3 from .common
import InfoExtractor
4 from ..networking
import HEADRequest
12 from ..utils
.traversal
import traverse_obj
15 class Mx3BaseIE(InfoExtractor
):
16 _VALID_URL_TMPL
= r
'https?://(?:www\.)?%s/t/(?P<id>\w+)'
18 'url': 'player_asset',
19 'format_id': 'default',
22 'url': 'player_asset?quality=hd',
27 'format_id': 'download',
30 'url': 'player_asset?quality=source',
31 'format_id': 'source',
35 def _extract_formats(self
, track_id
):
37 for fmt
in self
._FORMATS
:
38 format_url
= f
'https://{self._DOMAIN}/tracks/{track_id}/{fmt["url"]}'
39 urlh
= self
._request
_webpage
(
40 HEADRequest(format_url
), track_id
, fatal
=False, expected_status
=404,
41 note
=f
'Checking for format {fmt["format_id"]}')
42 if urlh
and urlh
.status
== 200:
46 'ext': urlhandle_detect_ext(urlh
),
47 'filesize': int_or_none(urlh
.headers
.get('Content-Length')),
51 def _real_extract(self
, url
):
52 track_id
= self
._match
_id
(url
)
53 webpage
= self
._download
_webpage
(url
, track_id
)
54 more_info
= get_element_by_class('single-more-info', webpage
)
55 data
= self
._download
_json
(f
'https://{self._DOMAIN}/t/{track_id}.json', track_id
, fatal
=False)
57 def get_info_field(name
):
58 return self
._html
_search
_regex
(
59 rf
'<dt[^>]*>\s*{name}\s*</dt>\s*<dd[^>]*>(.*?)</dd>',
60 more_info
, name
, default
=None, flags
=re
.DOTALL
)
64 'formats': self
._extract
_formats
(track_id
),
65 'genre': self
._html
_search
_regex
(
66 r
'<div\b[^>]+class="single-band-genre"[^>]*>([^<]+)</div>', webpage
, 'genre', default
=None),
67 'release_year': int_or_none(get_info_field('Year of creation')),
68 'description': get_info_field('Description'),
69 'tags': try_call(lambda: get_info_field('Tag').split(', '), list),
70 **traverse_obj(data
, {
71 'title': ('title', {str}
),
72 'artist': (('performer_name', 'artist'), {str}
),
73 'album_artist': ('artist', {str}
),
74 'composer': ('composer_name', {str}
),
75 'thumbnail': (('picture_url_xlarge', 'picture_url'), {url_or_none}
),
80 class Mx3IE(Mx3BaseIE
):
82 _VALID_URL
= Mx3BaseIE
._VALID
_URL
_TMPL
% re
.escape(_DOMAIN
)
84 'url': 'https://mx3.ch/t/1Cru',
85 'md5': '7ba09e9826b4447d4e1ce9d69e0e295f',
90 'album_artist': 'Tortue Tortue',
91 'composer': 'Olivier Godinat',
93 'thumbnail': 'https://mx3.ch/pictures/mx3/file/0101/4643/square_xlarge/1-s-envoler-1.jpg?1630272813',
99 'url': 'https://mx3.ch/t/1LIY',
100 'md5': '48293cb908342547827f963a5a2e9118',
104 'artist': 'Tania Kimfumu',
105 'album_artist': 'The Broots',
106 'composer': 'Emmanuel Diserens',
108 'thumbnail': 'https://mx3.ch/pictures/mx3/file/0110/0003/video_xlarge/frame_0000.png?1686963670',
109 'title': 'The Broots-Larytta remix "Begging For Help"',
110 'release_year': 2023,
111 'tags': ['the broots', 'cassata records', 'larytta'],
112 'description': '"Begging for Help" Larytta Remix Official Video\nRealized By Kali Donkilie in 2023',
115 'url': 'https://mx3.ch/t/1C6E',
116 'md5': '1afcd578493ddb8e5008e94bb6d97e25',
120 'artist': 'Alien Bubblegum',
121 'album_artist': 'Alien Bubblegum',
122 'composer': 'Alien Bubblegum',
124 'thumbnail': 'https://mx3.ch/pictures/mx3/file/0101/1551/square_xlarge/pandora-s-box-cover-with-title.png?1627054733',
125 'title': 'Wide Awake',
126 'release_year': 2021,
127 'tags': ['alien bubblegum', 'bubblegum', 'alien', 'pop punk', 'poppunk'],
132 class Mx3NeoIE(Mx3BaseIE
):
133 _DOMAIN
= 'neo.mx3.ch'
134 _VALID_URL
= Mx3BaseIE
._VALID
_URL
_TMPL
% re
.escape(_DOMAIN
)
136 'url': 'https://neo.mx3.ch/t/1hpd',
137 'md5': '6d9986bbae5cac3296ec8813bf965eb2',
141 'artist': 'Baptiste Lopez',
142 'album_artist': 'Kammerorchester Basel',
143 'composer': 'Jannik Giger',
144 'genre': 'Composition, Orchestra',
145 'title': 'Troisième œil. Für Kammerorchester (2023)',
146 'thumbnail': 'https://neo.mx3.ch/pictures/neo/file/0000/0241/square_xlarge/kammerorchester-basel-group-photo-2_c_-lukasz-rajchert.jpg?1560341252',
147 'release_year': 2023,
153 class Mx3VolksmusikIE(Mx3BaseIE
):
154 _DOMAIN
= 'volksmusik.mx3.ch'
155 _VALID_URL
= Mx3BaseIE
._VALID
_URL
_TMPL
% re
.escape(_DOMAIN
)
157 'url': 'https://volksmusik.mx3.ch/t/Zx',
158 'md5': 'dd967a7b0c1ef898f3e072cf9c2eae3c',
162 'artist': 'Ländlerkapelle GrischArt',
163 'album_artist': 'Ländlerkapelle GrischArt',
164 'composer': 'Urs Glauser',
165 'genre': 'Instrumental, Graubünden',
166 'title': 'Chämilouf',
167 'thumbnail': 'https://volksmusik.mx3.ch/pictures/vxm/file/0000/3815/square_xlarge/grischart1.jpg?1450530120',
168 'release_year': 2012,