1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-21 18:22:30 +01:00

[patreon] handle exception for suspended accounts

This commit is contained in:
Mike Fährmann 2024-10-01 07:46:07 +02:00
parent 319c3a4c9b
commit 3d4191fc0d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 16 additions and 21 deletions

View File

@ -379,7 +379,15 @@ class PatreonPostExtractor(PatreonExtractor):
def posts(self):
url = "{}/posts/{}".format(self.root, self.groups[0])
page = self.request(url, notfound="post").text
post = self._extract_bootstrap(page)["post"]
bootstrap = self._extract_bootstrap(page)
try:
post = bootstrap["post"]
except KeyError:
self.log.debug(bootstrap)
if bootstrap.get("campaignDisciplinaryStatus") == "suspended":
self.log.warning("Account suspended")
return ()
included = self._transform(post["included"])
return (self._process(post["data"], included),)

View File

@ -12,7 +12,6 @@ from gallery_dl import exception
__tests__ = (
{
"#url" : "https://www.patreon.com/koveliana",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
"#range" : "1-15",
"#count" : 15,
@ -32,7 +31,6 @@ __tests__ = (
{
"#url" : "https://www.patreon.com/koveliana/posts?filters[month]=2020-3",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
"#count" : 1,
@ -41,79 +39,68 @@ __tests__ = (
{
"#url" : "https://www.patreon.com/kovelianot",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
"#exception": exception.NotFoundError,
},
{
"#url" : "https://www.patreon.com/user?u=2931440",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/user/posts/?u=2931440",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/user?c=369707",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/id:369707",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/home",
"#category": ("", "patreon", "user"),
"#class" : patreon.PatreonUserExtractor,
},
{
"#url" : "https://www.patreon.com/posts/precious-metal-23563293",
"#comment" : "postfile + attachments",
"#category": ("", "patreon", "post"),
"#class" : patreon.PatreonPostExtractor,
"#count" : 4,
},
{
"#url" : "https://www.patreon.com/posts/56127163",
"#comment" : "postfile + content",
"#category": ("", "patreon", "post"),
"#comment" : "account suspended",
"#class" : patreon.PatreonPostExtractor,
"#count" : 3,
"filename": r"re:^(?!1).+$",
"#count" : 0,
},
{
"#url" : "https://www.patreon.com/posts/free-post-12497641",
"#comment" : "tags (#1539)",
"#category": ("", "patreon", "post"),
"#class" : patreon.PatreonPostExtractor,
"tags": ["AWMedia"],
},
{
"#url" : "https://www.patreon.com/posts/meu8-94714289",
"#category": ("", "patreon", "post"),
"#url" : "https://www.patreon.com/posts/m3u8-94714289",
"#class" : patreon.PatreonPostExtractor,
"#range" : "2",
"#pattern" : r"ytdl:https://stream\.mux\.com/NLrxTLdxyGStpOgapJAtB8uPGAaokEcj8YovML00y2DY\.m3u8\?token=ey.+",
"#pattern" : [
r"https://c10\.patreonusercontent\.com/4/patreon-media/p/post/94714289/be3d8eb994ae44eca4baffcdc6dd25fc/eyJhIjoxLCJwIjoxfQ%3D%3D/1\.png",
r"ytdl:https://www.patreon\.com/api/video/255859412/video\.m3u8",
]
},
{
"#url" : "https://www.patreon.com/posts/not-found-123",
"#category": ("", "patreon", "post"),
"#class" : patreon.PatreonPostExtractor,
"#exception": exception.NotFoundError,
},