1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-11 09:27:55 +01:00

Fix raiplayradio.it code based on coding conventions

This commit is contained in:
Francesco Frassinelli 2019-09-21 15:06:29 +02:00
parent 3d10b1b8a6
commit 5a3905826a

View File

@ -533,32 +533,35 @@ class RaiPlayRadioBaseIE(InfoExtractor):
for attrs in self.parse_list(webpage): for attrs in self.parse_list(webpage):
title = attrs['data-title'].strip() title = attrs['data-title'].strip()
webpage = urljoin(url, attrs['data-mediapolis']) webpage = urljoin(url, attrs['data-mediapolis'])
audio_url = compat_str(self._request_webpage(webpage, title).geturl()) audio_url = compat_str(self._request_webpage(
webpage, title).geturl())
yield { yield {
'url': audio_url, 'url': audio_url,
'id': attrs['data-uniquename'].lstrip('ContentItem-'), 'id': attrs['data-uniquename'].lstrip('ContentItem-'),
'title': title, 'title': title,
'ext': determine_ext(audio_url), 'ext': determine_ext(audio_url),
'thumbnail': urljoin(url, attrs['data-image']), 'thumbnail': urljoin(url, attrs['data-image']),
'language': 'it', 'language': 'it'}
}
def get_playlist(self, *args, **kwargs): def get_playlist(self, *args, **kwargs):
return list(self.get_playlist_iter(*args, **kwargs)) return list(self.get_playlist_iter(*args, **kwargs))
class RaiPlayRadioIE(RaiPlayRadioBaseIE): class RaiPlayRadioIE(RaiPlayRadioBaseIE):
_VALID_URL = r'%s/audio/.+?-(?P<id>%s)\.html' % (RaiPlayRadioBaseIE._BASE, RaiBaseIE._UUID_RE) _VALID_URL = r'%s/audio/.+?-(?P<id>%s)\.html' % (
RaiPlayRadioBaseIE._BASE, RaiBaseIE._UUID_RE)
_TEST = { _TEST = {
'url': 'https://www.raiplayradio.it/audio/2019/07/RADIO3---LEZIONI-DI-MUSICA-36b099ff-4123-4443-9bf9-38e43ef5e025.html', 'url': 'https://www.raiplayradio.it/audio/2019/07/'
'RADIO3---LEZIONI-DI-MUSICA-'
'36b099ff-4123-4443-9bf9-38e43ef5e025.html',
'info_dict': { 'info_dict': {
'id': '36b099ff-4123-4443-9bf9-38e43ef5e025', 'id': '36b099ff-4123-4443-9bf9-38e43ef5e025',
'ext': 'mp3', 'ext': 'mp3',
'title': 'Dal "Chiaro di luna" al "Clair de lune", prima parte con Giovanni Bietti', 'title': 'Dal "Chiaro di luna" al "Clair de lune", '
'thumbnail': 'https://www.raiplayradio.it/cropgd/400x400/dl/img/2019/07/08/1562590329054_luna.jpg', 'prima parte con Giovanni Bietti',
'language': 'it', 'thumbnail': 'https://www.raiplayradio.it/cropgd/400x400/dl/'
} 'img/2019/07/08/1562590329054_luna.jpg',
} 'language': 'it'}}
def _real_extract(self, url): def _real_extract(self, url):
list_url = url.replace('.html', '-list.html') list_url = url.replace('.html', '-list.html')
@ -568,25 +571,30 @@ class RaiPlayRadioIE(RaiPlayRadioBaseIE):
class RaiPlayRadioPlaylistIE(RaiPlayRadioBaseIE): class RaiPlayRadioPlaylistIE(RaiPlayRadioBaseIE):
_VALID_URL = r'%s/playlist/.+?-(?P<id>%s)\.html' % (RaiPlayRadioBaseIE._BASE, RaiBaseIE._UUID_RE) _VALID_URL = r'%s/playlist/.+?-(?P<id>%s)\.html' % (
RaiPlayRadioBaseIE._BASE, RaiBaseIE._UUID_RE)
_TEST = { _TEST = {
'url': 'https://www.raiplayradio.it/playlist/2017/12/Alice-nel-paese-delle-meraviglie-72371d3c-d998-49f3-8860-d168cfdf4966.html', 'url': 'https://www.raiplayradio.it/playlist/2017/12/'
'Alice-nel-paese-delle-meraviglie-'
'72371d3c-d998-49f3-8860-d168cfdf4966.html',
'info_dict': { 'info_dict': {
'id': '72371d3c-d998-49f3-8860-d168cfdf4966', 'id': '72371d3c-d998-49f3-8860-d168cfdf4966',
'title': "Alice nel paese delle meraviglie", 'title': "Alice nel paese delle meraviglie",
'description': "di Lewis Carrol letto da Aldo Busi", 'description': "di Lewis Carrol letto da Aldo Busi"},
}, 'playlist_count': 11}
'playlist_count': 11,
}
def _real_extract(self, url): def _real_extract(self, url):
playlist_id = self._match_id(url) playlist_id = self._match_id(url)
playlist_webpage = self._download_webpage(url, playlist_id) playlist_webpage = self._download_webpage(url, playlist_id)
playlist_title = unescapeHTML(self._html_search_regex(r'data-playlist-title="(.+?)"', playlist_webpage, 'title')) playlist_title = unescapeHTML(self._html_search_regex(
playlist_creator = self._html_search_meta('nomeProgramma', playlist_webpage) r'data-playlist-title="(.+?)"', playlist_webpage, 'title'))
playlist_description = get_element_by_class('textDescriptionProgramma', playlist_webpage) playlist_creator = self._html_search_meta(
'nomeProgramma', playlist_webpage)
playlist_description = get_element_by_class(
'textDescriptionProgramma', playlist_webpage)
player_href = self._html_search_regex(r'data-player-href="(.+?)"', playlist_webpage, 'href') player_href = self._html_search_regex(
r'data-player-href="(.+?)"', playlist_webpage, 'href')
list_url = urljoin(url, player_href) list_url = urljoin(url, player_href)
entries = self.get_playlist(list_url) entries = self.get_playlist(list_url)
@ -595,7 +603,7 @@ class RaiPlayRadioPlaylistIE(RaiPlayRadioBaseIE):
'track': entry['title'], 'track': entry['title'],
'track_number': index, 'track_number': index,
'album': playlist_title, 'album': playlist_title,
'artist': playlist_creator, 'artist': playlist_creator})
})
return self.playlist_result(entries, playlist_id, playlist_title, playlist_description) return self.playlist_result(
entries, playlist_id, playlist_title, playlist_description)