Compare commits

..

4 Commits

Author SHA1 Message Date
Bart Broere
e50adf24c9
Merge 6de650f51f into c5098961b0 2024-09-21 22:14:55 +02:00
Bart Broere
6de650f51f Use traverse_obj in another place as well 2024-09-21 20:08:53 +00:00
Bart Broere
bf91db4846 Use suggested util 2024-09-21 20:04:50 +00:00
Bart Broere
ad6ee6fdd2
Commit two suggestions from the PR
Co-authored-by: dirkf <fieldhouse@gmx.net>
2024-09-21 21:58:53 +02:00

View File

@ -5,7 +5,7 @@ import json
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ExtractorError from ..utils import ExtractorError, join_nonempty, traverse_obj
class NPOIE(InfoExtractor): class NPOIE(InfoExtractor):
@ -95,7 +95,7 @@ class NPOIE(InfoExtractor):
}, },
fatal=False, fatal=False,
) )
stream_url = stream_link.get('stream', {}).get('streamURL') stream_url = traverse_obj(stream_link, ('stream', 'streamURL'))
formats.extend(self._extract_mpd_formats(stream_url, slug, mpd_id='dash', fatal=False)) formats.extend(self._extract_mpd_formats(stream_url, slug, mpd_id='dash', fatal=False))
return formats return formats
@ -140,9 +140,9 @@ class BNNVaraIE(NPOIE):
return { return {
'id': product_id, 'id': product_id,
'title': media.get('data', {}).get('player', {}).get('title'), 'title': traverse_obj(media, ('data', 'player', 'title')),
'formats': formats, 'formats': formats,
'thumbnail': media.get('data', {}).get('player', {}).get('image').get('url'), 'thumbnail': traverse_obj(media, ('data', 'player', 'image', 'url')),
} }
@ -160,7 +160,7 @@ class ONIE(NPOIE):
def _real_extract(self, url): def _real_extract(self, url):
video_id = url.rstrip('/').split('/')[-1] video_id = url.rstrip('/').split('/')[-1]
page, _ = self._download_webpage_handle(url, video_id) page = self._download_webpage(url, video_id)
results = re.findall("page: '(.+)'", page) results = re.findall("page: '(.+)'", page)
formats = [] formats = []
for result in results: for result in results:
@ -241,7 +241,7 @@ class SchoolTVIE(NPOIE):
return { return {
'id': video_id, 'id': video_id,
'title': metadata.get('title', '') + ' - ' + metadata.get('subtitle', ''), 'title': join_nonempty('title', 'subtitle', from_dict=metadata),
'description': metadata.get('description') or metadata.get('short_description'), 'description': metadata.get('description') or metadata.get('short_description'),
'formats': formats, 'formats': formats,
} }