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

[bunkr] update to new site layout (#6344, #6352)

This commit is contained in:
Mike Fährmann 2024-10-21 14:07:27 +02:00
parent 66aa514c25
commit 9a2bccd0d9
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 45 additions and 30 deletions

View File

@ -26,6 +26,7 @@ else:
) )
LEGACY_DOMAINS = { LEGACY_DOMAINS = {
"bunkr.cat",
"bunkr.ru", "bunkr.ru",
"bunkrr.ru", "bunkrr.ru",
"bunkr.su", "bunkr.su",
@ -52,24 +53,30 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
def fetch_album(self, album_id): def fetch_album(self, album_id):
# album metadata # album metadata
page = self.request(self.root + "/a/" + self.album_id).text page = self.request(self.root + "/a/" + self.album_id).text
info = text.split_html(text.extr( title, size = text.split_html(text.extr(
page, "<h1", "</div>").partition(">")[2]) page, "<h1", "</span>").partition(">")[2])
count, _, size = info[1].split(None, 2)
pos = page.index('class="grid-images') items = list(text.extract_iter(page, "<!-- item -->", "<!-- -->"))
urls = list(text.extract_iter(page, '<a href="', '"', pos)) return self._extract_files(items), {
return self._extract_files(urls), {
"album_id" : self.album_id, "album_id" : self.album_id,
"album_name" : text.unescape(info[0]), "album_name" : title,
"album_size" : size[1:-1], "album_size" : text.extr(size, "(", ")"),
"count" : len(urls), "count" : len(items),
} }
def _extract_files(self, urls): def _extract_files(self, items):
for url in urls: for item in items:
try: try:
yield self._extract_file(text.unescape(url)) url = text.extr(item, ' href="', '"')
file = self._extract_file(text.unescape(url))
info = text.split_html(item)
file["name"] = info[0]
file["size"] = info[2]
file["date"] = text.parse_datetime(
info[-1], "%H:%M:%S %d/%m/%Y")
yield file
except Exception as exc: except Exception as exc:
self.log.error("%s: %s", exc.__class__.__name__, exc) self.log.error("%s: %s", exc.__class__.__name__, exc)

View File

@ -47,7 +47,15 @@ class LolisafeAlbumExtractor(LolisafeExtractor):
url = file["file"] url = file["file"]
file.update(data) file.update(data)
text.nameext_from_url(url, file) text.nameext_from_url(url, file)
file["name"], sep, file["id"] = file["filename"].rpartition("-")
if "name" in file:
name = file["name"]
file["name"] = name.rpartition(".")[0] or name
file["id"] = file["filename"].rpartition("-")[2]
else:
file["name"], sep, file["id"] = \
file["filename"].rpartition("-")
yield Message.Url, url, file yield Message.Url, url, file
def fetch_album(self, album_id): def fetch_album(self, album_id):

View File

@ -12,15 +12,15 @@ __tests__ = (
"#url" : "https://bunkr.sk/a/Lktg9Keq", "#url" : "https://bunkr.sk/a/Lktg9Keq",
"#category": ("lolisafe", "bunkr", "album"), "#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor, "#class" : bunkr.BunkrAlbumExtractor,
"#urls" : "https://i-burger.bunkr.ru/test-テスト-\"&>-QjgneIQv.png", "#urls" : "https://i-burger.bunkr.ru/test-%E3%83%86%E3%82%B9%E3%83%88-%22%26%3E-QjgneIQv.png?download=true",
"#sha1_content": "961b25d85b5f5bd18cbe3e847ac55925f14d0286", "#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
"album_id" : "Lktg9Keq", "album_id" : "Lktg9Keq",
"album_name" : "test テスト \"&>", "album_name" : "test テスト \"&>",
"album_size" : "182 B", "album_size" : "182 B",
"count" : 1, "count" : 1,
"extension" : "png", "extension" : "png",
"file" : "https://i-burger.bunkr.ru/test-テスト-\"&>-QjgneIQv.png", "file" : "https://i-burger.bunkr.ru/test-%E3%83%86%E3%82%B9%E3%83%88-%22%26%3E-QjgneIQv.png?download=true",
"filename" : "test-テスト-\"&>-QjgneIQv", "filename" : "test-テスト-\"&>-QjgneIQv",
"id" : "QjgneIQv", "id" : "QjgneIQv",
"name" : "test-テスト-\"&>", "name" : "test-テスト-\"&>",
@ -33,10 +33,10 @@ __tests__ = (
"#category": ("lolisafe", "bunkr", "album"), "#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor, "#class" : bunkr.BunkrAlbumExtractor,
"#urls" : ( "#urls" : (
"https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg", "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg?download=true",
"https://burger.bunkr.ru/video-gLn1hgpw.mp4", "https://burger.bunkr.ru/video-gLn1hgpw.mp4",
), ),
"#sha1_content": "80914b8190ad001662f64e3b0b9c02ea3872c584", "#sha1_content": "caf7c3d3439d94e83b3c24ddaf5a3a48aa057519",
"album_id" : "iXTTc1o2", "album_id" : "iXTTc1o2",
"album_name" : "test2", "album_name" : "test2",
@ -54,7 +54,7 @@ __tests__ = (
"#category": ("lolisafe", "bunkr", "album"), "#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor, "#class" : bunkr.BunkrAlbumExtractor,
"#pattern" : r"https://(i-)?meatballs.bunkr.ru/\w+", "#pattern" : r"https://(i-)?meatballs.bunkr.ru/\w+",
"#count" : 9, "#count" : 7,
}, },
{ {
@ -173,30 +173,30 @@ __tests__ = (
"#url" : "https://bunkr.black/i/image-sZrQUeOx.jpg", "#url" : "https://bunkr.black/i/image-sZrQUeOx.jpg",
"#category": ("lolisafe", "bunkr", "media"), "#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor, "#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg", "#urls" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg?download=true",
"#sha1_content": "55998743751dfe008d0e95605114fcbfa7dc4de8", "#sha1_content": "caf7c3d3439d94e83b3c24ddaf5a3a48aa057519",
"count" : 1, "count" : 1,
"extension": "jpg", "extension": "jpg",
"file" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg", "file" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg?download=true",
"filename" : "image-sZrQUeOx", "filename" : "image-sZrQUeOx",
"id" : "sZrQUeOx", "id" : "sZrQUeOx",
"name" : "image", "name" : "image",
}, },
{ {
"#url" : "https://bunkrrr.org/d/sample-1-F3aGP907.zip", "#url" : "https://bunkrrr.org/d/dJuETSzKLrUps",
"#category": ("lolisafe", "bunkr", "media"), "#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor, "#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://burger.bunkr.ru/sample-1-F3aGP907.zip", "#urls" : "https://burger.bunkr.ru/file-r5fmwjdd.zip",
"#sha1_content": "d342c3982efc4b69dc18b2d4801fd08290e1ff12", "#sha1_content": "102ddd7894fe39b3843098fc51f972a0af938f45",
"count" : 1, "count" : 1,
"extension": "zip", "extension": "zip",
"file" : "https://burger.bunkr.ru/sample-1-F3aGP907.zip", "file" : "https://burger.bunkr.ru/file-r5fmwjdd.zip",
"filename" : "sample-1-F3aGP907", "filename" : "file-r5fmwjdd",
"id" : "F3aGP907", "id" : "r5fmwjdd",
"name" : "sample-1", "name" : "file",
}, },
) )