[svtplay:series] Improve extraction (closes #16059)
This commit is contained in:
parent
fd97fa7bfc
commit
b71bb3ba8b
2 changed files with 18 additions and 20 deletions
|
@ -1031,7 +1031,7 @@ from .sunporno import SunPornoIE
|
||||||
from .svt import (
|
from .svt import (
|
||||||
SVTIE,
|
SVTIE,
|
||||||
SVTPlayIE,
|
SVTPlayIE,
|
||||||
SVTPlaylistIE,
|
SVTSeriesIE,
|
||||||
)
|
)
|
||||||
from .swrmediathek import SWRMediathekIE
|
from .swrmediathek import SWRMediathekIE
|
||||||
from .syfy import SyfyIE
|
from .syfy import SyfyIE
|
||||||
|
|
|
@ -193,10 +193,8 @@ class SVTPlayIE(SVTBaseIE):
|
||||||
return info_dict
|
return info_dict
|
||||||
|
|
||||||
|
|
||||||
class SVTPlaylistIE(InfoExtractor):
|
class SVTSeriesIE(InfoExtractor):
|
||||||
IE_DESC = 'SVT Play serie'
|
|
||||||
_VALID_URL = r'https?://(?:www\.)?svtplay\.se/(?P<id>[^/?&#]+)'
|
_VALID_URL = r'https?://(?:www\.)?svtplay\.se/(?P<id>[^/?&#]+)'
|
||||||
IE_NAME = 'svtplay:serie'
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.svtplay.se/rederiet',
|
'url': 'https://www.svtplay.se/rederiet',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -209,33 +207,28 @@ class SVTPlaylistIE(InfoExtractor):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def suitable(cls, url):
|
def suitable(cls, url):
|
||||||
return False if SVTIE.suitable(url) or SVTPlayIE.suitable(url) else super(SVTPlaylistIE, cls).suitable(url)
|
return False if SVTIE.suitable(url) or SVTPlayIE.suitable(url) else super(SVTSeriesIE, cls).suitable(url)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
page = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
url, video_id,
|
url, video_id, 'Downloading serie page')
|
||||||
note='Downloading serie page',
|
|
||||||
errnote='unable to fetch serie page')
|
|
||||||
|
|
||||||
root_json = self._search_regex(
|
root = self._parse_json(
|
||||||
r'root\[\'__svtplay\'\]\s*=(.+);\n',
|
self._search_regex(
|
||||||
page, 'root')
|
r'root\[\s*(["\'])_*svtplay\1\s*\]\s*=\s*(?P<json>{.+?})\s*;\s*\n',
|
||||||
root = self._parse_json(root_json, video_id)
|
webpage, 'content', group='json'),
|
||||||
|
video_id)
|
||||||
metadata = root.get('metaData', {})
|
|
||||||
related_videos_accordion = root['relatedVideoContent']['relatedVideosAccordion']
|
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for season in related_videos_accordion:
|
for season in root['relatedVideoContent']['relatedVideosAccordion']:
|
||||||
videos = season.get('videos')
|
videos = season.get('videos')
|
||||||
if not isinstance(videos, list):
|
if not isinstance(videos, list):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for video in videos:
|
for video in videos:
|
||||||
content_url = video.get('contentUrl')
|
content_url = video.get('contentUrl')
|
||||||
if not isinstance(content_url, compat_str):
|
if not content_url or not isinstance(content_url, compat_str):
|
||||||
continue
|
continue
|
||||||
entries.append(
|
entries.append(
|
||||||
self.url_result(
|
self.url_result(
|
||||||
|
@ -244,5 +237,10 @@ class SVTPlaylistIE(InfoExtractor):
|
||||||
video_title=video.get('title')
|
video_title=video.get('title')
|
||||||
))
|
))
|
||||||
|
|
||||||
|
metadata = root.get('metaData')
|
||||||
|
if not isinstance(metadata, dict):
|
||||||
|
metadata = {}
|
||||||
|
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
entries, video_id, metadata.get('title'), metadata.get('description'))
|
entries, video_id, metadata.get('title'),
|
||||||
|
metadata.get('description'))
|
||||||
|
|
Loading…
Reference in a new issue