mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 15:24:36 +00:00
[nrk] Extract f4m formats and impose geo restriction only when not media URL (Closes #7715)
This commit is contained in:
parent
4c6b4764f0
commit
874ae0354e
1 changed files with 17 additions and 7 deletions
|
@ -6,6 +6,7 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_urlparse
|
from ..compat import compat_urlparse
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
@ -48,12 +49,22 @@ def _real_extract(self, url):
|
||||||
'http://v8.psapi.nrk.no/mediaelement/%s' % video_id,
|
'http://v8.psapi.nrk.no/mediaelement/%s' % video_id,
|
||||||
video_id, 'Downloading media JSON')
|
video_id, 'Downloading media JSON')
|
||||||
|
|
||||||
if data['usageRights']['isGeoBlocked']:
|
media_url = data.get('mediaUrl')
|
||||||
raise ExtractorError(
|
|
||||||
'NRK har ikke rettigheter til å vise dette programmet utenfor Norge',
|
|
||||||
expected=True)
|
|
||||||
|
|
||||||
video_url = data['mediaUrl'] + '?hdcore=3.5.0&plugin=aasp-3.5.0.151.81'
|
if not media_url:
|
||||||
|
if data['usageRights']['isGeoBlocked']:
|
||||||
|
raise ExtractorError(
|
||||||
|
'NRK har ikke rettigheter til å vise dette programmet utenfor Norge',
|
||||||
|
expected=True)
|
||||||
|
|
||||||
|
if determine_ext(media_url) == 'f4m':
|
||||||
|
formats = self._extract_f4m_formats(
|
||||||
|
media_url + '?hdcore=3.5.0&plugin=aasp-3.5.0.151.81', video_id, f4m_id='hds')
|
||||||
|
else:
|
||||||
|
formats = [{
|
||||||
|
'url': media_url,
|
||||||
|
'ext': 'flv',
|
||||||
|
}]
|
||||||
|
|
||||||
duration = parse_duration(data.get('duration'))
|
duration = parse_duration(data.get('duration'))
|
||||||
|
|
||||||
|
@ -67,12 +78,11 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
|
||||||
'ext': 'flv',
|
|
||||||
'title': data['title'],
|
'title': data['title'],
|
||||||
'description': data['description'],
|
'description': data['description'],
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue