Compare commits

...

2 Commits

Author SHA1 Message Date
Martin Renold
ce38da900b [ie/mx3] Do not prepend artist to title, do not output lists
Some other extractors use lists too, but it doesn't work well with filename
templates.
2024-01-14 21:57:45 +01:00
Martin Renold
fb53e7197f [ie/mx3] Support for neo.mx3.ch and volksmusik.mx3.ch
The track IDs on neo.mx3.ch and volksmusik.mx3.ch do not work on mx3.ch.
The sites even require users to create a separate login.

And also extract "composer" and "performer".
2024-01-14 20:13:34 +01:00
2 changed files with 63 additions and 13 deletions

View File

@ -1124,7 +1124,11 @@ from .musicdex import (
MusicdexArtistIE,
MusicdexPlaylistIE,
)
from .mx3 import Mx3IE
from .mx3 import (
Mx3IE,
Mx3NeoIE,
Mx3VolksmusikIE,
)
from .mxplayer import (
MxplayerIE,
MxplayerShowIE,

View File

@ -6,6 +6,7 @@ from ..networking import HEADRequest
class Mx3IE(InfoExtractor):
_MX3_DOMAIN = 'mx3.ch'
_VALID_URL = r'https?://(?:www\.)?mx3\.ch/t/(?P<id>[0-9A-Za-z]+)'
_TESTS = [{
'url': 'https://mx3.ch/t/1Cru',
@ -14,10 +15,11 @@ class Mx3IE(InfoExtractor):
'id': '1Cru',
# This one is audio-only. It's a mp3, but we have to make a HEAD request to find out.
'ext': 'mp3',
'artist': 'Tortue Tortue',
'artist': 'Tortue Tortue, Godina',
'composer': 'Olivier Godinat',
'genre': 'Rock',
'thumbnail': 'https://mx3.ch/pictures/mx3/file/0101/4643/square_xlarge/1-s-envoler-1.jpg?1630272813',
'title': 'Tortue Tortue - S\'envoler',
'title': 'S\'envoler',
}
}, {
'url': 'https://mx3.ch/t/1LIY',
@ -26,7 +28,8 @@ class Mx3IE(InfoExtractor):
'id': '1LIY',
# This is a music video. 'file' says: ISO Media, MP4 Base Media v1 [ISO 14496-12:2003]
'ext': 'mp4',
'artist': 'The Broots',
'artist': 'The Broots, Tania Kimfumu',
'composer': 'Emmanuel Diserens',
'genre': 'Electro',
'thumbnail': 'https://mx3.ch/pictures/mx3/file/0110/0003/video_xlarge/frame_0000.png?1686963670',
'title': 'The Broots-Larytta remix "Begging For Help"',
@ -39,21 +42,26 @@ class Mx3IE(InfoExtractor):
# This one has a download button, yielding a WAV.
'ext': 'wav',
'artist': 'Alien Bubblegum',
'composer': 'Alien Bubblegum',
'genre': 'Punk',
'thumbnail': 'https://mx3.ch/pictures/mx3/file/0101/1551/square_xlarge/pandora-s-box-cover-with-title.png?1627054733',
'title': 'Alien Bubblegum - Wide Awake',
'title': 'Wide Awake',
}
}]
def _real_extract(self, url):
track_id = self._match_id(url)
webpage = self._download_webpage(url, track_id)
json = self._download_json(f'https://mx3.ch/t/{track_id}.json', track_id)
json = self._download_json(f'https://{self._MX3_DOMAIN}/t/{track_id}.json', track_id)
artists = []
if json.get('artist'):
artists.append(json['artist'])
performer = json.get('performer_name')
if performer and performer not in artists:
artists.append(performer)
title = json['title']
artist = json.get('artist')
if artist and not title.startswith(artist):
title = artist + ' - ' + title
genre = self._html_search_regex(r'<div\b[^>]+class="single-band-genre"[^>]*>([^<]+)</div>',
webpage, 'genre', fatal=False, flags=re.DOTALL)
@ -66,15 +74,16 @@ class Mx3IE(InfoExtractor):
fmt['ext'] = urlhandle_detect_ext(urlh)
formats.append(fmt)
base_url = 'https://' + self._MX3_DOMAIN + '/'
add_format({
'url': 'https://mx3.ch/' + json['url'],
'url': base_url + json["url"],
'format_id': 'default',
'quality': 1,
})
if 'hd_url' in json:
add_format({
'url': 'https://mx3.ch/' + json['hd_url'],
'url': base_url + json['hd_url'],
'format_id': 'hd',
'quality': 10,
})
@ -82,7 +91,7 @@ class Mx3IE(InfoExtractor):
# the "download" feature is not available everywhere
if f'/tracks/{track_id}/download' in webpage:
add_format({
'url': f'https://mx3.ch/tracks/{track_id}/download',
'url': f'{base_url}tracks/{track_id}/download',
'format_id': 'download',
'quality': 11,
'format_note': 'usually uncompressed WAV',
@ -92,7 +101,44 @@ class Mx3IE(InfoExtractor):
'id': track_id,
'formats': formats,
'title': title,
'artist': artist,
'artist': ', '.join(artists),
'composer': json.get('composer_name', None),
'genre': genre,
'thumbnail': json.get('picture_url_xlarge') or json.get('picture_url'),
}
class Mx3NeoIE(Mx3IE):
_MX3_DOMAIN = 'neo.mx3.ch'
_VALID_URL = r'https?://(?:www\.)?neo.mx3\.ch/t/(?P<id>[0-9A-Za-z]+)'
_TESTS = [{
'url': 'https://neo.mx3.ch/t/1hpd',
'md5': 'ff0b2b91ce0b8931c0a358715758dc78',
'info_dict': {
'id': '1hpd',
'ext': 'mp3',
'artist': 'Kammerorchester Basel, Baptiste Lopez',
'composer': 'Jannik Giger',
'genre': 'Composition, Orchestra',
'title': 'Troisième œil. Für Kammerorchester (2023)',
'thumbnail': 'https://neo.mx3.ch/pictures/neo/file/0000/0241/square_xlarge/kammerorchester-basel-group-photo-2_c_-lukasz-rajchert.jpg?1560341252'
}
}]
class Mx3VolksmusikIE(Mx3IE):
_MX3_DOMAIN = 'volksmusik.mx3.ch'
_VALID_URL = r'https?://(?:www\.)?volksmusik.mx3\.ch/t/(?P<id>[0-9A-Za-z]+)'
_TESTS = [{
'url': 'https://volksmusik.mx3.ch/t/Zx',
'md5': 'dd967a7b0c1ef898f3e072cf9c2eae3c',
'info_dict': {
'id': 'Zx',
'ext': 'mp3',
'artist': 'Ländlerkapelle GrischArt',
'composer': 'Urs Glauser',
'genre': 'Instrumental, Graubünden',
'title': 'Chämilouf',
'thumbnail': 'https://volksmusik.mx3.ch/pictures/vxm/file/0000/3815/square_xlarge/grischart1.jpg?1450530120',
}
}]