1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +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 = {
"bunkr.cat",
"bunkr.ru",
"bunkrr.ru",
"bunkr.su",
@ -52,24 +53,30 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
def fetch_album(self, album_id):
# album metadata
page = self.request(self.root + "/a/" + self.album_id).text
info = text.split_html(text.extr(
page, "<h1", "</div>").partition(">")[2])
count, _, size = info[1].split(None, 2)
title, size = text.split_html(text.extr(
page, "<h1", "</span>").partition(">")[2])
pos = page.index('class="grid-images')
urls = list(text.extract_iter(page, '<a href="', '"', pos))
return self._extract_files(urls), {
items = list(text.extract_iter(page, "<!-- item -->", "<!-- -->"))
return self._extract_files(items), {
"album_id" : self.album_id,
"album_name" : text.unescape(info[0]),
"album_size" : size[1:-1],
"count" : len(urls),
"album_name" : title,
"album_size" : text.extr(size, "(", ")"),
"count" : len(items),
}
def _extract_files(self, urls):
for url in urls:
def _extract_files(self, items):
for item in items:
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:
self.log.error("%s: %s", exc.__class__.__name__, exc)

View File

@ -47,7 +47,15 @@ class LolisafeAlbumExtractor(LolisafeExtractor):
url = file["file"]
file.update(data)
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
def fetch_album(self, album_id):

View File

@ -12,15 +12,15 @@ __tests__ = (
"#url" : "https://bunkr.sk/a/Lktg9Keq",
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
"#urls" : "https://i-burger.bunkr.ru/test-テスト-\"&>-QjgneIQv.png",
"#sha1_content": "961b25d85b5f5bd18cbe3e847ac55925f14d0286",
"#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": "0c8768055e4e20e7c7259608b67799171b691140",
"album_id" : "Lktg9Keq",
"album_name" : "test テスト \"&>",
"album_size" : "182 B",
"count" : 1,
"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",
"id" : "QjgneIQv",
"name" : "test-テスト-\"&>",
@ -33,10 +33,10 @@ __tests__ = (
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
"#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",
),
"#sha1_content": "80914b8190ad001662f64e3b0b9c02ea3872c584",
"#sha1_content": "caf7c3d3439d94e83b3c24ddaf5a3a48aa057519",
"album_id" : "iXTTc1o2",
"album_name" : "test2",
@ -54,7 +54,7 @@ __tests__ = (
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
"#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",
"#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg",
"#sha1_content": "55998743751dfe008d0e95605114fcbfa7dc4de8",
"#urls" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg?download=true",
"#sha1_content": "caf7c3d3439d94e83b3c24ddaf5a3a48aa057519",
"count" : 1,
"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",
"id" : "sZrQUeOx",
"name" : "image",
},
{
"#url" : "https://bunkrrr.org/d/sample-1-F3aGP907.zip",
"#url" : "https://bunkrrr.org/d/dJuETSzKLrUps",
"#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://burger.bunkr.ru/sample-1-F3aGP907.zip",
"#sha1_content": "d342c3982efc4b69dc18b2d4801fd08290e1ff12",
"#urls" : "https://burger.bunkr.ru/file-r5fmwjdd.zip",
"#sha1_content": "102ddd7894fe39b3843098fc51f972a0af938f45",
"count" : 1,
"extension": "zip",
"file" : "https://burger.bunkr.ru/sample-1-F3aGP907.zip",
"filename" : "sample-1-F3aGP907",
"id" : "F3aGP907",
"name" : "sample-1",
"file" : "https://burger.bunkr.ru/file-r5fmwjdd.zip",
"filename" : "file-r5fmwjdd",
"id" : "r5fmwjdd",
"name" : "file",
},
)