]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/playfm.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class PlayFMIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?play\.fm/[^?#]*(?P<upload_date>[0-9]{8})(?P<id>[0-9]{6})(?:$|[?#])'
21 'url': 'http://www.play.fm/recording/leipzigelectronicmusicbatofarparis_fr20140712137220',
22 'md5': 'c505f8307825a245d0c7ad1850001f22',
26 'title': 'LEIPZIG ELECTRONIC MUSIC @ Batofar (Paris,FR) - 2014-07-12',
27 'uploader': 'Sven Tasnadi',
28 'uploader_id': 'sventasnadi',
30 'upload_date': '20140712',
32 'thumbnail': 're:^https?://.*\.jpg$',
36 def _real_extract(self
, url
):
37 mobj
= re
.match(self
._VALID
_URL
, url
)
38 video_id
= mobj
.group('id')
39 upload_date
= mobj
.group('upload_date')
41 rec_data
= compat_urllib_parse
.urlencode({'rec_id': video_id}
)
42 req
= compat_urllib_request
.Request(
43 'http://www.play.fm/flexRead/recording', data
=rec_data
)
44 req
.add_header('Content-Type', 'application/x-www-form-urlencoded')
45 rec_doc
= self
._download
_xml
(req
, video_id
)
47 error_node
= rec_doc
.find('./error')
48 if error_node
is not None:
49 raise ExtractorError('An error occured: %s (code %s)' % (
50 error_node
.text
, rec_doc
.find('./status').text
))
52 recording
= rec_doc
.find('./recording')
53 title
= recording
.find('./title').text
54 view_count
= int_or_none(recording
.find('./stats/playcount').text
)
55 duration
= float_or_none(recording
.find('./duration').text
, scale
=1000)
56 thumbnail
= recording
.find('./image').text
58 artist
= recording
.find('./artists/artist')
59 uploader
= artist
.find('./name').text
60 uploader_id
= artist
.find('./slug').text
62 video_url
= '%s//%s/%s/%s/offset/0/sh/%s/rec/%s/jingle/%s/loc/%s' % (
63 'http:', recording
.find('./url').text
,
64 recording
.find('./_class').text
, recording
.find('./file_id').text
,
65 rec_doc
.find('./uuid').text
, video_id
,
66 rec_doc
.find('./jingle/file_id').text
,
67 'http%3A%2F%2Fwww.play.fm%2Fplayer',
74 'filesize': int_or_none(recording
.find('./size').text
),
76 'upload_date': upload_date
,
77 'view_count': view_count
,
79 'thumbnail': thumbnail
,
81 'uploader_id': uploader_id
,