diff --git a/gallery_dl/extractor/weibo.py b/gallery_dl/extractor/weibo.py index 879cd969..b681002f 100644 --- a/gallery_dl/extractor/weibo.py +++ b/gallery_dl/extractor/weibo.py @@ -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()) diff --git a/test/results/weibo.py b/test/results/weibo.py index 8f46da3f..a27a26e9 100644 --- a/test/results/weibo.py +++ b/test/results/weibo.py @@ -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", },