Skip to content

Commit

Permalink
[khinsider] add 'covers' option (#6844)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 18, 2025
1 parent 5a31a2a commit dc7b46b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,16 @@ Description
* ``"reverse"``: Same as ``"asc"``


extractor.khinsider.covers
--------------------------
Type
``bool``
Default
``false``
Description
Download album cover images.


extractor.khinsider.format
--------------------------
Type
Expand Down
1 change: 1 addition & 0 deletions docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
},
"khinsider":
{
"covers": false,
"format": "mp3"
},
"koharu":
Expand Down
19 changes: 17 additions & 2 deletions gallery_dl/extractor/khinsider.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ def items(self):

data = self.metadata(page)
yield Message.Directory, data
for track in self.tracks(page):

if self.config("covers", False):
for num, url in enumerate(self._extract_covers(page), 1):
cover = text.nameext_from_url(
url, {"url": url, "num": num, "type": "cover"})
cover.update(data)
yield Message.Url, url, cover

for track in self._extract_tracks(page):
track.update(data)
track["type"] = "track"
yield Message.Url, track["url"], track

def metadata(self, page):
Expand All @@ -56,7 +65,7 @@ def metadata(self, page):
"uploader": text.remove_html(extr("Uploaded by: ", "</")),
}}

def tracks(self, page):
def _extract_tracks(self, page):
fmt = self.config("format", ("mp3",))
if fmt and isinstance(fmt, str):
if fmt == "all":
Expand All @@ -80,3 +89,9 @@ def tracks(self, page):
yield track
if first:
yield first

def _extract_covers(self, page):
return [
text.unescape(text.extr(cover, ' href="', '"'))
for cover in text.extract_iter(page, ' class="albumImage', '</')
]
36 changes: 36 additions & 0 deletions test/results/khinsider.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,43 @@
"extension": "mp3",
"filename" : str,
"num" : int,
"type" : "track",
"url" : str,
},

{
"#url" : "https://downloads.khinsider.com/game-soundtracks/album/super-mario-64-soundtrack",
"#class": khinsider.KhinsiderSoundtrackExtractor,
"#options": {"covers": True},
"#range" : "1-10",
"#urls" : (
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/00%20Front.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/01%20Back.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/02%20Booklet%20Front%20and%20Back.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/03%20Booklet%20p%2001-02.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/04%20Booklet%20p%2003-04.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/05%20Booklet%20p%2005-06.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/06%20Disc.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/07%20Front%20digital.png",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/08%20Obi.jpg",
"https://vgmsite.com/soundtracks/super-mario-64-soundtrack/09%20Tray.jpg",
),

"extension": {"jpg", "png"},
"type" : "cover",
"album" : {
"catalog" : "PCCG-00357",
"count" : 36,
"date" : "Jul 1st, 2024",
"developer": "Nintendo",
"name" : "Super Mario 64 Original Soundtrack",
"platform" : ["N64"],
"publisher": "Nintendo",
"size" : 102760448,
"type" : "Soundtrack",
"uploader" : "HeroArts",
"year" : "1996",
},
},

)

0 comments on commit dc7b46b

Please sign in to comment.