Skip to content

Commit

Permalink
[bunkr] add extractor for media URLs (#4684)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 20, 2023
1 parent 0d52b77 commit b2c3db3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
34 changes: 33 additions & 1 deletion gallery_dl/extractor/bunkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from .. import text
from urllib.parse import urlsplit, urlunsplit

BASE_PATTERN = r"(?:https?://)?(?:app\.)?bunkr+\.(?:la|[sr]u|is|to)"

MEDIA_DOMAIN_OVERRIDES = {
"cdn9.bunkr.ru" : "c9.bunkr.ru",
"cdn12.bunkr.ru": "media-files12.bunkr.la",
Expand All @@ -28,7 +30,7 @@ class BunkrAlbumExtractor(LolisafeAlbumExtractor):
"""Extractor for bunkrr.su albums"""
category = "bunkr"
root = "https://bunkrr.su"
pattern = r"(?:https?://)?(?:app\.)?bunkr+\.(?:la|[sr]u|is|to)/a/([^/?#]+)"
pattern = BASE_PATTERN + r"/a/([^/?#]+)"
example = "https://bunkrr.su/a/ID"

def fetch_album(self, album_id):
Expand Down Expand Up @@ -72,3 +74,33 @@ def _extract_files(self, urls):
url = urlunsplit((scheme, domain, path, query, fragment))

yield {"file": text.unescape(url)}


class BunkrMediaExtractor(LolisafeAlbumExtractor):
"""Extractor for bunkrr.su media links"""
category = "bunkr"
subcategory = "media"
root = "https://bunkrr.su"
directory_fmt = ("{category}",)
pattern = BASE_PATTERN + r"/[vi]/([^/?#]+)"
example = "https://bunkrr.su/v/FILENAME"

def fetch_album(self, album_id):
try:
path = urlsplit(self.url).path
page = self.request(self.root + path).text
if path[1] == "v":
url = text.extr(page, '<source src="', '"')
else:
url = text.extr(page, '<img src="', '"')
except Exception as exc:
self.log.error("%s: %s", exc.__class__.__name__, exc)
return (), {}

return ({"file": text.unescape(url)},), {
"album_id" : "",
"album_name" : "",
"album_size" : -1,
"description": "",
"count" : 1,
}
36 changes: 33 additions & 3 deletions test/results/bunkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
"#urls" : (
"https://media-files4.bunkr.ru/video-wFO9FtxG.mp4",
"https://i4.bunkr.ru/image-sZrQUeOx.jpg",
"https://milkshake.bunkr.ru/video-wFO9FtxG.mp4",
"https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg",
),
"#sha1_content": "da29aae371b7adc8c5ef8e6991b66b69823791e8",

Expand All @@ -61,7 +61,7 @@
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
"#pattern" : r"https://(i-)?meatballs.bunkr.ru/\w+",
"#count" : 10,
"#count" : 9,
},

{
Expand Down Expand Up @@ -100,4 +100,34 @@
"#class" : bunkr.BunkrAlbumExtractor,
},

{
"#url" : "https://bunkrr.su/i/image-sZrQUeOx.jpg",
"#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg",
"#sha1_content": "caf7c3d3439d94e83b3c24ddaf5a3a48aa057519",

"count" : 1,
"extension": "jpg",
"file" : "https://i-milkshake.bunkr.ru/image-sZrQUeOx.jpg",
"filename" : "image-sZrQUeOx",
"id" : "sZrQUeOx",
"name" : "image",
},

{
"#url" : "https://bunkrr.su/v/video-wFO9FtxG.mp4",
"#category": ("lolisafe", "bunkr", "media"),
"#class" : bunkr.BunkrMediaExtractor,
"#urls" : "https://milkshake.bunkr.ru/video-wFO9FtxG.mp4",
"#sha1_content": "a8cba735ae533507b1810b88d11df7028286dd8a",

"count" : 1,
"extension": "mp4",
"file" : "https://milkshake.bunkr.ru/video-wFO9FtxG.mp4",
"filename" : "video-wFO9FtxG",
"id" : "wFO9FtxG",
"name" : "video",
},

)

0 comments on commit b2c3db3

Please sign in to comment.