[kemonoparty] support new discord channel URLs (#6542)
This commit is contained in:
@@ -345,18 +345,15 @@ class KemonopartyDiscordExtractor(KemonopartyExtractor):
|
|||||||
"{channel_name|channel}")
|
"{channel_name|channel}")
|
||||||
filename_fmt = "{id}_{num:>02}_{filename}.{extension}"
|
filename_fmt = "{id}_{num:>02}_{filename}.{extension}"
|
||||||
archive_fmt = "discord_{server}_{id}_{num}"
|
archive_fmt = "discord_{server}_{id}_{num}"
|
||||||
pattern = BASE_PATTERN + r"/discord/server/(\d+)(?:/channel/(\d+))?#(.*)"
|
pattern = (BASE_PATTERN + r"/discord/server/(\d+)"
|
||||||
example = "https://kemono.su/discord/server/12345#CHANNEL"
|
r"(?:/(?:channel/)?(\d+)(?:#(.+))?|#(.+))")
|
||||||
|
example = "https://kemono.su/discord/server/12345/12345"
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
self._prepare_ddosguard_cookies()
|
self._prepare_ddosguard_cookies()
|
||||||
|
_, _, server_id, channel_id, channel_name, channel = self.groups
|
||||||
|
|
||||||
_, _, server_id, channel_id, channel = self.groups
|
if channel_id is None:
|
||||||
channel_name = ""
|
|
||||||
|
|
||||||
if channel_id:
|
|
||||||
channel_name = channel
|
|
||||||
else:
|
|
||||||
if channel.isdecimal() and len(channel) >= 16:
|
if channel.isdecimal() and len(channel) >= 16:
|
||||||
key = "id"
|
key = "id"
|
||||||
else:
|
else:
|
||||||
@@ -370,6 +367,8 @@ class KemonopartyDiscordExtractor(KemonopartyExtractor):
|
|||||||
|
|
||||||
channel_id = ch["id"]
|
channel_id = ch["id"]
|
||||||
channel_name = ch["name"]
|
channel_name = ch["name"]
|
||||||
|
elif channel_name is None:
|
||||||
|
channel_name = ""
|
||||||
|
|
||||||
find_inline = re.compile(
|
find_inline = re.compile(
|
||||||
r"https?://(?:cdn\.discordapp.com|media\.discordapp\.net)"
|
r"https?://(?:cdn\.discordapp.com|media\.discordapp\.net)"
|
||||||
@@ -422,7 +421,7 @@ class KemonopartyDiscordServerExtractor(KemonopartyExtractor):
|
|||||||
def items(self):
|
def items(self):
|
||||||
server_id = self.groups[2]
|
server_id = self.groups[2]
|
||||||
for channel in self.api.discord_server(server_id):
|
for channel in self.api.discord_server(server_id):
|
||||||
url = "{}/discord/server/{}/channel/{}#{}".format(
|
url = "{}/discord/server/{}/{}#{}".format(
|
||||||
self.root, server_id, channel["id"], channel["name"])
|
self.root, server_id, channel["id"], channel["name"])
|
||||||
channel["_extractor"] = KemonopartyDiscordExtractor
|
channel["_extractor"] = KemonopartyDiscordExtractor
|
||||||
yield Message.Queue, url, channel
|
yield Message.Queue, url, channel
|
||||||
|
|||||||
@@ -299,6 +299,16 @@ __tests__ = (
|
|||||||
"type" : "attachment",
|
"type" : "attachment",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://kemono.su/discord/server/488668827274444803/608504710906904576",
|
||||||
|
"#category": ("", "kemonoparty", "discord"),
|
||||||
|
"#class" : kemonoparty.KemonopartyDiscordExtractor,
|
||||||
|
"#count" : 4,
|
||||||
|
|
||||||
|
"channel" : "608504710906904576",
|
||||||
|
"channel_name": "",
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://kemono.su/discord/server/488668827274444803#608504710906904576",
|
"#url" : "https://kemono.su/discord/server/488668827274444803#608504710906904576",
|
||||||
"#category": ("", "kemonoparty", "discord"),
|
"#category": ("", "kemonoparty", "discord"),
|
||||||
|
|||||||
Reference in New Issue
Block a user