[extractor/rai] using new _VALID_URLS property

- implemented _VALID_URLS property
- deleted a couple of subclasses
- added '_old_archive_ids' to manage back-compatibility with removed subclasses (by @pukkandan)
This commit is contained in:
nixxo 2022-12-16 11:20:03 +01:00
parent 74b5d34794
commit 7b93fb5ddc
No known key found for this signature in database
GPG Key ID: E0DE62EF9A9BFAB2
2 changed files with 47 additions and 49 deletions

View File

@ -1479,10 +1479,8 @@
)
from .rai import (
RaiPlayIE,
RaiPlayLiveIE,
RaiPlayPlaylistIE,
RaiPlaySoundIE,
RaiPlaySoundLiveIE,
RaiPlaySoundPlaylistIE,
RaiNewsIE,
RaiSudtirolIE,

View File

@ -16,6 +16,7 @@
HEADRequest,
int_or_none,
join_nonempty,
make_archive_id,
parse_duration,
remove_start,
strip_or_none,
@ -234,7 +235,10 @@ def _extract_subtitles(url, video_data):
class RaiPlayIE(RaiBaseIE):
_VALID_URL = rf'(?P<base>https?://(?:www\.)?raiplay\.it/.+?-(?P<id>{RaiBaseIE._UUID_RE}))\.(?:html|json)'
_VALID_URLS = [
rf'(?P<base>https?://(?:www\.)?raiplay\.it/.+?-(?P<id>{RaiBaseIE._UUID_RE}))\.(?:html|json)',
r'(?P<base>https?://(?:www\.)?raiplay\.it/dirette/(?P<id>[^/?#&]+))',
]
_TESTS = [{
'url': 'http://www.raiplay.it/video/2014/04/Report-del-07042014-cb27157f-9dd0-4aee-b788-b1f67643a391.html',
'md5': '8970abf8caf8aef4696e7b1f2adfc696',
@ -282,6 +286,25 @@ class RaiPlayIE(RaiBaseIE):
'timestamp': 1637318940,
'upload_date': '20211119',
},
}, {
# live stream
'url': 'https://www.raiplay.it/dirette/rainews24',
'info_dict': {
'id': 'd784ad40-e0ae-4a69-aa76-37519d238a9c',
'display_id': 'rainews24',
'ext': 'mp4',
'title': r're:^Diretta di Rai News 24 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
'description': 'md5:4d00bcf6dc98b27c6ec480de329d1497',
'uploader': 'Rai News 24',
'creator': 'Rai News 24',
'is_live': True,
'live_status': 'is_live',
'upload_date': '20090502',
'timestamp': 1241276220,
},
'params': {
'skip_download': True,
},
}, {
'url': 'http://www.raiplay.it/video/2016/11/gazebotraindesi-efebe701-969c-4593-92f3-285f0d1ce750.html?',
'only_matching': True,
@ -336,6 +359,7 @@ def _real_extract(self, url):
return {
'id': remove_start(media.get('id'), 'ContentItem-') or video_id,
'display_id': video_id,
'_old_archive_ids': [make_archive_id('RaiPlayLive', video_id)] if not re.match(RaiBaseIE._UUID_RE, video_id) else None,
'title': title,
'alt_title': strip_or_none(alt_title or None),
'description': media.get('description'),
@ -355,29 +379,6 @@ def _real_extract(self, url):
}
class RaiPlayLiveIE(RaiPlayIE): # XXX: Do not subclass from concrete IE
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplay\.it/dirette/(?P<id>[^/?#&]+))'
_TESTS = [{
'url': 'http://www.raiplay.it/dirette/rainews24',
'info_dict': {
'id': 'd784ad40-e0ae-4a69-aa76-37519d238a9c',
'display_id': 'rainews24',
'ext': 'mp4',
'title': 're:^Diretta di Rai News 24 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
'description': 'md5:4d00bcf6dc98b27c6ec480de329d1497',
'uploader': 'Rai News 24',
'creator': 'Rai News 24',
'is_live': True,
'live_status': 'is_live',
'upload_date': '20090502',
'timestamp': 1241276220,
},
'params': {
'skip_download': True,
},
}]
class RaiPlayPlaylistIE(InfoExtractor):
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplay\.it/programmi/(?P<id>[^/?#&]+))(?:/(?P<extra_id>[^?#&]+))?'
_TESTS = [{
@ -440,7 +441,10 @@ def _real_extract(self, url):
class RaiPlaySoundIE(RaiBaseIE):
_VALID_URL = rf'(?P<base>https?://(?:www\.)?raiplaysound\.it/.+?-(?P<id>{RaiBaseIE._UUID_RE}))\.(?:html|json)'
_VALID_URLS = [
rf'(?P<base>https?://(?:www\.)?raiplaysound\.it/.+?-(?P<id>{RaiBaseIE._UUID_RE}))\.(?:html|json)',
r'(?P<base>https?://(?:www\.)?raiplaysound\.it/(?P<id>[^/?#&]+)$)',
]
_TESTS = [{
'url': 'https://www.raiplaysound.it/audio/2021/12/IL-RUGGITO-DEL-CONIGLIO-1ebae2a7-7cdb-42bb-842e-fe0d193e9707.html',
'md5': '8970abf8caf8aef4696e7b1f2adfc696',
@ -462,6 +466,23 @@ class RaiPlaySoundIE(RaiBaseIE):
'params': {
'skip_download': True,
},
}, {
'url': 'https://www.raiplaysound.it/radio2',
'info_dict': {
'id': 'b00a50e6-f404-4af6-8f8c-ff3b9af73a44',
'display_id': 'radio2',
'ext': 'mp4',
'title': r're:Rai Radio 2 \d+-\d+-\d+ \d+:\d+',
'thumbnail': r're:https://www\.raiplaysound\.it/dl/img/.+png',
'uploader': 'rai radio 2',
'series': 'Rai Radio 2',
'creator': 'raiplaysound',
'is_live': True,
'live_status': 'is_live',
},
'params': {
'skip_download': 'live',
},
}]
def _real_extract(self, url):
@ -488,6 +509,7 @@ def _real_extract(self, url):
**info,
'id': uid or audio_id,
'display_id': audio_id,
'_old_archive_ids': [make_archive_id('RaiPlaySoundLive', audio_id)] if not re.match(RaiBaseIE._UUID_RE, audio_id) else None,
'title': traverse_obj(media, 'title', 'episode_title'),
'alt_title': traverse_obj(media, ('track_info', 'media_name'), expected_type=strip_or_none),
'description': media.get('description'),
@ -503,28 +525,6 @@ def _real_extract(self, url):
}
class RaiPlaySoundLiveIE(RaiPlaySoundIE): # XXX: Do not subclass from concrete IE
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplaysound\.it/(?P<id>[^/?#&]+)$)'
_TESTS = [{
'url': 'https://www.raiplaysound.it/radio2',
'info_dict': {
'id': 'b00a50e6-f404-4af6-8f8c-ff3b9af73a44',
'display_id': 'radio2',
'ext': 'mp4',
'title': r're:Rai Radio 2 \d+-\d+-\d+ \d+:\d+',
'thumbnail': r're:https://www.raiplaysound.it/dl/img/.+?png',
'uploader': 'rai radio 2',
'series': 'Rai Radio 2',
'creator': 'raiplaysound',
'is_live': True,
'live_status': 'is_live',
},
'params': {
'skip_download': 'live',
},
}]
class RaiPlaySoundPlaylistIE(InfoExtractor):
_VALID_URL = r'(?P<base>https?://(?:www\.)?raiplaysound\.it/(?:programmi|playlist|audiolibri)/(?P<id>[^/?#&]+))(?:/(?P<extra_id>[^?#&]+))?'
_TESTS = [{