3 from .common
import InfoExtractor
4 from ..compat
import compat_str
5 from ..utils
import int_or_none
8 class BeatportIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.|pro\.)?beatport\.com/track/(?P<display_id>[^/]+)/(?P<id>[0-9]+)'
11 'url': 'https://beatport.com/track/synesthesia-original-mix/5379371',
12 'md5': 'b3c34d8639a2f6a7f734382358478887',
15 'display_id': 'synesthesia-original-mix',
17 'title': 'Froxic - Synesthesia (Original Mix)',
20 'url': 'https://beatport.com/track/love-and-war-original-mix/3756896',
21 'md5': 'e44c3025dfa38c6577fbaeb43da43514',
24 'display_id': 'love-and-war-original-mix',
26 'title': 'Wolfgang Gartner - Love & War (Original Mix)',
29 'url': 'https://beatport.com/track/birds-original-mix/4991738',
30 'md5': 'a1fd8e8046de3950fd039304c186c05f',
33 'display_id': 'birds-original-mix',
35 'title': "Tos, Middle Milk, Mumblin' Johnsson - Birds (Original Mix)",
39 def _real_extract(self
, url
):
40 mobj
= self
._match
_valid
_url
(url
)
41 track_id
= mobj
.group('id')
42 display_id
= mobj
.group('display_id')
44 webpage
= self
._download
_webpage
(url
, display_id
)
46 playables
= self
._parse
_json
(
48 r
'window\.Playables\s*=\s*({.+?});', webpage
,
49 'playables info', flags
=re
.DOTALL
),
52 track
= next(t
for t
in playables
['tracks'] if t
['id'] == int(track_id
))
54 title
= ', '.join((a
['name'] for a
in track
['artists'])) + ' - ' + track
['name']
56 title
+= ' (' + track
['mix'] + ')'
59 for ext
, info
in track
['preview'].items():
79 for name
, info
in track
['images'].items():
80 image_url
= info
.get('url')
81 if name
== 'dynamic' or not image_url
:
86 'height': int_or_none(info
.get('height')),
87 'width': int_or_none(info
.get('width')),
92 'id': compat_str(track
.get('id')) or track_id
,
93 'display_id': track
.get('slug') or display_id
,