1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-02 09:12:40 +01:00

[CuriosityStream] Fix series

Bug indroduced in ed807c1837
This commit is contained in:
pukkandan 2021-11-13 15:07:48 +05:30
parent df03de2c02
commit 92775d8a40
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
2 changed files with 35 additions and 24 deletions

View File

@ -44,7 +44,7 @@ def _real_initialize(self):
'password': password, 'password': password,
})) }))
self._handle_errors(result) self._handle_errors(result)
self._auth_token = result['message']['auth_token'] CuriosityStreamBaseIE._auth_token = result['message']['auth_token']
class CuriosityStreamIE(CuriosityStreamBaseIE): class CuriosityStreamIE(CuriosityStreamBaseIE):
@ -142,9 +142,26 @@ def _real_extract(self, url):
} }
class CuriosityStreamCollectionIE(CuriosityStreamBaseIE): class CuriosityStreamCollectionBaseIE(CuriosityStreamBaseIE):
IE_NAME = 'curiositystream:collection'
_VALID_URL = r'https?://(?:app\.)?curiositystream\.com/(?:collections?|series)/(?P<id>\d+)' def _real_extract(self, url):
collection_id = self._match_id(url)
collection = self._call_api(collection_id, collection_id)
entries = []
for media in collection.get('media', []):
media_id = compat_str(media.get('id'))
media_type, ie = ('series', CuriosityStreamSeriesIE) if media.get('is_collection') else ('video', CuriosityStreamIE)
entries.append(self.url_result(
'https://curiositystream.com/%s/%s' % (media_type, media_id),
ie=ie.ie_key(), video_id=media_id))
return self.playlist_result(
entries, collection_id,
collection.get('title'), collection.get('description'))
class CuriosityStreamCollectionsIE(CuriosityStreamCollectionBaseIE):
IE_NAME = 'curiositystream:collections'
_VALID_URL = r'https?://(?:app\.)?curiositystream\.com/collections/(?P<id>\d+)'
_API_BASE_URL = 'https://api.curiositystream.com/v2/collections/' _API_BASE_URL = 'https://api.curiositystream.com/v2/collections/'
_TESTS = [{ _TESTS = [{
'url': 'https://curiositystream.com/collections/86', 'url': 'https://curiositystream.com/collections/86',
@ -155,7 +172,17 @@ class CuriosityStreamCollectionIE(CuriosityStreamBaseIE):
}, },
'playlist_mincount': 7, 'playlist_mincount': 7,
}, { }, {
'url': 'https://app.curiositystream.com/collection/2', 'url': 'https://curiositystream.com/collections/36',
'only_matching': True,
}]
class CuriosityStreamSeriesIE(CuriosityStreamCollectionBaseIE):
IE_NAME = 'curiositystream:series'
_VALID_URL = r'https?://(?:app\.)?curiositystream\.com/(?:series|collection)/(?P<id>\d+)'
_API_BASE_URL = 'https://api.curiositystream.com/v2/series/'
_TESTS = [{
'url': 'https://curiositystream.com/series/2',
'info_dict': { 'info_dict': {
'id': '2', 'id': '2',
'title': 'Curious Minds: The Internet', 'title': 'Curious Minds: The Internet',
@ -163,23 +190,6 @@ class CuriosityStreamCollectionIE(CuriosityStreamBaseIE):
}, },
'playlist_mincount': 16, 'playlist_mincount': 16,
}, { }, {
'url': 'https://curiositystream.com/series/2', 'url': 'https://curiositystream.com/collection/2',
'only_matching': True,
}, {
'url': 'https://curiositystream.com/collections/36',
'only_matching': True, 'only_matching': True,
}] }]
def _real_extract(self, url):
collection_id = self._match_id(url)
collection = self._call_api(collection_id, collection_id)
entries = []
for media in collection.get('media', []):
media_id = compat_str(media.get('id'))
media_type, ie = ('series', CuriosityStreamCollectionIE) if media.get('is_collection') else ('video', CuriosityStreamIE)
entries.append(self.url_result(
'https://curiositystream.com/%s/%s' % (media_type, media_id),
ie=ie.ie_key(), video_id=media_id))
return self.playlist_result(
entries, collection_id,
collection.get('title'), collection.get('description'))

View File

@ -307,7 +307,8 @@
from .cultureunplugged import CultureUnpluggedIE from .cultureunplugged import CultureUnpluggedIE
from .curiositystream import ( from .curiositystream import (
CuriosityStreamIE, CuriosityStreamIE,
CuriosityStreamCollectionIE, CuriosityStreamCollectionsIE,
CuriosityStreamSeriesIE,
) )
from .cwtv import CWTVIE from .cwtv import CWTVIE
from .dailymail import DailyMailIE from .dailymail import DailyMailIE