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

[zzzz] add album extractor #2105

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"oauth",
"test",
"ytdl",
"zzzz",
]


Expand Down
43 changes: 43 additions & 0 deletions gallery_dl/extractor/zzzz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from .common import Extractor, Message
from .. import text


class ZzzzAlbumExtractor(Extractor):
category = "zzzz"
subcategory = "album"
pattern = r"(?:https?://)?zz\.(ht|fo)/a/([^/?#]+)"
root = "https://zz.ht"
directory_fmt = ("{category}", "{album_name} ({album_id})")
test = (
("https://zz.ht/a/lop7W6EZ", {
"pattern": "https://z.zz.fo/.*",
"keyword": {"album_id": "lop7W6EZ", "album_name": "ferris"}
}),
("https://zz.fo/a/lop7W6EZ", {
"pattern": "https://z.zz.fo/.*",
"keyword": {"album_id": "lop7W6EZ", "album_name": "ferris"}
})
)

def __init__(self, match):
Extractor.__init__(self, match)
self.album_id = match.group(2)

def items(self):
url = self.root + "/a/" + self.album_id
extr = text.extract_from(self.request(url).text, default=None)
album_name = extr("<title>", "</title>")
files = []
while True:
url = extr('class="image" href="', '"')
if not url:
break
files.append(text.unescape(url))
data = {
"album_id": self.album_id,
"album_name": album_name
}
yield Message.Directory, data
for url in files:
text.nameext_from_url(url, data)
yield Message.Url, url, data