Add PalcoMP3 Video extractor
This commit is contained in:
parent
2c7edaf8f6
commit
da47b154b8
@ -746,7 +746,9 @@ from .packtpub import (
|
||||
PacktPubCourseIE,
|
||||
)
|
||||
from .palcomp3 import (
|
||||
PalcoMP3IE
|
||||
PalcoMP3IE,
|
||||
PalcoMP3ArtistIE,
|
||||
PalcoMP3VideoIE,
|
||||
)
|
||||
from .pandatv import PandaTVIE
|
||||
from .pandoratv import PandoraTVIE
|
||||
|
@ -11,7 +11,8 @@ from .common import InfoExtractor
|
||||
from pprint import pprint as pp
|
||||
|
||||
class PalcoMP3IE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?palcomp3\.com/(?P<artist>[^/]+)/(?P<id>[^/]+)'
|
||||
IE_NAME = 'PalcoMP3:song'
|
||||
_VALID_URL = r'https?://(?:www\.)?palcomp3\.com/(?P<artist>[^/]+)/(?P<id>[^/]+)/?$'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.palcomp3.com/maiaraemaraisaoficial/nossas-composicoes-cuida-bem-dela/',
|
||||
'md5': '99fd6405b2d8fd589670f6db1ba3b358',
|
||||
@ -23,7 +24,7 @@ class PalcoMP3IE(InfoExtractor):
|
||||
'thumbnail': r'https://studiosol-a.akamaihd.net/tb/80x60/palcomp3-logo/9/d/f/c/356447_20170324175145.jpg',
|
||||
}},
|
||||
{
|
||||
'url': 'https://www.palcomp3.com/maiaraemaraisaoficial/niveis-da-bebida/',
|
||||
'url': 'https://www.palcomp3.com/maiaraemaraisaoficial/niveis-da-bebida',
|
||||
'md5': '4c4d1e45b5ae49396cfff017eb41cdd9',
|
||||
'info_dict': {
|
||||
'id': '2303899',
|
||||
@ -40,19 +41,27 @@ class PalcoMP3IE(InfoExtractor):
|
||||
`_json_ld` function does not fit us."""
|
||||
return self._parse_json(json_ld, display_id, fatal=fatal)
|
||||
|
||||
def _real_extract(self, url):
|
||||
display_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, display_id)
|
||||
print ("Webpage", type(webpage), len(webpage))
|
||||
|
||||
ld = self._get_ld_info(webpage, display_id)
|
||||
def _extract_common(self, url):
|
||||
artist_id = self._VALID_URL_RE.match(url).group('artist')
|
||||
webpage = self._download_webpage(url, artist_id)
|
||||
print ("Webpage", type(webpage), len(webpage))
|
||||
self.webpage = webpage
|
||||
|
||||
ld = self._get_ld_info(webpage, artist_id)
|
||||
tracks = [ self._ld_track_process(track, ld) for track in ld['track'] ]
|
||||
|
||||
# from IPython import embed
|
||||
# embed()
|
||||
|
||||
return tracks, ld, webpage
|
||||
|
||||
def _real_extract(self, url, with_webpage=False):
|
||||
display_id = self._match_id(url)
|
||||
tracks, ld, webpage = self._extract_common(url)
|
||||
for track in tracks:
|
||||
if track['display_id'] == display_id:
|
||||
return track
|
||||
if with_webpage:
|
||||
return track, webpage
|
||||
else:
|
||||
return track
|
||||
|
||||
|
||||
def _get_ld_info(self, webpage, display_id):
|
||||
@ -80,4 +89,93 @@ class PalcoMP3IE(InfoExtractor):
|
||||
'display_id': track['url'].split('/')[-2],
|
||||
'duration': int(tmin)*60 + int(tsec),
|
||||
'genre': ld['genre'],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PalcoMP3ArtistIE(PalcoMP3IE):
|
||||
IE_NAME = 'PalcoMP3:artist'
|
||||
_VALID_URL = r'https?://(?:www\.)?palcomp3\.com/(?P<artist>[^/]+)/?$'
|
||||
_TESTS = [
|
||||
{
|
||||
'url': 'https://www.palcomp3.com/maiaraemaraisaoficial',
|
||||
'info_dict': {
|
||||
'id': 'maiaraemaraisaoficial',
|
||||
'title': 'Maiara e Maraisa Oficial',
|
||||
},
|
||||
'playlist_count': 8,
|
||||
},
|
||||
{
|
||||
'url': 'https://www.palcomp3.com/banda5cha/',
|
||||
'info_dict': {
|
||||
'id': 'banda5cha',
|
||||
'title': '5Chá',
|
||||
},
|
||||
'playlist_count': 2,
|
||||
},
|
||||
]
|
||||
|
||||
def _real_extract(self, url):
|
||||
tracks, ld, _ = self._extract_common(url)
|
||||
return self.playlist_result(tracks, ld['name'], ld['description'])
|
||||
|
||||
|
||||
class PalcoMP3VideoIE(PalcoMP3IE):
|
||||
IE_NAME = 'PalcoMP3:video'
|
||||
_VALID_URL = r'https?://(?:www\.)?palcomp3\.com/(?P<artist>[^/]+)/(?P<id>[^/]+)/#clipe$'
|
||||
_TESTS = [
|
||||
{
|
||||
'url': 'https://www.palcomp3.com/maiaraemaraisaoficial/maiara-e-maraisa-voce-faz-falta-aqui-ao-vivo-em-vicosa-mg/#clipe',
|
||||
'add_ie': ['Youtube'],
|
||||
'info_dict': {
|
||||
'id': '_pD1nR2qqPg',
|
||||
'ext': 'mp4',
|
||||
'title': 'Maiara e Maraisa - Você Faz Falta Aqui - DVD Ao Vivo Em Campo Grande',
|
||||
'description': 'md5:739d585d094212b999e507377daa21de',
|
||||
'upload_date': '20161107',
|
||||
'uploader_id': 'maiaramaraisaoficial',
|
||||
'uploader': 'Maiara e Maraisa',
|
||||
}},
|
||||
{
|
||||
'url': 'https://www.palcomp3.com/mckevinho/dog-vagabundo-mc-phe-cachorrera-part-mc-kevinho/#clipe',
|
||||
'add_ie': ['Youtube'],
|
||||
'info_dict': {
|
||||
'id': 'iKVAfp6-o-Q',
|
||||
'ext': 'mp4',
|
||||
'title': 'MC Phe Cachorrera e MC Kevinho - Dog Vagabundo (Video Clipe) Jorgin Deejhay / HDUC ep.2',
|
||||
'description': 'md5:728024b6905a9a321c8c16e1e1985e56',
|
||||
'upload_date': '20170208',
|
||||
'uploader': 'GR6 EXPLODE',
|
||||
'uploader_id': 'gr6explode',
|
||||
}},
|
||||
]
|
||||
|
||||
def _real_extract(self, url):
|
||||
track, webpage = super(PalcoMP3VideoIE, self)._real_extract(url, with_webpage=True)
|
||||
print "TRACK"
|
||||
pp(track)
|
||||
|
||||
video_re = r"""
|
||||
(?x)
|
||||
<li (.*?) data-id="{}" (.*?)
|
||||
data-id-video="(?P<video_id>[^"]+?)"
|
||||
(.*?) >
|
||||
<a (.*?) href="([^"]*?)">
|
||||
<span>([^<]*?)</span></a></li>
|
||||
""".format(track['id'])
|
||||
|
||||
m = re.search(video_re, webpage)
|
||||
|
||||
# from IPython import embed
|
||||
# embed()
|
||||
|
||||
if not m:
|
||||
return None
|
||||
|
||||
video_id = m.group('video_id')
|
||||
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'ie_key': 'Youtube',
|
||||
'id': video_id,
|
||||
'url': video_id,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user