1 from .common
import InfoExtractor
9 class PalcoMP3BaseIE(InfoExtractor
):
10 _GQL_QUERY_TMPL
= '''{
15 _ARTIST_FIELDS_TMPL
= '''music(slug: "%%s") {
18 _MUSIC_FIELDS
= '''duration
25 def _call_api(self
, artist_slug
, artist_fields
):
26 return self
._download
_json
(
27 'https://www.palcomp3.com.br/graphql/', artist_slug
, query
={
28 'query': self
._GQL
_QUERY
_TMPL
% (artist_slug
, artist_fields
),
31 def _parse_music(self
, music
):
32 music_id
= str(music
['musicID'])
33 title
= music
['title']
36 hls_url
= music
.get('hls')
40 'protocol': 'm3u8_native',
43 mp3_file
= music
.get('mp3File')
53 'duration': int_or_none(music
.get('duration')),
54 'view_count': int_or_none(music
.get('plays')),
57 def _real_initialize(self
):
58 self
._ARTIST
_FIELDS
_TMPL
= self
._ARTIST
_FIELDS
_TMPL
% self
._MUSIC
_FIELDS
60 def _real_extract(self
, url
):
61 artist_slug
, music_slug
= self
._match
_valid
_url
(url
).groups()
62 artist_fields
= self
._ARTIST
_FIELDS
_TMPL
% music_slug
63 music
= self
._call
_api
(artist_slug
, artist_fields
)['artist']['music']
64 return self
._parse
_music
(music
)
67 class PalcoMP3IE(PalcoMP3BaseIE
):
68 IE_NAME
= 'PalcoMP3:song'
69 _VALID_URL
= r
'https?://(?:www\.)?palcomp3\.com(?:\.br)?/(?P<artist>[^/]+)/(?P<id>[^/?&#]+)'
71 'url': 'https://www.palcomp3.com/maiaraemaraisaoficial/nossas-composicoes-cuida-bem-dela/',
72 'md5': '99fd6405b2d8fd589670f6db1ba3b358',
76 'title': 'Nossas Composições - CUIDA BEM DELA',
83 def suitable(cls
, url
):
84 return False if PalcoMP3VideoIE
.suitable(url
) else super().suitable(url
)
87 class PalcoMP3ArtistIE(PalcoMP3BaseIE
):
88 IE_NAME
= 'PalcoMP3:artist'
89 _VALID_URL
= r
'https?://(?:www\.)?palcomp3\.com(?:\.br)?/(?P<id>[^/?&#]+)'
91 'url': 'https://www.palcomp3.com.br/condedoforro/',
94 'title': 'Conde do Forró',
96 'playlist_mincount': 188,
98 _ARTIST_FIELDS_TMPL
= '''artistID
107 def suitable(cls
, url
):
108 return False if PalcoMP3IE
._match
_valid
_url
(url
) else super().suitable(url
)
110 def _real_extract(self
, url
):
111 artist_slug
= self
._match
_id
(url
)
112 artist
= self
._call
_api
(artist_slug
, self
._ARTIST
_FIELDS
_TMPL
)['artist']
115 for music
in (try_get(artist
, lambda x
: x
['musics']['nodes'], list) or []):
116 yield self
._parse
_music
(music
)
118 return self
.playlist_result(
119 entries(), str_or_none(artist
.get('artistID')), artist
.get('name'))
122 class PalcoMP3VideoIE(PalcoMP3BaseIE
):
123 IE_NAME
= 'PalcoMP3:video'
124 _VALID_URL
= r
'https?://(?:www\.)?palcomp3\.com(?:\.br)?/(?P<artist>[^/]+)/(?P<id>[^/?&#]+)/?#clipe'
126 'url': 'https://www.palcomp3.com/maiaraemaraisaoficial/maiara-e-maraisa-voce-faz-falta-aqui-ao-vivo-em-vicosa-mg/#clipe',
127 'add_ie': ['Youtube'],
131 'title': 'Maiara e Maraisa - Você Faz Falta Aqui - DVD Ao Vivo Em Campo Grande',
132 'description': 'md5:7043342c09a224598e93546e98e49282',
133 'upload_date': '20161107',
134 'uploader_id': 'maiaramaraisaoficial',
135 'uploader': 'Maiara e Maraisa',
138 _MUSIC_FIELDS
= 'youtubeID'
140 def _parse_music(self
, music
):
141 youtube_id
= music
['youtubeID']
142 return self
.url_result(youtube_id
, 'Youtube', youtube_id
)