]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/musicdex.py
1 from .common
import InfoExtractor
10 class MusicdexBaseIE(InfoExtractor
):
11 def _return_info(self
, track_json
, album_json
, id):
14 'title': track_json
.get('name'),
15 'track': track_json
.get('name'),
16 'description': track_json
.get('description'),
17 'track_number': track_json
.get('number'),
18 'url': format_field(track_json
, 'url', 'https://www.musicdex.org/%s'),
19 'duration': track_json
.get('duration'),
20 'genre': [genre
.get('name') for genre
in track_json
.get('genres') or []],
21 'like_count': track_json
.get('likes_count'),
22 'view_count': track_json
.get('plays'),
23 'artist': [artist
.get('name') for artist
in track_json
.get('artists') or []],
24 'album_artist': [artist
.get('name') for artist
in album_json
.get('artists') or []],
25 'thumbnail': format_field(album_json
, 'image', 'https://www.musicdex.org/%s'),
26 'album': album_json
.get('name'),
27 'release_year': try_get(album_json
, lambda x
: date_from_str(unified_strdate(x
['release_date'])).year
),
28 'extractor_key': MusicdexSongIE
.ie_key(),
29 'extractor': 'MusicdexSong',
33 class MusicdexSongIE(MusicdexBaseIE
):
34 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/track/(?P<id>\d+)'
37 'url': 'https://www.musicdex.org/track/306/dual-existence',
41 'title': 'dual existence',
42 'description': '#NIPPONSEI @ IRC.RIZON.NET',
43 'track': 'dual existence',
49 'artist': ['fripSide'],
50 'album_artist': ['fripSide'],
51 'thumbnail': 'https://www.musicdex.org/storage/album/9iDIam1DHTVqUG4UclFIEq1WAFGXfPW4y0TtZa91.png',
52 'album': 'To Aru Kagaku no Railgun T OP2 Single - dual existence',
55 'params': {'skip_download': True}
58 def _real_extract(self
, url
):
59 id = self
._match
_id
(url
)
60 data_json
= self
._download
_json
(f
'https://www.musicdex.org/secure/tracks/{id}?defaultRelations=true', id)['track']
61 return self
._return
_info
(data_json
, data_json
.get('album') or {}, id)
64 class MusicdexAlbumIE(MusicdexBaseIE
):
65 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/album/(?P<id>\d+)'
68 'url': 'https://www.musicdex.org/album/56/tenmon-and-eiichiro-yanagi-minori/ef-a-tale-of-memories-original-soundtrack-2-fortissimo',
69 'playlist_mincount': 28,
74 'artist': ['TENMON & Eiichiro Yanagi / minori'],
75 'title': 'ef - a tale of memories Original Soundtrack 2 ~fortissimo~',
77 'thumbnail': 'https://www.musicdex.org/storage/album/2rSHkyYBYfB7sbvElpEyTMcUn6toY7AohOgJuDlE.jpg',
81 def _real_extract(self
, url
):
82 id = self
._match
_id
(url
)
83 data_json
= self
._download
_json
(f
'https://www.musicdex.org/secure/albums/{id}?defaultRelations=true', id)['album']
84 entries
= [self
._return
_info
(track
, data_json
, track
['id']) for track
in data_json
.get('tracks') or [] if track
.get('id')]
89 'title': data_json
.get('name'),
90 'description': data_json
.get('description'),
91 'genre': [genre
.get('name') for genre
in data_json
.get('genres') or []],
92 'view_count': data_json
.get('plays'),
93 'artist': [artist
.get('name') for artist
in data_json
.get('artists') or []],
94 'thumbnail': format_field(data_json
, 'image', 'https://www.musicdex.org/%s'),
95 'release_year': try_get(data_json
, lambda x
: date_from_str(unified_strdate(x
['release_date'])).year
),
100 class MusicdexPageIE(MusicdexBaseIE
):
101 def _entries(self
, id):
102 next_page_url
= self
._API
_URL
% id
104 data_json
= self
._download
_json
(next_page_url
, id)['pagination']
105 for data
in data_json
.get('data') or []:
107 next_page_url
= data_json
.get('next_page_url')
110 class MusicdexArtistIE(MusicdexPageIE
):
111 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/artist/(?P<id>\d+)'
112 _API_URL
= 'https://www.musicdex.org/secure/artists/%s/albums?page=1'
115 'url': 'https://www.musicdex.org/artist/11/fripside',
116 'playlist_mincount': 28,
121 'thumbnail': 'https://www.musicdex.org/storage/artist/ZmOz0lN2vsweegB660em3xWffCjLPmTQHqJls5Xx.jpg',
125 def _real_extract(self
, url
):
126 id = self
._match
_id
(url
)
127 data_json
= self
._download
_json
(f
'https://www.musicdex.org/secure/artists/{id}', id)['artist']
129 for album
in self
._entries
(id):
130 entries
.extend(self
._return
_info
(track
, album
, track
['id']) for track
in album
.get('tracks') or [] if track
.get('id'))
135 'title': data_json
.get('name'),
136 'view_count': data_json
.get('plays'),
137 'thumbnail': format_field(data_json
, 'image_small', 'https://www.musicdex.org/%s'),
142 class MusicdexPlaylistIE(MusicdexPageIE
):
143 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/playlist/(?P<id>\d+)'
144 _API_URL
= 'https://www.musicdex.org/secure/playlists/%s/tracks?perPage=10000&page=1'
147 'url': 'https://www.musicdex.org/playlist/9/test',
148 'playlist_mincount': 73,
153 'thumbnail': 'https://www.musicdex.org/storage/album/jXATI79f0IbQ2sgsKYOYRCW3zRwF3XsfHhzITCuJ.jpg',
154 'description': 'Test 123 123 21312 32121321321321312',
158 def _real_extract(self
, url
):
159 id = self
._match
_id
(url
)
160 data_json
= self
._download
_json
(f
'https://www.musicdex.org/secure/playlists/{id}', id)['playlist']
161 entries
= [self
._return
_info
(track
, track
.get('album') or {}, track
['id'])
162 for track
in self
._entries
(id) or [] if track
.get('id')]
167 'title': data_json
.get('name'),
168 'description': data_json
.get('description'),
169 'view_count': data_json
.get('plays'),
170 'thumbnail': format_field(data_json
, 'image', 'https://www.musicdex.org/%s'),