]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/podomatic.py
   1 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..utils 
import int_or_none
 
   9 class PodomaticIE(InfoExtractor
): 
  11     _VALID_URL 
= r
'^(?P<proto>https?)://(?P<channel>[^.]+)\.podomatic\.com/entry/(?P<id>[^?]+)' 
  15             'url': 'http://scienceteachingtips.podomatic.com/entry/2009-01-02T16_03_35-08_00', 
  16             'md5': '84bb855fcf3429e6bf72460e1eed782d', 
  18                 'id': '2009-01-02T16_03_35-08_00', 
  20                 'uploader': 'Science Teaching Tips', 
  21                 'uploader_id': 'scienceteachingtips', 
  22                 'title': '64.  When the Moon Hits Your Eye', 
  27             'url': 'http://ostbahnhof.podomatic.com/entry/2013-11-15T16_31_21-08_00', 
  28             'md5': 'd2cf443931b6148e27638650e2638297', 
  30                 'id': '2013-11-15T16_31_21-08_00', 
  32                 'uploader': 'Ostbahnhof / Techno Mix', 
  33                 'uploader_id': 'ostbahnhof', 
  34                 'title': 'Einunddreizig', 
  40     def _real_extract(self
, url
): 
  41         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  42         video_id 
= mobj
.group('id') 
  43         channel 
= mobj
.group('channel') 
  45         json_url 
= (('%s://%s.podomatic.com/entry/embed_params/%s' + 
  46                      '?permalink=true&rtmp=0') % 
  47                     (mobj
.group('proto'), channel
, video_id
)) 
  48         data_json 
= self
._download
_webpage
( 
  49             json_url
, video_id
, 'Downloading video info') 
  50         data 
= json
.loads(data_json
) 
  52         video_url 
= data
['downloadLink'] 
  54             video_url 
= '%s/%s' % (data
['streamer'].replace('rtmp', 'http'), data
['mediaLocation']) 
  55         uploader 
= data
['podcast'] 
  57         thumbnail 
= data
['imageLocation'] 
  58         duration 
= int_or_none(data
.get('length'), 1000) 
  65             'uploader_id': channel
, 
  66             'thumbnail': thumbnail
,