1 from .common
import InfoExtractor
10 class MusicdexBaseIE(InfoExtractor
):
11 def _return_info(self
, track_json
, album_json
, video_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 'genres': [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 'artists': [artist
.get('name') for artist
in track_json
.get('artists') or []],
24 'album_artists': [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 'artists': ['fripSide'],
50 'album_artists': ['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 video_id
= self
._match
_id
(url
)
60 data_json
= self
._download
_json
(
61 f
'https://www.musicdex.org/secure/tracks/{video_id}?defaultRelations=true', video_id
)['track']
62 return self
._return
_info
(data_json
, data_json
.get('album') or {}, video_id
)
65 class MusicdexAlbumIE(MusicdexBaseIE
):
66 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/album/(?P<id>\d+)'
69 'url': 'https://www.musicdex.org/album/56/tenmon-and-eiichiro-yanagi-minori/ef-a-tale-of-memories-original-soundtrack-2-fortissimo',
70 'playlist_mincount': 28,
75 'artists': ['TENMON & Eiichiro Yanagi / minori'],
76 'title': 'ef - a tale of memories Original Soundtrack 2 ~fortissimo~',
78 'thumbnail': 'https://www.musicdex.org/storage/album/2rSHkyYBYfB7sbvElpEyTMcUn6toY7AohOgJuDlE.jpg',
82 def _real_extract(self
, url
):
83 playlist_id
= self
._match
_id
(url
)
84 data_json
= self
._download
_json
(
85 f
'https://www.musicdex.org/secure/albums/{playlist_id}?defaultRelations=true', playlist_id
)['album']
86 entries
= [self
._return
_info
(track
, data_json
, track
['id'])
87 for track
in data_json
.get('tracks') or [] if track
.get('id')]
92 'title': data_json
.get('name'),
93 'description': data_json
.get('description'),
94 'genres': [genre
.get('name') for genre
in data_json
.get('genres') or []],
95 'view_count': data_json
.get('plays'),
96 'artists': [artist
.get('name') for artist
in data_json
.get('artists') or []],
97 'thumbnail': format_field(data_json
, 'image', 'https://www.musicdex.org/%s'),
98 'release_year': try_get(data_json
, lambda x
: date_from_str(unified_strdate(x
['release_date'])).year
),
103 class MusicdexPageIE(MusicdexBaseIE
): # XXX: Conventionally, base classes should end with BaseIE/InfoExtractor
104 def _entries(self
, playlist_id
):
105 next_page_url
= self
._API
_URL
% playlist_id
107 data_json
= self
._download
_json
(next_page_url
, playlist_id
)['pagination']
108 yield from data_json
.get('data') or []
109 next_page_url
= data_json
.get('next_page_url')
112 class MusicdexArtistIE(MusicdexPageIE
):
113 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/artist/(?P<id>\d+)'
114 _API_URL
= 'https://www.musicdex.org/secure/artists/%s/albums?page=1'
117 'url': 'https://www.musicdex.org/artist/11/fripside',
118 'playlist_mincount': 28,
123 'thumbnail': 'https://www.musicdex.org/storage/artist/ZmOz0lN2vsweegB660em3xWffCjLPmTQHqJls5Xx.jpg',
127 def _real_extract(self
, url
):
128 playlist_id
= self
._match
_id
(url
)
129 data_json
= self
._download
_json
(f
'https://www.musicdex.org/secure/artists/{playlist_id}', playlist_id
)['artist']
131 for album
in self
._entries
(playlist_id
):
132 entries
.extend(self
._return
_info
(track
, album
, track
['id']) for track
in album
.get('tracks') or [] if track
.get('id'))
137 'title': data_json
.get('name'),
138 'view_count': data_json
.get('plays'),
139 'thumbnail': format_field(data_json
, 'image_small', 'https://www.musicdex.org/%s'),
144 class MusicdexPlaylistIE(MusicdexPageIE
):
145 _VALID_URL
= r
'https?://(?:www\.)?musicdex\.org/playlist/(?P<id>\d+)'
146 _API_URL
= 'https://www.musicdex.org/secure/playlists/%s/tracks?perPage=10000&page=1'
149 'url': 'https://www.musicdex.org/playlist/9/test',
150 'playlist_mincount': 73,
155 'thumbnail': 'https://www.musicdex.org/storage/album/jXATI79f0IbQ2sgsKYOYRCW3zRwF3XsfHhzITCuJ.jpg',
156 'description': 'Test 123 123 21312 32121321321321312',
160 def _real_extract(self
, url
):
161 playlist_id
= self
._match
_id
(url
)
162 data_json
= self
._download
_json
(f
'https://www.musicdex.org/secure/playlists/{playlist_id}', playlist_id
)['playlist']
163 entries
= [self
._return
_info
(track
, track
.get('album') or {}, track
['id'])
164 for track
in self
._entries
(playlist_id
) or [] if track
.get('id')]
169 'title': data_json
.get('name'),
170 'description': data_json
.get('description'),
171 'view_count': data_json
.get('plays'),
172 'thumbnail': format_field(data_json
, 'image', 'https://www.musicdex.org/%s'),