]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/moevideo.py
2ff79b9b88590e87f1aecf9fdfd32f242bd98420
   2 from __future__ 
import unicode_literals
 
   7 from .common 
import InfoExtractor
 
  11     compat_urllib_request
, 
  16 class MoeVideoIE(InfoExtractor
): 
  17     IE_DESC 
= 'LetitBit video services: moevideo.net, playreplay.net and videochart.net' 
  19         https?://(?P<host>(?:www\.)? 
  20         (?:(?:moevideo|playreplay|videochart)\.net))/ 
  21         (?:video|framevideo)/(?P<id>[0-9]+\.[0-9A-Za-z]+)''' 
  22     _API_URL 
= 'http://api.letitbit.net/' 
  23     _API_KEY 
= 'tVL0gjqo5' 
  26             'url': 'http://moevideo.net/video/00297.0036103fe3d513ef27915216fd29', 
  27             'md5': '129f5ae1f6585d0e9bb4f38e774ffb3a', 
  29                 'id': '00297.0036103fe3d513ef27915216fd29', 
  31                 'title': 'Sink cut out machine', 
  32                 'description': 'md5:f29ff97b663aefa760bf7ca63c8ca8a8', 
  33                 'thumbnail': 're:^https?://.*\.jpg$', 
  41             'url': 'http://playreplay.net/video/77107.7f325710a627383d40540d8e991a', 
  42             'md5': '74f0a014d5b661f0f0e2361300d1620e', 
  44                 'id': '77107.7f325710a627383d40540d8e991a', 
  46                 'title': 'Operacion Condor.', 
  47                 'description': 'md5:7e68cb2fcda66833d5081c542491a9a3', 
  48                 'thumbnail': 're:^https?://.*\.jpg$', 
  52                 'filesize': 588257923, 
  57     def _real_extract(self
, url
): 
  58         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  59         video_id 
= mobj
.group('id') 
  61         webpage 
= self
._download
_webpage
( 
  62             'http://%s/video/%s' % (mobj
.group('host'), video_id
), 
  63             video_id
, 'Downloading webpage') 
  65         title 
= self
._og
_search
_title
(webpage
) 
  66         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  67         description 
= self
._og
_search
_description
(webpage
) 
  78         r_json 
= json
.dumps(r
) 
  79         post 
= compat_urllib_parse
.urlencode({'r': r_json
}) 
  80         req 
= compat_urllib_request
.Request(self
._API
_URL
, post
) 
  81         req
.add_header('Content-type', 'application/x-www-form-urlencoded') 
  83         response 
= self
._download
_json
(req
, video_id
) 
  84         if response
['status'] != 'OK': 
  86                 '%s returned error: %s' % (self
.IE_NAME
, response
['data']), 
  89         item 
= response
['data'][0] 
  90         video_url 
= item
['link'] 
  91         duration 
= int_or_none(item
['length']) 
  92         width 
= int_or_none(item
['width']) 
  93         height 
= int_or_none(item
['height']) 
  94         filesize 
= int_or_none(item
['convert_size']) 
  98             'http_headers': {'Range': 'bytes=0-'},  # Required to download 
 102             'filesize': filesize
, 
 108             'thumbnail': thumbnail
, 
 109             'description': description
, 
 110             'duration': duration
,