mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-16 06:15:46 +00:00
[duboku] add tests
This commit is contained in:
parent
de4144a4ae
commit
d82b6697c2
1 changed files with 31 additions and 3 deletions
|
@ -136,6 +136,26 @@ class DubokuPlaylistIE(InfoExtractor):
|
|||
IE_DESC = 'www.duboku.co entire series'
|
||||
|
||||
_VALID_URL = r'(?:https?://[^/]+\.duboku\.co/voddetail/)(?P<id>[0-9]+)\.html.*'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.duboku.co/vodplay/1575.html',
|
||||
'info_dict': {
|
||||
'id': '1575#playlist1',
|
||||
'title': '白色月光',
|
||||
},
|
||||
'playlist_count': 12,
|
||||
}, {
|
||||
'url': 'https://www.duboku.co/vodplay/1554.html',
|
||||
'info_dict': {
|
||||
'id': '1554#playlist1',
|
||||
'title': '以家人之名',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://www.duboku.co/vodplay/1554.html#playlist2',
|
||||
'info_dict': {
|
||||
'id': '1554#playlist2',
|
||||
'title': '以家人之名',
|
||||
},
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
mobj = re.match(self._VALID_URL, url)
|
||||
|
@ -173,7 +193,15 @@ class DubokuPlaylistIE(InfoExtractor):
|
|||
playlists[playlist_id] = playlist
|
||||
|
||||
# select the specified playlist if url fragment exists
|
||||
playlist = playlists.get(fragment) if fragment else next(iter(playlists.values()))
|
||||
playlist = None
|
||||
playlist_id = None
|
||||
if fragment:
|
||||
playlist = playlists.get(fragment)
|
||||
playlist_id = fragment
|
||||
else:
|
||||
first = next(iter(playlists.items()))
|
||||
if first:
|
||||
(playlist_id, playlist) = first
|
||||
if not playlist:
|
||||
raise ExtractorError(
|
||||
'Cannot find %s' % fragment if fragment else 'Cannot extract playlist')
|
||||
|
@ -181,5 +209,5 @@ class DubokuPlaylistIE(InfoExtractor):
|
|||
# return url results
|
||||
return self.playlist_result([
|
||||
self.url_result(
|
||||
'https://www.duboku.co' + x['href'], video_title=x.get('title'))
|
||||
for x in playlist], series_id, title)
|
||||
'https://www.duboku.co' + x['href'], DubokuIE.IE_NAME, video_title=x.get('title'))
|
||||
for x in playlist], series_id + '#' + playlist_id, title)
|
||||
|
|
Loading…
Reference in a new issue