[cbs:playlist] if instead of try per @dstftw

This commit is contained in:
John Hawkinson 2017-03-25 12:54:22 -04:00
parent 53b53c6638
commit 7fc3a7d09f

View File

@ -6,7 +6,6 @@ from ..utils import (
int_or_none, int_or_none,
js_to_json, js_to_json,
find_xpath_attr, find_xpath_attr,
RegexNotFoundError,
xpath_element, xpath_element,
xpath_text, xpath_text,
update_url_query, update_url_query,
@ -44,7 +43,7 @@ class CBSShowIE(InfoExtractor):
'id': 22927, 'id': 22927,
'title': 'Star Trek - The Original Series', 'title': 'Star Trek - The Original Series',
}, },
'playlist_count': 15, # No clips, only episodes 'playlist_count': 15, # No clips, only episodes
'only_matching': True, 'only_matching': True,
}, },
] ]
@ -90,12 +89,11 @@ class CBSShowIE(InfoExtractor):
# saveState : false # saveState : false
# }); # });
# } # }
try: clipdata = self._parse_json(
clipdata = self._parse_json( self._search_regex(r'element\.videoCarousel\(([^)]*)\);',
self._search_regex(r'element\.videoCarousel\(([^)]*)\);', webpage, 'carousel', default='{}'),
webpage, 'carousel'), show_name, transform_source=js_to_json)
show_name, transform_source=js_to_json) if (clipdata.get('id')):
# http://www.cbs.com/carousels/videosBySection/241426/offset/0/limit/15/xs/0/ # http://www.cbs.com/carousels/videosBySection/241426/offset/0/limit/15/xs/0/
# => {id: 241426, title: "Clips", # => {id: 241426, title: "Clips",
clips_url = \ clips_url = \
@ -103,7 +101,7 @@ class CBSShowIE(InfoExtractor):
'/carousels/videosBySection/%d/offset/0/limit/15/xs/0' '/carousels/videosBySection/%d/offset/0/limit/15/xs/0'
% clipdata['id']) % clipdata['id'])
clips = self.carousel_playlist(clips_url, 'clips') clips = self.carousel_playlist(clips_url, 'clips')
except RegexNotFoundError: else:
clips = {'entries': []} clips = {'entries': []}
playlist = self.carousel_playlist(episodes_url, 'episodes') playlist = self.carousel_playlist(episodes_url, 'episodes')