]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/audiomack.py
eeeec768fe302a508008e095f138690477594553
2 from __future__
import unicode_literals
4 from . common
import InfoExtractor
5 from . soundcloud
import SoundcloudIE
6 from .. utils
import ExtractorError
11 class AudiomackIE ( InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?audiomack\.com/song/(?P<id>[\w/-]+)'
17 'url' : 'http://www.audiomack.com/song/roosh-williams/extraordinary' ,
20 'id' : 'roosh-williams/extraordinary' ,
22 'title' : 'Roosh Williams - Extraordinary'
25 # hosted on soundcloud via audiomack
27 'url' : 'http://www.audiomack.com/song/xclusiveszone/take-kare' ,
28 'file' : '172419696.mp3' ,
32 'title' : 'Young Thug ft Lil Wayne - Take Kare' ,
33 "upload_date" : "20141016" ,
34 "description" : "New track produced by London On Da Track called “Take Kare \"\n\n http://instagram.com/theyoungthugworld \n https://www.facebook.com/ThuggerThuggerCashMoney \n " ,
35 "uploader" : "Young Thug World"
40 def _real_extract ( self
, url
):
41 video_id
= self
._ match
_ id
( url
)
43 api_response
= self
._ download
_ json
(
44 "http://www.audiomack.com/api/music/url/song/ %s ?_= %d " % (
45 video_id
, time
. time ()),
48 if "url" not in api_response
:
49 raise ExtractorError ( "Unable to deduce api url of song" )
50 realurl
= api_response
[ "url" ]
52 # Audiomack wraps a lot of soundcloud tracks in their branded wrapper
53 # - if so, pass the work off to the soundcloud extractor
54 if SoundcloudIE
. suitable ( realurl
):
55 return { '_type' : 'url' , 'url' : realurl
, 'ie_key' : 'Soundcloud' }
57 webpage
= self
._ download
_ webpage
( url
, video_id
)
58 artist
= self
._ html
_ search
_ regex
(
59 r
'<span class="artist">(.*?)</span>' , webpage
, "artist" )
60 songtitle
= self
._ html
_ search
_ regex
(
61 r
'<h1 class="profile-title song-title"><span class="artist">.*?</span>(.*?)</h1>' ,
63 title
= artist
+ " - " + songtitle