[bunkr] fix file downloads (#6037)

This commit is contained in:
Mike Fährmann
2024-08-17 11:01:42 +02:00
parent ef4c1b4fc5
commit 8ea75202ed
2 changed files with 18 additions and 13 deletions

View File

@@ -70,11 +70,16 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
def _extract_file(self, url): def _extract_file(self, url):
page = self.request(url).text page = self.request(url).text
return ( url = (text.extr(page, '<source src="', '"') or
text.extr(page, '<source src="', '"') or text.extr(page, '<img src="', '"'))
text.extr(page, '<img src="', '"') or
text.rextract(page, ' href="', '"', page.rindex("Download"))[0] if not url:
) url_download = text.rextract(
page, ' href="', '"', page.rindex("Download"))[0]
page = self.request(text.unescape(url_download)).text
url = text.unescape(text.rextract(page, ' href="', '"')[0])
return url
def _validate(self, response): def _validate(self, response):
if response.history and response.url.endswith("/maintenance-vid.mp4"): if response.history and response.url.endswith("/maintenance-vid.mp4"):

View File

@@ -175,18 +175,18 @@ __tests__ = (
}, },
{ {
"#url" : "https://bunkr.red/v/MY5aa4cLO7jN5", "#url" : "https://bunkrrr.org/d/sample-1-F3aGP907.zip",
"#category": ("lolisafe", "bunkr", "media"), "#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor, "#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://burger.bunkr.ru/video-gLn1hgpw.mp4", "#urls" : "https://burger.bunkr.ru/sample-1-F3aGP907.zip",
"#sha1_content": "f7a2ab24766a15ceffff1b07bada432b13ff8e5b", "#sha1_content": "d342c3982efc4b69dc18b2d4801fd08290e1ff12",
"count" : 1, "count" : 1,
"extension": "mp4", "extension": "zip",
"file" : "https://burger.bunkr.ru/video-gLn1hgpw.mp4", "file" : "https://burger.bunkr.ru/sample-1-F3aGP907.zip",
"filename" : "video-gLn1hgpw", "filename" : "sample-1-F3aGP907",
"id" : "gLn1hgpw", "id" : "F3aGP907",
"name" : "video", "name" : "sample-1",
}, },
) )