[ie/soundcloud] Various fixes (#11820)
[yt-dlp.git] / yt_dlp / extractor / musescore.py
blob0ef2fa0c88e4e348d3c661f058f83112880c4529
1 from .common import InfoExtractor
4 class MuseScoreIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:www\.)?musescore\.com/(?:user/\d+|[^/]+)(?:/scores)?/(?P<id>[^#&?]+)'
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',
13 'thumbnail': r're:https?://(?:www\.)?musescore\.com/.*\.png[^$]+',
14 'uploader': 'PapyPiano',
15 'creator': 'Wolfgang Amadeus Mozart',
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',
24 'thumbnail': r're:https?://(?:www\.)?musescore\.com/.*\.png[^$]+',
25 'uploader': 'roxbelviolin',
26 'creator': 'Guns N´Roses Arr. Roxbel Violin',
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',
35 'thumbnail': r're:https?://(?:www\.)?musescore\.com/.*\.png[^$]+',
36 'uploader': 'ClassicMan',
37 'creator': 'Ludwig van Beethoven (1770–1827)',
39 }, {
40 'url': 'https://musescore.com/minh_cuteee/scores/6555384',
41 'only_matching': True,
44 def _real_extract(self, url):
45 webpage = self._download_webpage(url, None)
46 url = self._og_search_url(webpage) or url
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,
49 headers={'authorization': '63794e5461e4cfa046edfbdddfccc1ac16daffd2'})['info']['url']
50 formats = [{
51 'url': mp3_url,
52 'ext': 'mp3',
53 'vcodec': 'none',
56 return {
57 'id': video_id,
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'),