add missing tests

This commit is contained in:
Mike Fährmann
2016-09-19 16:15:27 +02:00
parent a017cd9e63
commit 49a05c32ed
7 changed files with 32 additions and 6 deletions

View File

@@ -6,10 +6,10 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
"""Extract soundtracks from https://khinsider.com/"""
"""Extract soundtracks from http://khinsider.com/"""
from .common import AsynchronousExtractor, Message
from .. import text
from .. import text, exception
class KhinsiderSoundtrackExtractor(AsynchronousExtractor):
"""Extractor for soundtracks from khinsider.com"""
@@ -18,6 +18,10 @@ class KhinsiderSoundtrackExtractor(AsynchronousExtractor):
directory_fmt = ["{category}", "{album}"]
filename_fmt = "{filename}"
pattern = [r"(?:https?://)?downloads\.khinsider\.com/game-soundtracks/album/(.+)"]
test = [("http://downloads.khinsider.com/game-soundtracks/album/horizon-riders-wii-", {
"url": "35ff4c8310884664408dc5560fda3b06157f7606",
"keyword": "dde50e1f5dbed5ee3f13df4e1bffc58bb9563f22",
})]
def __init__(self, match):
AsynchronousExtractor.__init__(self)
@@ -34,6 +38,7 @@ class KhinsiderSoundtrackExtractor(AsynchronousExtractor):
yield Message.Url, url, track
def get_job_metadata(self, page):
"""Collect metadata for extractor-job"""
return text.extract_all(page, (
("album", "Album name: <b>", "</b>"),
("count", "Number of Files: <b>", "</b>"),
@@ -43,7 +48,10 @@ class KhinsiderSoundtrackExtractor(AsynchronousExtractor):
), values={"category": self.category})[0]
def get_album_tracks(self, page):
pos = page.index("Download all songs at once:")
"""Collect url and metadata for all tracks of a soundtrack"""
pos = page.find("Download all songs at once:")
if pos == -1:
raise exception.NotFoundError("soundtrack")
num = 0
for url in text.extract_iter(page, '<tr>\r\n\t\t<td><a href="', '"', pos):
page = self.request(url, encoding="utf-8").text