Skip to content

Commit

Permalink
[bunkr] update to new site layout (#6344, #6352)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 21, 2024
1 parent 66aa514 commit 9a2bccd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
33 changes: 20 additions & 13 deletions gallery_dl/extractor/bunkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)

LEGACY_DOMAINS = {
"bunkr.cat",
"bunkr.ru",
"bunkrr.ru",
"bunkr.su",
Expand All @@ -52,24 +53,30 @@ def __init__(self, match):
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)

Expand Down
10 changes: 9 additions & 1 deletion gallery_dl/extractor/lolisafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ def items(self):
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):
Expand Down
32 changes: 16 additions & 16 deletions test/results/bunkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"#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-テスト-\"&>",
Expand All @@ -33,10 +33,10 @@
"#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",
Expand All @@ -54,7 +54,7 @@
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
"#pattern" : r"https://(i-)?meatballs.bunkr.ru/\w+",
"#count" : 9,
"#count" : 7,
},

{
Expand Down Expand Up @@ -173,30 +173,30 @@
"#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",
},

)

0 comments on commit 9a2bccd

Please sign in to comment.