]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/beatportpro.py
3c7775d3e2762bef7f9424ffa769346dae2d577f
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
8 from ..utils
import int_or_none
11 class BeatportProIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://pro\.beatport\.com/track/(?P<display_id>[^/]+)/(?P<id>[0-9]+)'
14 'url': 'https://pro.beatport.com/track/synesthesia-original-mix/5379371',
15 'md5': 'b3c34d8639a2f6a7f734382358478887',
18 'display_id': 'synesthesia-original-mix',
20 'title': 'Froxic - Synesthesia (Original Mix)',
23 'url': 'https://pro.beatport.com/track/love-and-war-original-mix/3756896',
24 'md5': 'e44c3025dfa38c6577fbaeb43da43514',
27 'display_id': 'love-and-war-original-mix',
29 'title': 'Wolfgang Gartner - Love & War (Original Mix)',
32 'url': 'https://pro.beatport.com/track/birds-original-mix/4991738',
33 'md5': 'a1fd8e8046de3950fd039304c186c05f',
36 'display_id': 'birds-original-mix',
38 'title': "Tos, Middle Milk, Mumblin' Johnsson - Birds (Original Mix)",
42 def _real_extract(self
, url
):
43 mobj
= re
.match(self
._VALID
_URL
, url
)
44 track_id
= mobj
.group('id')
45 display_id
= mobj
.group('display_id')
47 webpage
= self
._download
_webpage
(url
, display_id
)
49 playables
= self
._parse
_json
(
51 r
'window\.Playables\s*=\s*({.+?});', webpage
,
52 'playables info', flags
=re
.DOTALL
),
55 track
= next(t
for t
in playables
['tracks'] if t
['id'] == int(track_id
))
57 title
= ', '.join((a
['name'] for a
in track
['artists'])) + ' - ' + track
['name']
59 title
+= ' (' + track
['mix'] + ')'
62 for ext
, info
in track
['preview'].items():
82 self
._sort
_formats
(formats
)
85 for name
, info
in track
['images'].items():
86 image_url
= info
.get('url')
87 if name
== 'dynamic' or not image_url
:
92 'height': int_or_none(info
.get('height')),
93 'width': int_or_none(info
.get('width')),
98 'id': compat_str(track
.get('id')) or track_id
,
99 'display_id': track
.get('slug') or display_id
,
102 'thumbnails': images
,