1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-17 14:54:31 +01:00

[svtplay] Share svtplay regex

This commit is contained in:
Sergey M․ 2018-04-05 00:28:36 +07:00
parent df146eb282
commit 1236ac6b0b
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -128,7 +128,11 @@ class SVTIE(SVTBaseIE):
return info_dict return info_dict
class SVTPlayIE(SVTBaseIE): class SVTPlayBaseIE(SVTBaseIE):
_SVTPLAY_RE = r'root\s*\[\s*(["\'])_*svtplay\1\s*\]\s*=\s*(?P<json>{.+?})\s*;\s*\n'
class SVTPlayIE(SVTPlayBaseIE):
IE_DESC = 'SVT Play and Öppet arkiv' IE_DESC = 'SVT Play and Öppet arkiv'
_VALID_URL = r'https?://(?:www\.)?(?:svtplay|oppetarkiv)\.se/(?:video|klipp)/(?P<id>[0-9]+)' _VALID_URL = r'https?://(?:www\.)?(?:svtplay|oppetarkiv)\.se/(?:video|klipp)/(?P<id>[0-9]+)'
_TESTS = [{ _TESTS = [{
@ -163,8 +167,8 @@ class SVTPlayIE(SVTBaseIE):
data = self._parse_json( data = self._parse_json(
self._search_regex( self._search_regex(
r'root\["__svtplay"\]\s*=\s*([^;]+);', self._SVTPLAY_RE, webpage, 'embedded data', default='{}',
webpage, 'embedded data', default='{}'), group='json'),
video_id, fatal=False) video_id, fatal=False)
thumbnail = self._og_search_thumbnail(webpage) thumbnail = self._og_search_thumbnail(webpage)
@ -197,7 +201,7 @@ class SVTPlayIE(SVTBaseIE):
return info_dict return info_dict
class SVTSeriesIE(InfoExtractor): class SVTSeriesIE(SVTPlayBaseIE):
_VALID_URL = r'https?://(?:www\.)?svtplay\.se/(?P<id>[^/?&#]+)' _VALID_URL = r'https?://(?:www\.)?svtplay\.se/(?P<id>[^/?&#]+)'
_TESTS = [{ _TESTS = [{
'url': 'https://www.svtplay.se/rederiet', 'url': 'https://www.svtplay.se/rederiet',
@ -235,8 +239,7 @@ class SVTSeriesIE(InfoExtractor):
root = self._parse_json( root = self._parse_json(
self._search_regex( self._search_regex(
r'root\[\s*(["\'])_*svtplay\1\s*\]\s*=\s*(?P<json>{.+?})\s*;\s*\n', self._SVTPLAY_RE, webpage, 'content', group='json'),
webpage, 'content', group='json'),
series_id) series_id)
season_name = None season_name = None