mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-29 05:32:00 +00:00
[ciscolive] fix search
This commit is contained in:
parent
0af2f585e7
commit
dd2ee5e071
1 changed files with 21 additions and 31 deletions
|
@ -116,11 +116,11 @@ class CiscoLiveSessionIE(CiscoLiveBaseIE):
|
||||||
class CiscoLiveSearchIE(CiscoLiveBaseIE):
|
class CiscoLiveSearchIE(CiscoLiveBaseIE):
|
||||||
_VALID_URL = r'https?://(?:www\.)?ciscolive(?:\.cisco)?\.com/(?:global/|on-demand/)?on-demand-library(?:\.html|/)'
|
_VALID_URL = r'https?://(?:www\.)?ciscolive(?:\.cisco)?\.com/(?:global/|on-demand/)?on-demand-library(?:\.html|/)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.ciscolive.com/on-demand/on-demand-library.html?search.event=1636046385176005FbBU&search.technology=scpsTechnology_dataCenter&search.technicallevel=scpsSkillLevel_aintroductory#/',
|
'url': 'https://www.ciscolive.com/on-demand/on-demand-library.html?search.technology=1614262524988009b6j9&search.technicallevel=scpsSkillLevel_bintermediate#/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'title': 'Search query',
|
'title': 'Search query',
|
||||||
},
|
},
|
||||||
'playlist_count': 3, # example returns 4 results, only 3 have video
|
'playlist_count': 6,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.ciscolive.com/on-demand/on-demand-library.html?search.technology=scpsTechnology_automation&search.technicallevel=scpsSkillLevel_cadvanced#/',
|
'url': 'https://www.ciscolive.com/on-demand/on-demand-library.html?search.technology=scpsTechnology_automation&search.technicallevel=scpsSkillLevel_cadvanced#/',
|
||||||
}, {
|
}, {
|
||||||
|
@ -137,20 +137,17 @@ class CiscoLiveSearchIE(CiscoLiveBaseIE):
|
||||||
return int_or_none(try_get(rf_item, lambda x: x['videos'][0]['url'])) is not None
|
return int_or_none(try_get(rf_item, lambda x: x['videos'][0]['url'])) is not None
|
||||||
|
|
||||||
def _entries(self, query, url):
|
def _entries(self, query, url):
|
||||||
query['size'] = 50
|
|
||||||
query['from'] = 0
|
|
||||||
for page_num in itertools.count(1):
|
|
||||||
results = self._call_api(
|
results = self._call_api(
|
||||||
'search', None, query, url,
|
'search', None, query, url,
|
||||||
'Downloading search JSON page %d' % page_num)
|
'Downloading search JSON')
|
||||||
if int(results['totalSearchItems']) == 0:
|
if int(results['totalSearchItems']) == 0:
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Search api returned no items (if matches are expected rfApiProfileId may be invalid)',
|
'Search api returned no items (if matches are expected rfApiProfileId may be invalid)',
|
||||||
expected=True)
|
expected=True)
|
||||||
sl = try_get(results, lambda x: x['sectionList'][0], dict)
|
sl = try_get(results, lambda x: x['sectionList'], list)
|
||||||
if sl:
|
if sl is not None:
|
||||||
results = sl
|
for s in sl:
|
||||||
items = results.get('items')
|
items = s.get('items')
|
||||||
if not items or not isinstance(items, list):
|
if not items or not isinstance(items, list):
|
||||||
break
|
break
|
||||||
for item in items:
|
for item in items:
|
||||||
|
@ -159,13 +156,6 @@ class CiscoLiveSearchIE(CiscoLiveBaseIE):
|
||||||
if not self._check_bc_id_exists(item):
|
if not self._check_bc_id_exists(item):
|
||||||
continue
|
continue
|
||||||
yield self._parse_rf_item(item)
|
yield self._parse_rf_item(item)
|
||||||
size = int_or_none(results.get('size'))
|
|
||||||
if size is not None:
|
|
||||||
query['size'] = size
|
|
||||||
total = int_or_none(results.get('total'))
|
|
||||||
if total is not None and query['from'] + query['size'] > total:
|
|
||||||
break
|
|
||||||
query['from'] += query['size']
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
query = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
|
query = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
|
||||||
|
|
Loading…
Reference in a new issue