[bunkr] update domain (#3391)

and improve bunkr/app.bunkr handling
pull/3406/head
Mike Fährmann 2 years ago
parent eb94568e1f
commit 6b6f886dcf
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -971,7 +971,7 @@ extractor.cyberdrop.domain
Type Type
``string`` ``string``
Default Default
``"auto"`` ``null``
Example Example
``"cyberdrop.to"`` ``"cyberdrop.to"``
Description Description
@ -1717,7 +1717,7 @@ extractor.lolisafe.domain
Type Type
``string`` ``string``
Default Default
``"auto"`` ``null``
Description Description
Specifies the domain used by a ``lolisafe`` extractor Specifies the domain used by a ``lolisafe`` extractor
regardless of input URL. regardless of input URL.

@ -55,7 +55,7 @@
}, },
"cyberdrop": "cyberdrop":
{ {
"domain": "auto" "domain": null
}, },
"danbooru": "danbooru":
{ {

@ -111,7 +111,7 @@ Consider all sites to be NSFW unless otherwise known.
</tr> </tr>
<tr> <tr>
<td>Bunkr</td> <td>Bunkr</td>
<td>https://bunkr.is/</td> <td>https://bunkr.ru/</td>
<td>Albums</td> <td>Albums</td>
<td></td> <td></td>
</tr> </tr>

@ -6,7 +6,7 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extractors for https://bunkr.is/""" """Extractors for https://bunkr.ru/"""
from .lolisafe import LolisafeAlbumExtractor from .lolisafe import LolisafeAlbumExtractor
from .. import text from .. import text
@ -14,13 +14,13 @@ import json
class BunkrAlbumExtractor(LolisafeAlbumExtractor): class BunkrAlbumExtractor(LolisafeAlbumExtractor):
"""Extractor for bunkr.is albums""" """Extractor for bunkr.ru albums"""
category = "bunkr" category = "bunkr"
root = "https://bunkr.is" root = "https://bunkr.ru"
pattern = r"(?:https?://)?(?:app\.)?bunkr\.(?:is|to)/a/([^/?#]+)" pattern = r"(?:https?://)?(?:app\.)?bunkr\.(?:ru|is|to)/a/([^/?#]+)"
test = ( test = (
("https://bunkr.is/a/Lktg9Keq", { ("https://bunkr.ru/a/Lktg9Keq", {
"pattern": r"https://cdn\.bunkr\.is/test-テスト-\"&>-QjgneIQv\.png", "pattern": r"https://cdn\.bunkr\.ru/test-テスト-\"&>-QjgneIQv\.png",
"content": "0c8768055e4e20e7c7259608b67799171b691140", "content": "0c8768055e4e20e7c7259608b67799171b691140",
"keyword": { "keyword": {
"album_id": "Lktg9Keq", "album_id": "Lktg9Keq",
@ -34,64 +34,46 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
}), }),
# mp4 (#2239) # mp4 (#2239)
("https://app.bunkr.is/a/ptRHaCn2", { ("https://app.bunkr.is/a/ptRHaCn2", {
"pattern": r"https://media-files\.bunkr\.is/_-RnHoW69L\.mp4", "pattern": r"https://media-files\.bunkr\.ru/_-RnHoW69L\.mp4",
"content": "80e61d1dbc5896ae7ef9a28734c747b28b320471", "content": "80e61d1dbc5896ae7ef9a28734c747b28b320471",
}), }),
# cdn4 # cdn4
("https://bunkr.is/a/iXTTc1o2", { ("https://bunkr.is/a/iXTTc1o2", {
"pattern": r"https://(cdn|media-files)4\.bunkr\.is/", "pattern": r"https://(cdn|media-files)4\.bunkr\.ru/",
"content": "da29aae371b7adc8c5ef8e6991b66b69823791e8", "content": "da29aae371b7adc8c5ef8e6991b66b69823791e8",
}), }),
("https://bunkr.to/a/Lktg9Keq"), ("https://bunkr.to/a/Lktg9Keq"),
) )
def fetch_album(self, album_id): def fetch_album(self, album_id):
if "//app." in self.root: root = self.root
return self._fetch_album_api(album_id)
else:
return self._fetch_album_site(album_id)
def _fetch_album_api(self, album_id):
files, data = LolisafeAlbumExtractor.fetch_album(self, album_id)
for file in files:
url = file["file"]
if url.endswith(".mp4"):
file["file"] = url.replace(
"//cdn.bunkr.is/", "//media-files.bunkr.is/", 1)
else:
file["_fallback"] = (url.replace("//cdn.", "//cdn3.", 1),)
return files, data
def _fetch_album_site(self, album_id):
url = self.root + "/a/" + self.album_id
try: try:
data = json.loads(text.extr( data = json.loads(text.extr(
self.request(url).text, self.request(root + "/a/" + self.album_id).text,
'id="__NEXT_DATA__" type="application/json">', '<')) 'id="__NEXT_DATA__" type="application/json">', '<'))
album = data["props"]["pageProps"]["album"] album = data["props"]["pageProps"]["album"]
files = album["files"] files = album["files"]
except Exception as exc: except Exception as exc:
self.log.debug(exc.__class__.__name__, exc) self.log.debug("%s: %s", exc.__class__.__name__, exc)
self.root = self.root.replace("bunkr", "app.bunkr", 1) self.root = root.replace("://", "://app.", 1)
return self._fetch_album_api(album_id) files, data = LolisafeAlbumExtractor.fetch_album(self, album_id)
else:
headers = {"Referer": "https://stream.bunkr.is/"}
for file in files: for file in files:
name = file["name"] file["file"] = file["cdn"] + "/" + file["name"]
cdn = file["cdn"] data = {
if name.endswith((".mp4", ".m4v", ".mov", ".webm",
".zip", ".rar", ".7z")):
cdn = cdn.replace("//cdn", "//media-files", 1)
file["_http_headers"] = headers
file["file"] = cdn + "/" + name
return files, {
"album_id" : self.album_id, "album_id" : self.album_id,
"album_name" : text.unescape(album["name"]), "album_name" : text.unescape(album["name"]),
"description": text.unescape(album["description"]), "description": text.unescape(album["description"]),
"count" : len(files), "count" : len(files),
} }
headers = {"Referer": root.replace("://", "://stream.", 1)}
for file in files:
if file["file"].endswith(
(".mp4", ".m4v", ".mov", ".webm", ".zip", ".rar", ".7z")):
file["_http_headers"] = headers
file["file"] = file["file"].replace(
"//cdn", "//media-files", 1)
return files, data

@ -23,7 +23,7 @@ BASE_PATTERN = LolisafeExtractor.update({
"xbunkr": { "xbunkr": {
"root": "https://xbunkr.com", "root": "https://xbunkr.com",
"pattern": r"xbunkr\.com", "pattern": r"xbunkr\.com",
} },
}) })
@ -47,9 +47,9 @@ class LolisafeAlbumExtractor(LolisafeExtractor):
self.album_id = match.group(match.lastindex) self.album_id = match.group(match.lastindex)
domain = self.config("domain") domain = self.config("domain")
if domain is None or domain == "auto": if domain == "auto":
self.root = text.root_from_url(match.group(0)) self.root = text.root_from_url(match.group(0))
else: elif domain:
self.root = text.ensure_http_scheme(domain) self.root = text.ensure_http_scheme(domain)
def items(self): def items(self):

Loading…
Cancel
Save