]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/musescore.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / musescore.py
CommitLineData
ffecd303
AG
1from .common import InfoExtractor
2
3
4class MuseScoreIE(InfoExtractor):
73f035e1 5 _VALID_URL = r'https?://(?:www\.)?musescore\.com/(?:user/\d+|[^/]+)(?:/scores)?/(?P<id>[^#&?]+)'
ffecd303
AG
6 _TESTS = [{
7 'url': 'https://musescore.com/user/73797/scores/142975',
8 'info_dict': {
9 'id': '142975',
10 'ext': 'mp3',
11 'title': 'WA Mozart Marche Turque (Turkish March fingered)',
12 'description': 'md5:7ede08230e4eaabd67a4a98bb54d07be',
73f035e1 13 'thumbnail': r're:https?://(?:www\.)?musescore\.com/.*\.png[^$]+',
ffecd303
AG
14 'uploader': 'PapyPiano',
15 'creator': 'Wolfgang Amadeus Mozart',
add96eb9 16 },
ffecd303
AG
17 }, {
18 'url': 'https://musescore.com/user/36164500/scores/6837638',
19 'info_dict': {
20 'id': '6837638',
21 'ext': 'mp3',
22 'title': 'Sweet Child O\' Mine – Guns N\' Roses sweet child',
23 'description': 'md5:4dca71191c14abc312a0a4192492eace',
73f035e1 24 'thumbnail': r're:https?://(?:www\.)?musescore\.com/.*\.png[^$]+',
ffecd303
AG
25 'uploader': 'roxbelviolin',
26 'creator': 'Guns N´Roses Arr. Roxbel Violin',
add96eb9 27 },
ffecd303
AG
28 }, {
29 'url': 'https://musescore.com/classicman/fur-elise',
30 'info_dict': {
31 'id': '33816',
32 'ext': 'mp3',
33 'title': 'Für Elise – Beethoven',
34 'description': 'md5:49515a3556d5ecaf9fa4b2514064ac34',
73f035e1 35 'thumbnail': r're:https?://(?:www\.)?musescore\.com/.*\.png[^$]+',
ffecd303
AG
36 'uploader': 'ClassicMan',
37 'creator': 'Ludwig van Beethoven (1770–1827)',
add96eb9 38 },
ffecd303
AG
39 }, {
40 'url': 'https://musescore.com/minh_cuteee/scores/6555384',
41 'only_matching': True,
42 }]
43
44 def _real_extract(self, url):
45 webpage = self._download_webpage(url, None)
46 url = self._og_search_url(webpage) or url
add96eb9 47 video_id = self._match_id(url)
48 mp3_url = self._download_json(f'https://musescore.com/api/jmuse?id={video_id}&index=0&type=mp3&v2=1', video_id,
ffecd303
AG
49 headers={'authorization': '63794e5461e4cfa046edfbdddfccc1ac16daffd2'})['info']['url']
50 formats = [{
51 'url': mp3_url,
52 'ext': 'mp3',
53 'vcodec': 'none',
54 }]
55
56 return {
add96eb9 57 'id': video_id,
ffecd303
AG
58 'formats': formats,
59 'title': self._og_search_title(webpage),
60 'description': self._og_search_description(webpage),
61 'thumbnail': self._og_search_thumbnail(webpage),
62 'uploader': self._html_search_meta('musescore:author', webpage, 'uploader'),
63 'creator': self._html_search_meta('musescore:composer', webpage, 'composer'),
64 }