X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/b7da73eb19e00e4eab43ec7de129e9aa12f6d5d3..61edf57f8f13f6dfd81154174e647eb5fdd26089:/yt_dlp/extractor/videomore.py diff --git a/yt_dlp/extractor/videomore.py b/yt_dlp/extractor/videomore.py index 05ae74e33..c41d3d984 100644 --- a/yt_dlp/extractor/videomore.py +++ b/yt_dlp/extractor/videomore.py @@ -1,16 +1,7 @@ -# coding: utf-8 -from __future__ import unicode_literals - -import re - from .common import InfoExtractor -from ..compat import ( - compat_parse_qs, - compat_str, - compat_urllib_parse_urlparse, -) from ..utils import ( int_or_none, + parse_qs, ) @@ -51,6 +42,12 @@ class VideomoreIE(InfoExtractor): (?P\d+) (?:[/?#&]|\.(?:xml|json)|$) ''' + _EMBED_REGEX = [r'''(?x) + (?: + ]+src=([\'"])| + ]+data=(["\'])https?://videomore\.ru/player\.swf\?.*config= + )(?Phttps?://videomore\.ru/[^?#"']+/\d+(?:\.xml)?) + '''] _TESTS = [{ 'url': 'http://videomore.ru/kino_v_detalayah/5_sezon/367617', 'md5': '44455a346edc0d509ac5b5a5b531dc35', @@ -130,23 +127,10 @@ class VideomoreIE(InfoExtractor): }] _GEO_BYPASS = False - @staticmethod - def _extract_url(webpage): - mobj = re.search( - r']+data=(["\'])https?://videomore\.ru/player\.swf\?.*config=(?Phttps?://videomore\.ru/(?:[^/]+/)+\d+\.xml).*\1', - webpage) - if not mobj: - mobj = re.search( - r']+src=([\'"])(?Phttps?://videomore\.ru/embed/\d+)', - webpage) - - if mobj: - return mobj.group('url') - def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) + mobj = self._match_valid_url(url) video_id = mobj.group('sid') or mobj.group('id') - partner_id = mobj.group('partner_id') or compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('partner_id', [None])[0] or '97' + partner_id = mobj.group('partner_id') or parse_qs(url).get('partner_id', [None])[0] or '97' item = self._download_json( 'https://siren.more.tv/player/config', video_id, query={ @@ -194,7 +178,6 @@ def _real_extract(self, url): if error in ('Данное видео недоступно для просмотра на территории этой страны', 'Данное видео доступно для просмотра только на территории России'): self.raise_geo_restricted(countries=['RU'], metadata_available=True) self.raise_no_formats(error, expected=True) - self._sort_formats(formats) return { 'id': video_id, @@ -267,7 +250,7 @@ class VideomoreVideoIE(VideomoreBaseIE): 'params': { 'skip_download': True, }, - 'skip': 'redirects to https://more.tv/' + 'skip': 'redirects to https://more.tv/', }, { 'url': 'https://videomore.ru/molodezhka/6_sezon/29_seriya?utm_so', 'only_matching': True, @@ -278,7 +261,7 @@ class VideomoreVideoIE(VideomoreBaseIE): @classmethod def suitable(cls, url): - return False if VideomoreIE.suitable(url) else super(VideomoreVideoIE, cls).suitable(url) + return False if VideomoreIE.suitable(url) else super().suitable(url) def _real_extract(self, url): display_id = self._match_id(url) @@ -306,14 +289,14 @@ class VideomoreSeasonIE(VideomoreBaseIE): @classmethod def suitable(cls, url): return (False if (VideomoreIE.suitable(url) or VideomoreVideoIE.suitable(url)) - else super(VideomoreSeasonIE, cls).suitable(url)) + else super().suitable(url)) def _real_extract(self, url): display_id = self._match_id(url) season = self._download_page_data(display_id) - season_id = compat_str(season['id']) + season_id = str(season['id']) tracks = self._download_json( - self._API_BASE_URL + 'seasons/%s/tracks' % season_id, + self._API_BASE_URL + f'seasons/{season_id}/tracks', season_id)['data'] entries = [] for track in tracks: