1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[weibo] fix livephoto 'filename' & 'extension' (#6471)

This commit is contained in:
Mike Fährmann 2024-11-14 18:56:18 +01:00
parent a3276e3b5d
commit 396b52aef7
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 17 additions and 10 deletions

View File

@ -127,10 +127,14 @@ class WeiboExtractor(Extractor):
elif pic_type == "livephoto" and self.livephoto:
append(pic["largest"].copy())
file = {"url": pic["video"]}
file["filename"], _, file["extension"] = \
pic["video"].rpartition("%2F")[2].rpartition(".")
append(file)
url = pic["video"]
fname, _, ext = (
url.rpartition("%2F")[2]
if "%2F" in url else
text.filename_from_url(url)
).rpartition(".")
append({"url": url, "filename": fname, "extension": ext})
else:
append(pic["largest"].copy())
@ -251,8 +255,10 @@ class WeiboUserExtractor(WeiboExtractor):
pattern = USER_PATTERN + r"(?:$|#)"
example = "https://weibo.com/USER"
def initialize(self):
pass
# do NOT override 'initialize()'
# it is needed for 'self._user_id()'
# def initialize(self):
# pass
def items(self):
base = "{}/u/{}?tabtype=".format(self.root, self._user_id())

View File

@ -227,13 +227,14 @@ __tests__ = (
},
{
"#url" : "https://weibo.com/5643044717/KkuDZ4jAA",
"#comment" : "type == livephoto (#2146)",
"#url" : "https://weibo.com/3194672795/OuxSwgUrC",
"#comment" : "type == livephoto (#2146, #6471)",
"#category": ("", "weibo", "status"),
"#class" : weibo.WeiboStatusExtractor,
"#pattern" : r"https://video\.weibo\.com/media/play\?livephoto=https%3A%2F%2Fus\.sinaimg\.cn%2F\w+\.mov",
"#range" : "2,4,6",
"#pattern" : r"https://livephoto\.us\.sinaimg\.cn/\w+\.mov\?Expires=\d+&ssig=\w+&KID=unistore,video",
"#range" : "2,4",
"filename" : {"000yfKhRjx08hBAXxdZ60f0f0100tBPr0k01", "000GEYrCjx08hBAXUFo40f0f0100vS5G0k01"},
"extension": "mov",
},