Skip to content

Commit

Permalink
[yaplog] improve metadata extraction (#443)
Browse files Browse the repository at this point in the history
- provide a fallback if there is no numerical image ID
- add a 'filename' field
- convert 'date' to an actual datetime object
  • Loading branch information
mikf committed Oct 11, 2019
1 parent 15af2f8 commit d4ffd6c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gallery_dl/extractor/yaplog.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ def items(self):
iurl = text.extract(page, '<img src="', '"')[0]
if iurl[0] == "/":
iurl = text.urljoin(self.root, iurl)
iid, _, ext = iurl.rpartition("/")[2].rpartition(".")
name, _, ext = iurl.rpartition("/")[2].rpartition(".")
iid = name.rpartition("_")[0] or name
image = {
"url" : iurl,
"num" : num,
"id" : text.parse_int(iid.partition("_")[0]),
"id" : text.parse_int(iid, iid),
"filename" : name,
"extension": ext,
"post" : post,
}
Expand Down Expand Up @@ -75,7 +77,7 @@ def _parse_post(self, url):
"id" : text.parse_int(pid),
"title": text.unescape(title[:-3]),
"user" : self.user,
"date" : date,
"date" : text.parse_datetime(date, "%B %d [%a], %Y, %H:%M"),
}


Expand All @@ -102,7 +104,7 @@ class YaplogPostExtractor(YaplogExtractor):
test = (
("https://yaplog.jp/imamiami0726/image/1299", {
"url": "896cae20fa718735a57e723c48544e830ff31345",
"keyword": "f8d8781e61c4c38238a7622d6df6c905f864e5d3",
"keyword": "22df8ad6cb534514c6bb2ff000381d156769a620",
}),
# complete image URLs (#443)
("https://yaplog.jp/msjane/archive/246", {
Expand Down

0 comments on commit d4ffd6c

Please sign in to comment.