3 from .common
import InfoExtractor
4 from ..utils
import int_or_none
7 class BeatportIE(InfoExtractor
):
8 _VALID_URL
= r
'https?://(?:www\.|pro\.)?beatport\.com/track/(?P<display_id>[^/]+)/(?P<id>[0-9]+)'
10 'url': 'https://beatport.com/track/synesthesia-original-mix/5379371',
11 'md5': 'b3c34d8639a2f6a7f734382358478887',
14 'display_id': 'synesthesia-original-mix',
16 'title': 'Froxic - Synesthesia (Original Mix)',
19 'url': 'https://beatport.com/track/love-and-war-original-mix/3756896',
20 'md5': 'e44c3025dfa38c6577fbaeb43da43514',
23 'display_id': 'love-and-war-original-mix',
25 'title': 'Wolfgang Gartner - Love & War (Original Mix)',
28 'url': 'https://beatport.com/track/birds-original-mix/4991738',
29 'md5': 'a1fd8e8046de3950fd039304c186c05f',
32 'display_id': 'birds-original-mix',
34 'title': "Tos, Middle Milk, Mumblin' Johnsson - Birds (Original Mix)",
38 def _real_extract(self
, url
):
39 mobj
= self
._match
_valid
_url
(url
)
40 track_id
= mobj
.group('id')
41 display_id
= mobj
.group('display_id')
43 webpage
= self
._download
_webpage
(url
, display_id
)
45 playables
= self
._parse
_json
(
47 r
'window\.Playables\s*=\s*({.+?});', webpage
,
48 'playables info', flags
=re
.DOTALL
),
51 track
= next(t
for t
in playables
['tracks'] if t
['id'] == int(track_id
))
53 title
= ', '.join(a
['name'] for a
in track
['artists']) + ' - ' + track
['name']
55 title
+= ' (' + track
['mix'] + ')'
58 for ext
, info
in track
['preview'].items():
78 for name
, info
in track
['images'].items():
79 image_url
= info
.get('url')
80 if name
== 'dynamic' or not image_url
:
85 'height': int_or_none(info
.get('height')),
86 'width': int_or_none(info
.get('width')),
91 'id': str(track
.get('id')) or track_id
,
92 'display_id': track
.get('slug') or display_id
,