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