Merge pull request #32 from amigatomte/patch-1

Update to reflect website changes.
This commit is contained in:
Tom-Oliver Heidel 2020-10-28 12:31:38 +01:00 committed by GitHub
commit 1808b9e28c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import unified_timestamp from ..utils import unified_timestamp
import re
class URPlayIE(InfoExtractor): class URPlayIE(InfoExtractor):
@ -13,10 +14,10 @@ class URPlayIE(InfoExtractor):
'info_dict': { 'info_dict': {
'id': '203704', 'id': '203704',
'ext': 'mp4', 'ext': 'mp4',
'title': 'UR Samtiden - Livet, universum och rymdens märkliga musik : Om vetenskap, kritiskt tänkande och motstånd', 'title': 'Om vetenskap, kritiskt tänkande och motstånd',
'description': 'md5:5344508a52aa78c1ced6c1b8b9e44e9a', 'description': 'md5:5344508a52aa78c1ced6c1b8b9e44e9a',
'timestamp': 1513512768, 'timestamp': 1513292400,
'upload_date': '20171217', 'upload_date': '20171214',
}, },
}, { }, {
'url': 'https://urskola.se/Produkter/190031-Tripp-Trapp-Trad-Sovkudde', 'url': 'https://urskola.se/Produkter/190031-Tripp-Trapp-Trad-Sovkudde',
@ -37,35 +38,41 @@ def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
urplayer_data = self._parse_json(self._search_regex( urplayer_data = re.sub(""", "\"", self._search_regex(
r'urPlayer\.init\(({.+?})\);', webpage, 'urplayer data'), video_id) r'components\/Player\/Player\" data-react-props=\"({.+?})\"',
webpage, 'urplayer data'))
urplayer_data = self._parse_json(urplayer_data, video_id)
for i in range(len(urplayer_data['accessibleEpisodes'])):
if urplayer_data.get('accessibleEpisodes', {})[i].get('id') == int(video_id):
urplayer_data = urplayer_data['accessibleEpisodes'][i]
break
host = self._download_json('http://streaming-loadbalancer.ur.se/loadbalancer.json', video_id)['redirect'] host = self._download_json('http://streaming-loadbalancer.ur.se/loadbalancer.json', video_id)['redirect']
formats = [] formats = []
for quality_attr, quality, preference in (('', 'sd', 0), ('_hd', 'hd', 1)): urplayer_streams = urplayer_data.get("streamingInfo")
file_http = urplayer_data.get('file_http' + quality_attr) or urplayer_data.get('file_http_sub' + quality_attr) for quality in ('sd'), ('hd'):
if file_http: location = (urplayer_streams.get("raw", {}).get(quality, {}).get("location")
or urplayer_streams.get("sweComplete", {}).get(quality, {}).get("location"))
if location:
formats.extend(self._extract_wowza_formats( formats.extend(self._extract_wowza_formats(
'http://%s/%splaylist.m3u8' % (host, file_http), video_id, skip_protocols=['rtmp', 'rtsp'])) 'http://%s/%s/playlist.m3u8' % (host, location), video_id,
skip_protocols=['f4m', 'rtmp', 'rtsp']))
self._sort_formats(formats) self._sort_formats(formats)
subtitles = {} subtitles = {}
for subtitle in urplayer_data.get('subtitles', []): subs = urplayer_streams.get("sweComplete", {}).get("tt", {}).get("location")
subtitle_url = subtitle.get('file') if subs:
kind = subtitle.get('kind') subtitles.setdefault('Svenska', []).append({
if not subtitle_url or (kind and kind != 'captions'): 'url': subs,
continue
subtitles.setdefault(subtitle.get('label', 'Svenska'), []).append({
'url': subtitle_url,
}) })
return { return {
'id': video_id, 'id': video_id,
'title': urplayer_data['title'], 'title': urplayer_data['title'],
'description': self._og_search_description(webpage), 'description': self._og_search_description(webpage),
'thumbnail': urplayer_data.get('image'), 'thumbnail': urplayer_data.get('image', {}).get('1280x720'),
'timestamp': unified_timestamp(self._html_search_meta(('uploadDate', 'schema:uploadDate'), webpage, 'timestamp')), 'timestamp': unified_timestamp(self._html_search_meta(('uploadDate', 'schema:uploadDate'),
'series': urplayer_data.get('series_title'), webpage, 'timestamp')),
'series': urplayer_data.get('seriesTitle'),
'subtitles': subtitles, 'subtitles': subtitles,
'formats': formats, 'formats': formats,
} }