]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tunepk.py
   1 from __future__ 
import unicode_literals
 
   3 from .common 
import InfoExtractor
 
   4 from ..compat 
import compat_str
 
  12 class TunePkIE(InfoExtractor
): 
  16                             (?:www\.)?tune\.pk/(?:video/|player/embed_player.php?.*?\bvid=)| 
  22         'url': 'https://tune.pk/video/6919541/maudie-2017-international-trailer-1-ft-ethan-hawke-sally-hawkins', 
  23         'md5': '0c537163b7f6f97da3c5dd1e3ef6dd55', 
  27             'title': 'Maudie (2017) | International Trailer # 1 ft Ethan Hawke, Sally Hawkins', 
  28             'description': 'md5:eb5a04114fafef5cec90799a93a2d09c', 
  29             'thumbnail': r
're:^https?://.*\.jpg$', 
  30             'timestamp': 1487327564, 
  31             'upload_date': '20170217', 
  32             'uploader': 'Movie Trailers', 
  37         'url': 'https://tune.pk/player/embed_player.php?vid=6919541&folder=2017/02/17/&width=600&height=350&autoplay=no', 
  38         'only_matching': True, 
  40         'url': 'https://embed.tune.pk/play/6919541?autoplay=no&ssl=yes&inline=true', 
  41         'only_matching': True, 
  44     def _real_extract(self
, url
): 
  45         video_id 
= self
._match
_id
(url
) 
  47         webpage 
= self
._download
_webpage
( 
  48             'https://tune.pk/video/%s' % video_id
, video_id
) 
  50         details 
= self
._parse
_json
( 
  52                 r
'new\s+TunePlayer\(({.+?})\)\s*;\s*\n', webpage
, 'tune player'), 
  55         video 
= details
['video'] 
  56         title 
= video
.get('title') or self
._og
_search
_title
( 
  57             webpage
, default
=None) or self
._html
_search
_meta
( 
  58             'title', webpage
, 'title', fatal
=True) 
  60         formats 
= self
._parse
_jwplayer
_formats
( 
  61             details
['player']['sources'], video_id
) 
  62         self
._sort
_formats
(formats
) 
  64         description 
= self
._og
_search
_description
( 
  65             webpage
, default
=None) or self
._html
_search
_meta
( 
  66             'description', webpage
, 'description') 
  68         thumbnail 
= video
.get('thumb') or self
._og
_search
_thumbnail
( 
  69             webpage
, default
=None) or self
._html
_search
_meta
( 
  70             'thumbnail', webpage
, 'thumbnail') 
  72         timestamp 
= unified_timestamp(video
.get('date_added')) 
  74             video
, lambda x
: x
['uploader']['name'], 
  75             compat_str
) or self
._html
_search
_meta
('author', webpage
, 'author') 
  77         duration 
= int_or_none(video
.get('duration')) 
  78         view_count 
= int_or_none(video
.get('views')) 
  83             'description': description
, 
  84             'thumbnail': thumbnail
, 
  85             'timestamp': timestamp
, 
  88             'view_count': view_count
,