Skip to content

Commit

Permalink
[nijie] support downloading videos (#5707, #5617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 8, 2024
1 parent e17b1d5 commit 2e11b6e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gallery_dl/extractor/nijie.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def items(self):
data["user_id"] = data["artist_id"]
data["user_name"] = data["artist_name"]

urls = list(self._extract_images(image_id, page))
urls = self._extract_images(image_id, page)
data["count"] = len(urls)

yield Message.Directory, data
Expand Down Expand Up @@ -113,11 +113,14 @@ def _extract_images(self, image_id, page):
# multiple images
url = "{}/view_popup.php?id={}".format(self.root, image_id)
page = self.request(url).text
yield from text.extract_iter(
page, 'href="javascript:void(0);"><img src="', '"')
return [
text.extr(media, ' src="', '"')
for media in text.extract_iter(
page, 'href="javascript:void(0);"><', '>')
]
else:
pos = page.find('id="view-center"') + 1
yield text.extract(page, 'itemprop="image" src="', '"', pos)[0]
return (text.extr(page, 'itemprop="image" src="', '"', pos),)

@staticmethod
def _extract_user_name(page):
Expand Down
12 changes: 12 additions & 0 deletions test/results/nijie.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@
"#urls" : "https://pic.nijie.net/03/nijie/13/98/498/illust/0_0_703023d18ca8d058_bca943.jpg",
},

{
"#url" : "https://nijie.info/view.php?id=385585",
"#comment" : "video (#5707)",
"#category": ("Nijie", "nijie", "image"),
"#class" : nijie.NijieImageExtractor,
"#urls" : (
"https://pic.nijie.net/01/nijie/20/82/59182/illust/0_0_162270ef49e2ee28_fab5ae.mp4",
"https://pic.nijie.net/04/nijie/20/82/59182/illust/385585_0_ff2d5d19129530d5_b2821e.jpg",
"https://pic.nijie.net/01/nijie/20/82/59182/illust/385585_1_7ee1a2a67bed2f84_212d67.jpg",
),
},

{
"#url" : "https://nijie.info/view.php?id=70724",
"#category": ("Nijie", "nijie", "image"),
Expand Down

0 comments on commit 2e11b6e

Please sign in to comment.