]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/lnkgo.py
release 2017.10.15
[yt-dlp.git] / youtube_dl / extractor / lnkgo.py
CommitLineData
034206ce
NJ
1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
7from ..utils import (
8 int_or_none,
034206ce
NJ
9 unified_strdate,
10)
11
12
13class LnkGoIE(InfoExtractor):
b1a7bf44 14 _VALID_URL = r'https?://(?:www\.)?lnkgo\.(?:alfa\.)?lt/visi-video/(?P<show>[^/]+)/ziurek-(?P<id>[A-Za-z0-9-]+)'
034206ce
NJ
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,
ec85ded8 25 'thumbnail': r're:^https?://.*\.jpg$'
034206ce
NJ
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,
ec85ded8 40 'thumbnail': r're:^https?://.*\.jpg$'
034206ce
NJ
41 },
42 'params': {
43 'skip_download': True, # HLS download
44 },
b1a7bf44 45 }, {
46 'url': 'http://www.lnkgo.lt/visi-video/aktualai-pratesimas/ziurek-putka-trys-klausimai',
47 'only_matching': True,
034206ce
NJ
48 }]
49 _AGE_LIMITS = {
50 'N-7': 7,
51 'N-14': 14,
52 'S': 18,
53 }
54
55 def _real_extract(self, url):
2103d038 56 display_id = self._match_id(url)
034206ce
NJ
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)
2103d038
NJ
65 upload_date = unified_strdate(self._search_regex(
66 r'class="[^"]*meta-item[^"]*air-time[^"]*">.*?<strong>([^<]+)</strong>', webpage, 'upload date', fatal=False))
034206ce 67
034206ce
NJ
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))
f2cbc96c
NJ
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 })
034206ce 80
2103d038
NJ
81 config = self._parse_json(self._search_regex(
82 r'episodePlayer\((\{.*?\}),\s*\{', webpage, 'sources'), video_id)
034206ce 83
2103d038
NJ
84 if config.get('pGeo'):
85 self.report_warning(
86 'This content might not be available in your country due to copyright reasons')
034206ce 87
2103d038
NJ
88 formats = [{
89 'format_id': 'hls',
90 'ext': 'mp4',
91 'url': config['EpisodeVideoLink_HLS'],
92 }]
034206ce 93
2103d038
NJ
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 })
034206ce
NJ
103
104 self._sort_formats(formats)
105
106 return {
107 'id': video_id,
108 'display_id': display_id,
109 'title': title,
110 'formats': formats,
f2cbc96c 111 'thumbnails': [thumbnail],
2103d038 112 'duration': int_or_none(config.get('VideoTime')),
034206ce 113 'description': description,
2103d038 114 'age_limit': self._AGE_LIMITS.get(config.get('PGRating'), 0),
034206ce
NJ
115 'upload_date': upload_date,
116 }