mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-18 01:14:14 +09:00
Compare commits
4 Commits
8e01d80e2a
...
88d342f751
Author | SHA1 | Date | |
---|---|---|---|
![]() |
88d342f751 | ||
![]() |
673277e510 | ||
![]() |
91b1569f68 | ||
![]() |
1234033cf3 |
@ -1064,6 +1064,7 @@ from .rtl2 import (
|
||||
RTL2YouSeriesIE,
|
||||
)
|
||||
from .rtp import RTPIE
|
||||
from .rtrfm import RTRFMIE
|
||||
from .rts import RTSIE
|
||||
from .rtve import RTVEALaCartaIE, RTVELiveIE, RTVEInfantilIE, RTVELiveIE, RTVETelevisionIE
|
||||
from .rtvnh import RTVNHIE
|
||||
|
48
youtube_dl/extractor/rtrfm.py
Normal file
48
youtube_dl/extractor/rtrfm.py
Normal file
@ -0,0 +1,48 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .common import InfoExtractor
|
||||
|
||||
from ..compat import compat_urllib_parse_urlencode
|
||||
from ..compat import compat_urlparse
|
||||
|
||||
from ..utils import ExtractorError
|
||||
|
||||
import re
|
||||
|
||||
|
||||
class RTRFMIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?rtrfm.com.au/(?:shows/(?P<show1>[^/]+)|show-episode/(?P<show2>[^-]+)-(?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2})/?)'
|
||||
_SHOW_DATE_TITLE = r"window\.vm\.playShow\('([^']+)', *'([0-9]{4}-[0-9]{2}-[0-9]{2})', *'([^']+)'\)"
|
||||
_RESTREAMS_URL = 'https://restreams.rtrfm.com.au/rzz'
|
||||
_TESTS = [
|
||||
{
|
||||
'url': 'https://rtrfm.com.au/show-episode/breakfast-2020-06-01/',
|
||||
'md5': '594027f513ec36a24b15d65007a24dff',
|
||||
'info_dict': {
|
||||
'id': 'breakfast-2020-06-01',
|
||||
'ext': 'mp3',
|
||||
'title': 'Breakfast with Taylah 2020-06-01',
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
def _real_extract(self, url):
|
||||
show1, show2, date = self._VALID_URL_RE.match(url).groups()
|
||||
webpage = self._download_webpage(url, show1 or show2)
|
||||
match = re.compile(self._SHOW_DATE_TITLE).search(webpage)
|
||||
if not match:
|
||||
raise ExtractorError('Error getting the show, date & title', expected=True)
|
||||
show, date, title = match.groups()
|
||||
query = {'n': show, 'd': date}
|
||||
query = compat_urllib_parse_urlencode(query)
|
||||
url = compat_urlparse.urlparse(self._RESTREAMS_URL)
|
||||
url = compat_urlparse.urlunparse(url._replace(query=query))
|
||||
url = self._download_json(url, show, 'Downloading MP3 URL')['u']
|
||||
return {
|
||||
'id': '%s-%s' % (show, date),
|
||||
'title': '%s %s' % (title, date),
|
||||
'url': url,
|
||||
'ext': 'mp3',
|
||||
'release_date': 'date',
|
||||
'description': self._og_search_description(webpage),
|
||||
}
|
@ -27,6 +27,7 @@ from ..compat import (
|
||||
)
|
||||
from ..jsinterp import JSInterpreter
|
||||
from ..utils import (
|
||||
bug_reports_message,
|
||||
clean_html,
|
||||
dict_get,
|
||||
error_to_compat_str,
|
||||
@ -65,6 +66,7 @@ from ..utils import (
|
||||
url_or_none,
|
||||
urlencode_postdata,
|
||||
urljoin,
|
||||
variadic,
|
||||
)
|
||||
|
||||
|
||||
@ -460,6 +462,26 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
'uploader': uploader,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _extract_thumbnails(data, *path_list, **kw_final_key):
|
||||
"""
|
||||
Extract thumbnails from thumbnails dict
|
||||
@param path_list: path list to level that contains 'thumbnails' key
|
||||
"""
|
||||
final_key = kw_final_key.get('final_key', 'thumbnails')
|
||||
|
||||
return traverse_obj(data, ((
|
||||
tuple(variadic(path) + (final_key, Ellipsis)
|
||||
for path in path_list or [()])), {
|
||||
'url': ('url', T(url_or_none),
|
||||
# Sometimes youtube gives a wrong thumbnail URL. See:
|
||||
# https://github.com/yt-dlp/yt-dlp/issues/233
|
||||
# https://github.com/ytdl-org/youtube-dl/issues/28023
|
||||
T(lambda u: update_url(u, query=None) if u and 'maxresdefault' in u else u)),
|
||||
'height': ('height', T(int_or_none)),
|
||||
'width': ('width', T(int_or_none)),
|
||||
}, T(lambda t: t if t.get('url') else None)))
|
||||
|
||||
def _search_results(self, query, params):
|
||||
data = {
|
||||
'context': {
|
||||
@ -3183,8 +3205,12 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
expected_type=txt_or_none)
|
||||
|
||||
def _grid_entries(self, grid_renderer):
|
||||
for item in grid_renderer['items']:
|
||||
if not isinstance(item, dict):
|
||||
for item in traverse_obj(grid_renderer, ('items', Ellipsis, T(dict))):
|
||||
lockup_view_model = traverse_obj(item, ('lockupViewModel', T(dict)))
|
||||
if lockup_view_model:
|
||||
entry = self._extract_lockup_view_model(lockup_view_model)
|
||||
if entry:
|
||||
yield entry
|
||||
continue
|
||||
renderer = self._extract_grid_item_renderer(item)
|
||||
if not isinstance(renderer, dict):
|
||||
@ -3268,6 +3294,25 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
continue
|
||||
yield self._extract_video(renderer)
|
||||
|
||||
def _extract_lockup_view_model(self, view_model):
|
||||
content_id = view_model.get('contentId')
|
||||
if not content_id:
|
||||
return
|
||||
content_type = view_model.get('contentType')
|
||||
if content_type not in ('LOCKUP_CONTENT_TYPE_PLAYLIST', 'LOCKUP_CONTENT_TYPE_PODCAST'):
|
||||
self.report_warning(
|
||||
'Unsupported lockup view model content type "{0}"{1}'.format(content_type, bug_reports_message()), only_once=True)
|
||||
return
|
||||
return merge_dicts(self.url_result(
|
||||
update_url_query('https://www.youtube.com/playlist', {'list': content_id}),
|
||||
ie=YoutubeTabIE.ie_key(), video_id=content_id), {
|
||||
'title': traverse_obj(view_model, (
|
||||
'metadata', 'lockupMetadataViewModel', 'title', 'content', T(compat_str))),
|
||||
'thumbnails': self._extract_thumbnails(view_model, (
|
||||
'contentImage', 'collectionThumbnailViewModel', 'primaryThumbnail',
|
||||
'thumbnailViewModel', 'image'), final_key='sources'),
|
||||
})
|
||||
|
||||
def _video_entry(self, video_renderer):
|
||||
video_id = video_renderer.get('videoId')
|
||||
if video_id:
|
||||
|
Loading…
x
Reference in New Issue
Block a user