From 7fc3a7d09f288e2565f1a1afe84e67093a71ee3e Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sat, 25 Mar 2017 12:54:22 -0400 Subject: [PATCH] [cbs:playlist] if instead of try per @dstftw --- youtube_dl/extractor/cbs.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/youtube_dl/extractor/cbs.py b/youtube_dl/extractor/cbs.py index 3e6573ff5..e0b94f731 100644 --- a/youtube_dl/extractor/cbs.py +++ b/youtube_dl/extractor/cbs.py @@ -6,7 +6,6 @@ from ..utils import ( int_or_none, js_to_json, find_xpath_attr, - RegexNotFoundError, xpath_element, xpath_text, update_url_query, @@ -44,7 +43,7 @@ class CBSShowIE(InfoExtractor): 'id': 22927, 'title': 'Star Trek - The Original Series', }, - 'playlist_count': 15, # No clips, only episodes + 'playlist_count': 15, # No clips, only episodes 'only_matching': True, }, ] @@ -90,12 +89,11 @@ class CBSShowIE(InfoExtractor): # saveState : false # }); # } - try: - clipdata = self._parse_json( - self._search_regex(r'element\.videoCarousel\(([^)]*)\);', - webpage, 'carousel'), - show_name, transform_source=js_to_json) - + clipdata = self._parse_json( + self._search_regex(r'element\.videoCarousel\(([^)]*)\);', + webpage, 'carousel', default='{}'), + show_name, transform_source=js_to_json) + if (clipdata.get('id')): # http://www.cbs.com/carousels/videosBySection/241426/offset/0/limit/15/xs/0/ # => {id: 241426, title: "Clips", clips_url = \ @@ -103,7 +101,7 @@ class CBSShowIE(InfoExtractor): '/carousels/videosBySection/%d/offset/0/limit/15/xs/0' % clipdata['id']) clips = self.carousel_playlist(clips_url, 'clips') - except RegexNotFoundError: + else: clips = {'entries': []} playlist = self.carousel_playlist(episodes_url, 'episodes')