]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/lnkgo.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class LnkGoIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?lnkgo\.alfa\.lt/visi\-video/(?P<show>[^/]+)/ziurek\-(?P<display_id>[A-Za-z0-9\-]+)'
17 'url': 'http://lnkgo.alfa.lt/visi-video/yra-kaip-yra/ziurek-yra-kaip-yra-162',
21 'title': 'Yra kaip yra',
22 'upload_date': '20150107',
23 'description': 'md5:d82a5e36b775b7048617f263a0e3475e',
26 'thumbnail': 're:^https?://.*\.jpg$'
29 'skip_download': True, # HLS download
32 'url': 'http://lnkgo.alfa.lt/visi-video/aktualai-pratesimas/ziurek-nerdas-taiso-kompiuteri-2',
36 'title': 'Nėrdas: Kompiuterio Valymas',
37 'upload_date': '20150113',
38 'description': 'md5:7352d113a242a808676ff17e69db6a69',
41 'thumbnail': 're:^https?://.*\.jpg$'
44 'skip_download': True, # HLS download
53 def _real_extract(self
, url
):
54 mobj
= re
.match(self
._VALID
_URL
, url
)
55 display_id
= mobj
.group('display_id')
57 webpage
= self
._download
_webpage
(
58 url
, display_id
, 'Downloading player webpage')
60 video_id
= self
._search
_regex
(
61 r
'data-ep="([^"]+)"', webpage
, 'video ID')
62 title
= self
._og
_search
_title
(webpage
)
63 description
= self
._og
_search
_description
(webpage
)
65 thumbnail_w
= int_or_none(
66 self
._og
_search
_property
('image:width', webpage
, 'thumbnail width', fatal
=False))
67 thumbnail_h
= int_or_none(
68 self
._og
_search
_property
('image:height', webpage
, 'thumbnail height', fatal
=False))
70 'url': self
._og
_search
_thumbnail
(webpage
),
72 if thumbnail_w
and thumbnail_h
:
75 'height': thumbnail_h
,
78 upload_date
= unified_strdate(self
._search
_regex
(
79 r
'class="meta-item\sair-time">.*?<strong>([^<]+)</strong>', webpage
, 'upload date', fatal
=False))
80 duration
= int_or_none(self
._search
_regex
(
81 r
'VideoDuration = "([^"]+)"', webpage
, 'duration', fatal
=False))
83 pg_rating
= self
._search
_regex
(
84 r
'pgrating="([^"]+)"', webpage
, 'PG rating', fatal
=False, default
='')
85 age_limit
= self
._AGE
_LIMITS
.get(pg_rating
.upper(), 0)
87 sources_js
= self
._search
_regex
(
88 r
'(?s)sources:\s(\[.*?\]),', webpage
, 'sources')
89 sources
= self
._parse
_json
(
90 sources_js
, video_id
, transform_source
=js_to_json
)
93 for source
in sources
:
94 if source
.get('provider') == 'rtmp':
95 m
= re
.search(r
'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<play_path>.+)$', source
['file'])
101 'url': m
.group('url'),
102 'play_path': m
.group('play_path'),
105 elif source
.get('file').endswith('.m3u8'):
108 'ext': source
.get('type', 'mp4'),
109 'url': source
['file'],
112 self
._sort
_formats
(formats
)
116 'display_id': display_id
,
119 'thumbnails': [thumbnail
],
120 'duration': duration
,
121 'description': description
,
122 'age_limit': age_limit
,
123 'upload_date': upload_date
,