aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/bunkr.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/bunkr.py')
-rw-r--r--gallery_dl/extractor/bunkr.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/gallery_dl/extractor/bunkr.py b/gallery_dl/extractor/bunkr.py
index 14ebc48..ed9cd0f 100644
--- a/gallery_dl/extractor/bunkr.py
+++ b/gallery_dl/extractor/bunkr.py
@@ -11,6 +11,7 @@
from .common import Extractor
from .lolisafe import LolisafeAlbumExtractor
from .. import text, util, config, exception
+from ..cache import memcache
import random
if config.get(("extractor", "bunkr"), "tlds"):
@@ -63,7 +64,7 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
root_dl = "https://get.bunkrr.su"
root_api = "https://apidl.bunkr.ru"
archive_fmt = "{album_id}_{id|id_url|slug}"
- pattern = BASE_PATTERN + r"/a/([^/?#]+)"
+ pattern = rf"{BASE_PATTERN}/a/([^/?#]+)"
example = "https://bunkr.si/a/ID"
def __init__(self, match):
@@ -167,7 +168,7 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
item, 'name: "', ".")
file["size"] = text.parse_int(text.extr(
item, "size: ", " ,\n"))
- file["date"] = text.parse_datetime(text.extr(
+ file["date"] = self.parse_datetime(text.extr(
item, 'timestamp: "', '"'), "%H:%M:%S %d/%m/%Y")
yield file
@@ -176,6 +177,10 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
except Exception as exc:
self.log.error("%s: %s", exc.__class__.__name__, exc)
self.log.debug("%s", item, exc_info=exc)
+ if isinstance(exc, exception.HttpError) and \
+ exc.status == 400 and \
+ exc.response.url.startswith(self.root_api):
+ raise exception.AbortExtraction("Album deleted")
def _extract_file(self, data_id):
referer = f"{self.root_dl}/file/{data_id}"
@@ -211,7 +216,7 @@ class BunkrMediaExtractor(BunkrAlbumExtractor):
"""Extractor for bunkr.si media links"""
subcategory = "media"
directory_fmt = ("{category}",)
- pattern = BASE_PATTERN + r"(/[fvid]/[^/?#]+)"
+ pattern = rf"{BASE_PATTERN}(/[fvid]/[^/?#]+)"
example = "https://bunkr.si/f/FILENAME"
def fetch_album(self, album_id):
@@ -227,10 +232,26 @@ class BunkrMediaExtractor(BunkrAlbumExtractor):
self.log.error("%s: %s", exc.__class__.__name__, exc)
return (), {}
+ album_id, album_name, album_size = self._album_info(text.extr(
+ page, ' href="../a/', '"'))
return (file,), {
- "album_id" : "",
- "album_name" : "",
- "album_size" : -1,
- "description": "",
- "count" : 1,
+ "album_id" : album_id,
+ "album_name": album_name,
+ "album_size": album_size,
+ "count" : 1,
}
+
+ @memcache(keyarg=1)
+ def _album_info(self, album_id):
+ if album_id:
+ try:
+ page = self.request(f"{self.root}/a/{album_id}").text
+ return (
+ album_id,
+ text.unescape(text.unescape(text.extr(
+ page, 'property="og:title" content="', '"'))),
+ text.extr(page, '<span class="font-semibold">(', ')'),
+ )
+ except Exception:
+ pass
+ return album_id, "", -1