Skip to content

Commit

Permalink
[bunkr] support 'bunkr:' URL prefix (#6017)
Browse files Browse the repository at this point in the history
and support 'bunkr.ax' by default
  • Loading branch information
mikf committed Aug 14, 2024
1 parent 2d55521 commit 0bbdeaa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Consider all listed sites to potentially be NSFW.
</tr>
<tr>
<td>Bunkr</td>
<td>https://bunkr.sk/</td>
<td>https://bunkr.si/</td>
<td>Albums, Media Files</td>
<td></td>
</tr>
Expand Down
17 changes: 9 additions & 8 deletions gallery_dl/extractor/bunkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractors for https://bunkr.sk/"""
"""Extractors for https://bunkr.si/"""

from .lolisafe import LolisafeAlbumExtractor
from .. import text

BASE_PATTERN = (
r"(?:bunkr:(?:https?://)?([^/?#]+)|"
r"(?:https?://)?(?:app\.)?(bunkr+"
r"\.(?:s[kiu]|[cf]i|ru|la|is|to|ac|black|cat|media|red|site|ws|org))"
r"\.(?:s[kiu]|[cf]i|ru|la|is|to|a[cx]|black|cat|media|red|site|ws|org)))"
)

LEGACY_DOMAINS = {
Expand All @@ -28,15 +29,15 @@


class BunkrAlbumExtractor(LolisafeAlbumExtractor):
"""Extractor for bunkr.sk albums"""
"""Extractor for bunkr.si albums"""
category = "bunkr"
root = "https://bunkr.sk"
root = "https://bunkr.si"
pattern = BASE_PATTERN + r"/a/([^/?#]+)"
example = "https://bunkr.sk/a/ID"
example = "https://bunkr.si/a/ID"

def __init__(self, match):
LolisafeAlbumExtractor.__init__(self, match)
domain = match.group(match.lastindex-1)
domain = self.groups[0] or self.groups[1]
if domain not in LEGACY_DOMAINS:
self.root = "https://" + domain

Expand Down Expand Up @@ -83,11 +84,11 @@ def _validate(self, response):


class BunkrMediaExtractor(BunkrAlbumExtractor):
"""Extractor for bunkr.sk media links"""
"""Extractor for bunkr.si media links"""
subcategory = "media"
directory_fmt = ("{category}",)
pattern = BASE_PATTERN + r"(/[vid]/[^/?#]+)"
example = "https://bunkr.sk/v/FILENAME"
example = "https://bunkr.si/v/FILENAME"

def fetch_album(self, album_id):
try:
Expand Down
2 changes: 1 addition & 1 deletion gallery_dl/extractor/lolisafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LolisafeAlbumExtractor(LolisafeExtractor):

def __init__(self, match):
LolisafeExtractor.__init__(self, match)
self.album_id = match.group(match.lastindex)
self.album_id = self.groups[-1]

def _init(self):
domain = self.config("domain")
Expand Down
12 changes: 12 additions & 0 deletions test/results/bunkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
"#count" : 9,
},

{
"#url" : "https://bunkr.ax/a/Lktg9Keq",
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
},

{
"#url" : "https://bunkrrr.org/a/Lktg9Keq",
"#category": ("lolisafe", "bunkr", "album"),
Expand Down Expand Up @@ -147,6 +153,12 @@
"#class" : bunkr.BunkrAlbumExtractor,
},

{
"#url" : "bunkr:http://example.org/a/Lktg9Keq",
"#category": ("lolisafe", "bunkr", "album"),
"#class" : bunkr.BunkrAlbumExtractor,
},

{
"#url" : "https://bunkr.black/i/image-sZrQUeOx.jpg",
"#category": ("lolisafe", "bunkr", "media"),
Expand Down

0 comments on commit 0bbdeaa

Please sign in to comment.