[discord] add support (#6836)

* first commit

* add --

* skip video embeds

* fix typo

* removed ambiguity

* add category support

* code tweaks

* more reliable embed extraction

* handle 403 errors (testing done)

* added "parent_id" keyword

* added "parent", "parent_type" keywords

the extractor should be now ready to merge!

* removed unnecessary dict unpacking

* added empty text messages extraction

* added "channel_topic"

* even more metadata extraction

can now extract all embeds images & text, as well as server banners. also code is much better.

* added user avatar and banner

* better pagination

* fix regression

* minor tweaks

* Made requested changes
This commit is contained in:
Luca Russo
2025-02-18 18:45:39 +01:00
committed by GitHub
parent fd4de02e67
commit 95c446fcd1
6 changed files with 466 additions and 0 deletions

64
test/results/discord.py Normal file
View File

@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
from gallery_dl.extractor import discord
__tests__ = (
{
"#url" : "https://discord.com/channels/302094807046684672/1306705919916249098",
"#category": ("", "discord", "channel"),
"#class" : discord.DiscordChannelExtractor,
# # access token & access to minecraft server required for this test (REMEMBER TO REMOVE TOKEN BEFORE COMMITTING)
# "#range" : "1-2",
# "#count" : 2,
# "#options" : {"token": ""},
#
# "#server" : "MINECRAFT",
# "#server_id" : "302094807046684672",
# "#server_files" : list,
# "#owner_id" : "827254075857829920",
# "#channel" : str,
# "#channel_id" : str,
# "#channel_type" : 11,
# "#channel_topic": str,
# "#parent" : "challenges",
# "#parent_id" : "1306705919916249098",
# "#parent_type" : 15,
# "#is_thread" : True,
#
# "author" : str,
# "author_id" : str,
# "author_files": list,
# "message" : str,
# "message_id" : str,
# "type" : str,
# "date" : "type:datetime",
# "files" : list,
# "filename" : str,
# "extension" : str,
# "num" : int,
},
{
"#url" : "https://discord.com/channels/302094807046684672/1306705919916249098/threads/1306706528786583623",
"#category": ("", "discord", "channel"),
"#class" : discord.DiscordChannelExtractor,
},
{
"#url" : "https://discord.com/channels/302094807046684672",
"#category": ("", "discord", "server"),
"#class" : discord.DiscordServerExtractor,
},
{
"#url" : "https://discord.com/channels/@me/302094807046684672",
"#category": ("", "discord", "direct-messages"),
"#class" : discord.DiscordDirectMessagesExtractor,
},
)