[khinsider] add 'covers' option (#6844)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -366,6 +366,7 @@
|
||||
},
|
||||
"khinsider":
|
||||
{
|
||||
"covers": false,
|
||||
"format": "mp3"
|
||||
},
|
||||
"koharu":
|
||||
|
||||
@@ -36,8 +36,17 @@ class KhinsiderSoundtrackExtractor(AsynchronousMixin, Extractor):
|
||||
|
||||
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):
|
||||
@@ -56,7 +65,7 @@ class KhinsiderSoundtrackExtractor(AsynchronousMixin, Extractor):
|
||||
"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":
|
||||
@@ -80,3 +89,9 @@ class KhinsiderSoundtrackExtractor(AsynchronousMixin, Extractor):
|
||||
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', '</')
|
||||
]
|
||||
|
||||
@@ -53,7 +53,43 @@ __tests__ = (
|
||||
"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",
|
||||
},
|
||||
},
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user