]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tvplay.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class TVPlayIE(InfoExtractor
):
15 _VALID_URL
= r
'http://(?:www\.)?tvplay\.lv/parraides/[^/]+/(?P<id>\d+)'
18 'url': 'http://www.tvplay.lv/parraides/vinas-melo-labak/418113?autostart=true',
22 'title': 'Kādi ir īri? - Viņas melo labāk',
23 'description': 'Baiba apsmej īrus, kādi tie ir un ko viņi dara.',
25 'timestamp': 1406097056,
26 'upload_date': '20140723',
30 'skip_download': True,
35 def _real_extract(self
, url
):
36 mobj
= re
.match(self
._VALID
_URL
, url
)
37 video_id
= mobj
.group('id')
39 video
= self
._download
_json
(
40 'http://playapi.mtgx.tv/v1/videos/%s' % video_id
, video_id
, 'Downloading video JSON')
42 if video
['is_geo_blocked']:
44 'This content is not available in your country due to copyright reasons', expected
=True)
46 streams
= self
._download
_json
(
47 'http://playapi.mtgx.tv/v1/videos/stream/%s' % video_id
, video_id
, 'Downloading streams JSON')
49 quality
= qualities(['hls', 'medium', 'high'])
51 for format_id
, video_url
in streams
['streams'].items():
55 'format_id': format_id
,
56 'preference': quality(format_id
),
58 if video_url
.startswith('rtmp'):
59 m
= re
.search(r
'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url
)
64 'url': m
.group('url'),
65 'app': m
.group('app'),
66 'play_path': m
.group('playpath'),
74 self
._sort
_formats
(formats
)
78 'title': video
['title'],
79 'description': video
['description'],
80 'duration': video
['duration'],
81 'timestamp': parse_iso8601(video
['created_at']),
82 'view_count': video
['views']['total'],
83 'age_limit': video
.get('age_limit', 0),