]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/playfm.py
ebc0468042a22c2bccdfb5b7e45861c0bc45f61c
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
17 class PlayFMIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:www\.)?play\.fm/[^?#]*(?P<upload_date>[0-9]{8})(?P<id>[0-9]{6})(?:$|[?#])'
22 'url': 'http://www.play.fm/recording/leipzigelectronicmusicbatofarparis_fr20140712137220',
23 'md5': 'c505f8307825a245d0c7ad1850001f22',
27 'title': 'LEIPZIG ELECTRONIC MUSIC @ Batofar (Paris,FR) - 2014-07-12',
28 'uploader': 'Sven Tasnadi',
29 'uploader_id': 'sventasnadi',
31 'upload_date': '20140712',
34 'thumbnail': 're:^https?://.*\.jpg$',
38 def _real_extract(self
, url
):
39 mobj
= re
.match(self
._VALID
_URL
, url
)
40 video_id
= mobj
.group('id')
41 upload_date
= mobj
.group('upload_date')
43 rec_data
= compat_urllib_parse
.urlencode({'rec_id': video_id
})
44 req
= compat_urllib_request
.Request(
45 'http://www.play.fm/flexRead/recording', data
=rec_data
)
46 req
.add_header('Content-Type', 'application/x-www-form-urlencoded')
47 rec_doc
= self
._download
_xml
(req
, video_id
)
49 error_node
= rec_doc
.find('./error')
50 if error_node
is not None:
51 raise ExtractorError('An error occured: %s (code %s)' % (
52 error_node
.text
, rec_doc
.find('./status').text
))
54 recording
= rec_doc
.find('./recording')
55 title
= recording
.find('./title').text
56 view_count
= str_to_int(recording
.find('./stats/playcount').text
)
57 comment_count
= str_to_int(recording
.find('./stats/comments').text
)
58 duration
= float_or_none(recording
.find('./duration').text
, scale
=1000)
59 thumbnail
= recording
.find('./image').text
61 artist
= recording
.find('./artists/artist')
62 uploader
= artist
.find('./name').text
63 uploader_id
= artist
.find('./slug').text
65 video_url
= '%s//%s/%s/%s/offset/0/sh/%s/rec/%s/jingle/%s/loc/%s' % (
66 'http:', recording
.find('./url').text
,
67 recording
.find('./_class').text
, recording
.find('./file_id').text
,
68 rec_doc
.find('./uuid').text
, video_id
,
69 rec_doc
.find('./jingle/file_id').text
,
70 'http%3A%2F%2Fwww.play.fm%2Fplayer',
77 'filesize': int_or_none(recording
.find('./size').text
),
79 'upload_date': upload_date
,
80 'view_count': view_count
,
81 'comment_count': comment_count
,
83 'thumbnail': thumbnail
,
85 'uploader_id': uploader_id
,