diff options
Diffstat (limited to 'yt_dlp/extractor/viewlift.py')
-rw-r--r-- | yt_dlp/extractor/viewlift.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/yt_dlp/extractor/viewlift.py b/yt_dlp/extractor/viewlift.py index c5d65cd..4a7ba98 100644 --- a/yt_dlp/extractor/viewlift.py +++ b/yt_dlp/extractor/viewlift.py @@ -5,6 +5,7 @@ from ..networking.exceptions import HTTPError from ..utils import ( ExtractorError, int_or_none, + join_nonempty, parse_age_limit, traverse_obj, ) @@ -62,8 +63,8 @@ class ViewLiftBaseIE(InfoExtractor): class ViewLiftEmbedIE(ViewLiftBaseIE): IE_NAME = 'viewlift:embed' - _VALID_URL = r'https?://(?:(?:www|embed)\.)?(?P<domain>%s)/embed/player\?.*\bfilmId=(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})' % ViewLiftBaseIE._DOMAINS_REGEX - _EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:embed\.)?(?:%s)/embed/player.+?)\1' % ViewLiftBaseIE._DOMAINS_REGEX] + _VALID_URL = rf'https?://(?:(?:www|embed)\.)?(?P<domain>{ViewLiftBaseIE._DOMAINS_REGEX})/embed/player\?.*\bfilmId=(?P<id>[\da-f]{{8}}-(?:[\da-f]{{4}}-){{3}}[\da-f]{{12}})' + _EMBED_REGEX = [rf'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:embed\.)?(?:{ViewLiftBaseIE._DOMAINS_REGEX})/embed/player.+?)\1'] _TESTS = [{ 'url': 'http://embed.snagfilms.com/embed/player?filmId=74849a00-85a9-11e1-9660-123139220831&w=500', 'md5': '2924e9215c6eff7a55ed35b72276bd93', @@ -74,7 +75,7 @@ class ViewLiftEmbedIE(ViewLiftBaseIE): 'description': 'md5:b542bef32a6f657dadd0df06e26fb0c8', 'timestamp': 1334350096, 'upload_date': '20120413', - } + }, }, { # invalid labels, 360p is better that 480p 'url': 'http://www.snagfilms.com/embed/player?filmId=17ca0950-a74a-11e0-a92a-0026bb61d036', @@ -98,7 +99,7 @@ class ViewLiftEmbedIE(ViewLiftBaseIE): content_data = self._call_api( site, 'entitlement/video/status', film_id, url, { - 'id': film_id + 'id': film_id, })['video'] gist = content_data['gist'] title = gist['title'] @@ -120,7 +121,7 @@ class ViewLiftEmbedIE(ViewLiftBaseIE): 'height', default=None)) formats.append({ 'url': video_asset_url, - 'format_id': 'http%s' % ('-%d' % bitrate if bitrate else ''), + 'format_id': join_nonempty('http', bitrate), 'tbr': bitrate, 'height': height, 'vcodec': video_asset.get('codec'), @@ -153,7 +154,7 @@ class ViewLiftEmbedIE(ViewLiftBaseIE): class ViewLiftIE(ViewLiftBaseIE): IE_NAME = 'viewlift' _API_BASE = 'https://prod-api-cached-2.viewlift.com/' - _VALID_URL = r'https?://(?:www\.)?(?P<domain>%s)(?P<path>(?:/(?:films/title|show|(?:news/)?videos?|watch))?/(?P<id>[^?#]+))' % ViewLiftBaseIE._DOMAINS_REGEX + _VALID_URL = rf'https?://(?:www\.)?(?P<domain>{ViewLiftBaseIE._DOMAINS_REGEX})(?P<path>(?:/(?:films/title|show|(?:news/)?videos?|watch))?/(?P<id>[^?#]+))' _TESTS = [{ 'url': 'http://www.snagfilms.com/films/title/lost_for_life', 'md5': '19844f897b35af219773fd63bdec2942', @@ -169,7 +170,7 @@ class ViewLiftIE(ViewLiftBaseIE): 'age_limit': 14, 'upload_date': '20150421', 'timestamp': 1429656820, - } + }, }, { 'url': 'http://www.snagfilms.com/show/the_world_cut_project/india', 'md5': 'e6292e5b837642bbda82d7f8bf3fbdfd', @@ -183,7 +184,7 @@ class ViewLiftIE(ViewLiftBaseIE): 'duration': 979, 'timestamp': 1399478279, 'upload_date': '20140507', - } + }, }, { 'url': 'http://main.snagfilms.com/augie_alone/s_2_ep_12_love', 'info_dict': { @@ -253,7 +254,7 @@ class ViewLiftIE(ViewLiftBaseIE): 'description': 'md5:ca30a682b4528d02a3eb6d0427dd0f87', 'thumbnail': r're:^https?://.*\.jpg$', 'upload_date': '20210830', - 'series': 'Case Jaundice' + 'series': 'Case Jaundice', }, 'params': {'skip_download': True}, }, { # Free video @@ -265,7 +266,7 @@ class ViewLiftIE(ViewLiftBaseIE): 'description': 'md5:9d21edc1827d32f8633eb67c2054fc31', 'thumbnail': r're:^https?://.*\.jpg$', 'upload_date': '20211006', - 'series': 'Six (Hindi)' + 'series': 'Six (Hindi)', }, 'params': {'skip_download': True}, }, { # Free episode @@ -277,7 +278,7 @@ class ViewLiftIE(ViewLiftBaseIE): 'description': 'md5:ef6ffae01a3d83438597367400f824ed', 'thumbnail': r're:^https?://.*\.jpg$', 'upload_date': '20211004', - 'series': 'Asian Paints Moner Thikana' + 'series': 'Asian Paints Moner Thikana', }, 'params': {'skip_download': True}, }, { # Free series @@ -294,7 +295,7 @@ class ViewLiftIE(ViewLiftBaseIE): }, }, { # Premium movie 'url': 'https://www.hoichoi.tv/movies/detective-2020', - 'only_matching': True + 'only_matching': True, }, { # Chorki Premium series 'url': 'https://www.chorki.com/bn/series/sinpaat', 'playlist_mincount': 7, @@ -326,7 +327,7 @@ class ViewLiftIE(ViewLiftBaseIE): @classmethod def suitable(cls, url): - return False if ViewLiftEmbedIE.suitable(url) else super(ViewLiftIE, cls).suitable(url) + return False if ViewLiftEmbedIE.suitable(url) else super().suitable(url) def _show_entries(self, domain, seasons): for season in seasons: @@ -355,7 +356,7 @@ class ViewLiftIE(ViewLiftBaseIE): film_id = next(m['contentData'][0]['gist']['id'] for m in modules if m.get('moduleType') == 'VideoDetailModule') return { '_type': 'url_transparent', - 'url': 'http://%s/embed/player?filmId=%s' % (domain, film_id), + 'url': f'http://{domain}/embed/player?filmId={film_id}', 'id': film_id, 'display_id': display_id, 'ie_key': 'ViewLiftEmbed', |