]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/lnkgo.py
debian/patches: Remove patch to disambiguate between ffmpeg and avconv.
[youtubedl] / youtube_dl / extractor / lnkgo.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8 int_or_none,
9 unified_strdate,
10 )
11
12
13 class LnkGoIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?lnkgo\.(?:alfa\.)?lt/visi-video/(?P<show>[^/]+)/ziurek-(?P<id>[A-Za-z0-9-]+)'
15 _TESTS = [{
16 'url': 'http://lnkgo.alfa.lt/visi-video/yra-kaip-yra/ziurek-yra-kaip-yra-162',
17 'info_dict': {
18 'id': '46712',
19 'ext': 'mp4',
20 'title': 'Yra kaip yra',
21 'upload_date': '20150107',
22 'description': 'md5:d82a5e36b775b7048617f263a0e3475e',
23 'age_limit': 7,
24 'duration': 3019,
25 'thumbnail': r're:^https?://.*\.jpg$'
26 },
27 'params': {
28 'skip_download': True, # HLS download
29 },
30 }, {
31 'url': 'http://lnkgo.alfa.lt/visi-video/aktualai-pratesimas/ziurek-nerdas-taiso-kompiuteri-2',
32 'info_dict': {
33 'id': '47289',
34 'ext': 'mp4',
35 'title': 'Nėrdas: Kompiuterio Valymas',
36 'upload_date': '20150113',
37 'description': 'md5:7352d113a242a808676ff17e69db6a69',
38 'age_limit': 18,
39 'duration': 346,
40 'thumbnail': r're:^https?://.*\.jpg$'
41 },
42 'params': {
43 'skip_download': True, # HLS download
44 },
45 }, {
46 'url': 'http://www.lnkgo.lt/visi-video/aktualai-pratesimas/ziurek-putka-trys-klausimai',
47 'only_matching': True,
48 }]
49 _AGE_LIMITS = {
50 'N-7': 7,
51 'N-14': 14,
52 'S': 18,
53 }
54
55 def _real_extract(self, url):
56 display_id = self._match_id(url)
57
58 webpage = self._download_webpage(
59 url, display_id, 'Downloading player webpage')
60
61 video_id = self._search_regex(
62 r'data-ep="([^"]+)"', webpage, 'video ID')
63 title = self._og_search_title(webpage)
64 description = self._og_search_description(webpage)
65 upload_date = unified_strdate(self._search_regex(
66 r'class="[^"]*meta-item[^"]*air-time[^"]*">.*?<strong>([^<]+)</strong>', webpage, 'upload date', fatal=False))
67
68 thumbnail_w = int_or_none(
69 self._og_search_property('image:width', webpage, 'thumbnail width', fatal=False))
70 thumbnail_h = int_or_none(
71 self._og_search_property('image:height', webpage, 'thumbnail height', fatal=False))
72 thumbnail = {
73 'url': self._og_search_thumbnail(webpage),
74 }
75 if thumbnail_w and thumbnail_h:
76 thumbnail.update({
77 'width': thumbnail_w,
78 'height': thumbnail_h,
79 })
80
81 config = self._parse_json(self._search_regex(
82 r'episodePlayer\((\{.*?\}),\s*\{', webpage, 'sources'), video_id)
83
84 if config.get('pGeo'):
85 self.report_warning(
86 'This content might not be available in your country due to copyright reasons')
87
88 formats = [{
89 'format_id': 'hls',
90 'ext': 'mp4',
91 'url': config['EpisodeVideoLink_HLS'],
92 }]
93
94 m = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<play_path>.+)$', config['EpisodeVideoLink'])
95 if m:
96 formats.append({
97 'format_id': 'rtmp',
98 'ext': 'flv',
99 'url': m.group('url'),
100 'play_path': m.group('play_path'),
101 'page_url': url,
102 })
103
104 self._sort_formats(formats)
105
106 return {
107 'id': video_id,
108 'display_id': display_id,
109 'title': title,
110 'formats': formats,
111 'thumbnails': [thumbnail],
112 'duration': int_or_none(config.get('VideoTime')),
113 'description': description,
114 'age_limit': self._AGE_LIMITS.get(config.get('PGRating'), 0),
115 'upload_date': upload_date,
116 }