Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[urlgalleries] add support #4886

Merged
merged 2 commits into from Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/supportedsites.md
Expand Up @@ -889,6 +889,12 @@ Consider all sites to be NSFW unless otherwise known.
<td>Files</td>
<td></td>
</tr>
<tr>
<td>Urlgalleries</td>
<td>https://urlgalleries.net/</td>
<td>Galleries</td>
<td></td>
</tr>
<tr>
<td>Vipergirls</td>
<td>https://vipergirls.to/</td>
Expand Down
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Expand Up @@ -155,6 +155,7 @@
"tumblrgallery",
"twibooru",
"twitter",
"urlgalleries",
"unsplash",
"uploadir",
"urlshortener",
Expand Down
43 changes: 43 additions & 0 deletions gallery_dl/extractor/urlgalleries.py
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractors for https://urlgalleries.net/"""

from .common import GalleryExtractor
from .. import text


class UrlgalleriesGalleryExtractor(GalleryExtractor):
"""Base class for Urlgalleries extractors"""
category = "urlgalleries"
root = "urlgalleries.net"
directory_fmt = ("{category}", "{title}")
pattern = r"(?:https?://)([^/?#]+)?\.urlgalleries\.net/([^/?#]+)/([^/?#]+)"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pattern = r"(?:https?://)([^/?#]+)?\.urlgalleries\.net/([^/?#]+)/([^/?#]+)"
pattern = r"(?:https?://)([^/?#]+\.)?urlgalleries\.net/([^/?#]+)/([^/?#]+)"

otherwise it would match https://.urlgalleries.net

example = "https://blog.urlgalleries.net/gallery-1234567/a-title--1234"

def __init__(self, match):
self.blog = match.group(1)
self.gallery_id = match.group(2)
self.title = match.group(3)
url = "{}.urlgalleries.net/{}/{}&a=10000".format(
self.blog, self.gallery_id, self.title)
GalleryExtractor.__init__(self, match, text.ensure_http_scheme(url))

def images(self, page):
extr = text.extr(page, 'id="wtf"', "</div>")
url = "{}{{}}".format(self.root).format
return [
(text.ensure_http_scheme(url(i)), None)
for i in text.extract_iter(extr, "href='", "'")
]

def metadata(self, page):
date = text.extr(
page, "float:left;'> ", '</div>').split(" | ")[-1]
return {
'title': self.title,
'date': text.parse_datetime(date, format='%B %d, %Y T%H:%M')
}