Skip to content

Commit

Permalink
[fantia] apply patch (#2381)
Browse files Browse the repository at this point in the history
from @thatfuckingbird with small adjustments

#2381 (comment)
  • Loading branch information
mikf committed Mar 11, 2022
1 parent f31ab0d commit e64c2b8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions gallery_dl/extractor/fantia.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from .common import Extractor, Message
from .. import text
import json


class FantiaExtractor(Extractor):
Expand Down Expand Up @@ -92,14 +93,39 @@ def _get_urls_from_post(self, resp, post):
post["content_title"] = content["title"]
post["content_filename"] = content.get("filename", "")
post["content_id"] = content["id"]

if "comment" in content:
post["content_comment"] = content["comment"]

if "post_content_photos" in content:
for photo in content["post_content_photos"]:
post["file_id"] = photo["id"]
yield photo["url"]["original"], post

if "download_uri" in content:
post["file_id"] = content["id"]
yield self.root+"/"+content["download_uri"], post

if content["category"] == "blog" and "comment" in content:
comment_json = json.loads(content["comment"])
ops = comment_json.get("ops", ())

# collect blogpost text first
blog_text = ""
for op in ops:
insert = op.get("insert")
if isinstance(insert, str):
blog_text += insert
post["blogpost_text"] = blog_text

# collect images
for op in ops:
insert = op.get("insert")
if isinstance(insert, dict) and "fantiaImage" in insert:
img = insert["fantiaImage"]
post["file_id"] = img["id"]
yield "https://fantia.jp" + img["original_url"], post


class FantiaCreatorExtractor(FantiaExtractor):
"""Extractor for a Fantia creator's works"""
Expand Down

0 comments on commit e64c2b8

Please sign in to comment.