]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/beatportpro.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
10 class BeatportProIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://pro\.beatport\.com/track/.*/(?P<id>[0-9]+)'
13 'url': 'https://pro.beatport.com/track/synesthesia-original-mix/5379371',
14 'md5': 'b3c34d8639a2f6a7f734382358478887',
17 'display-id': 'synesthesia-original-mix',
19 'title': 'Froxic - Synesthesia (Original Mix)',
22 'url': 'https://pro.beatport.com/track/love-and-war-original-mix/3756896',
23 'md5': 'e44c3025dfa38c6577fbaeb43da43514',
26 'display-id': 'love-and-war-original-mix',
28 'title': 'Wolfgang Gartner - Love & War (Original Mix)',
31 'url': 'https://pro.beatport.com/track/birds-original-mix/4991738',
32 'md5': 'a1fd8e8046de3950fd039304c186c05f',
35 'display-id': 'birds-original-mix',
37 'title': "Tos, Middle Milk, Mumblin' Johnsson - Birds (Original Mix)",
41 def _real_extract(self
, url
):
42 track_id
= self
._match
_id
(url
)
43 webpage
= self
._download
_webpage
(url
, track_id
)
45 # Extract "Playables" JSON information from the page
46 playables
= self
._search
_regex
(r
'window\.Playables = ({.*?});', webpage
,
47 'playables info', flags
=re
.DOTALL
)
48 playables
= json
.loads(playables
)
50 # Find first track with matching ID (always the first one listed?)
51 track
= next(filter(lambda t
: t
['id'] == int(track_id
), playables
['tracks']))
53 # Construct title from artist(s), track name, and mix name
54 title
= ', '.join((a
['name'] for a
in track
['artists'])) + ' - ' + track
['name']
56 title
+= ' (' + track
['mix'] + ')'
58 # Get format information
60 for ext
, info
in track
['preview'].items():
61 if info
['url'] is None:
80 formats
.sort(key
=lambda f
: f
['preference'])
82 # Get album art as thumbnails
84 for name
, info
in track
['images'].items():
85 if name
== 'dynamic' or info
['url'] is None:
90 'height': info
['height'],
91 'width': info
['width'],
97 'display-id': track
['slug'],