]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ivideon.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / ivideon.py
1 import urllib.parse
2
3 from .common import InfoExtractor
4 from ..utils import qualities
5
6
7 class IvideonIE(InfoExtractor):
8 IE_NAME = 'ivideon'
9 IE_DESC = 'Ivideon TV'
10 _VALID_URL = r'https?://(?:www\.)?ivideon\.com/tv/(?:[^/]+/)*camera/(?P<id>\d+-[\da-f]+)/(?P<camera_id>\d+)'
11 _TESTS = [{
12 'url': 'https://www.ivideon.com/tv/camera/100-916ca13b5c4ad9f564266424a026386d/0/',
13 'info_dict': {
14 'id': '100-916ca13b5c4ad9f564266424a026386d',
15 'ext': 'flv',
16 'title': 're:^Касса [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
17 'description': 'Основное предназначение - запись действий кассиров. Плюс общий вид.',
18 'is_live': True,
19 },
20 'params': {
21 'skip_download': True,
22 },
23 }, {
24 'url': 'https://www.ivideon.com/tv/camera/100-c4ee4cb9ede885cf62dfbe93d7b53783/589824/?lang=ru',
25 'only_matching': True,
26 }, {
27 'url': 'https://www.ivideon.com/tv/map/22.917923/-31.816406/16/camera/100-e7bc16c7d4b5bbd633fd5350b66dfa9a/0',
28 'only_matching': True,
29 }]
30
31 _QUALITIES = ('low', 'mid', 'hi')
32
33 def _real_extract(self, url):
34 mobj = self._match_valid_url(url)
35 server_id, camera_id = mobj.group('id'), mobj.group('camera_id')
36 camera_name, description = None, None
37 camera_url = urllib.parse.urljoin(
38 url, f'/tv/camera/{server_id}/{camera_id}/')
39
40 webpage = self._download_webpage(camera_url, server_id, fatal=False)
41 if webpage:
42 config_string = self._search_regex(
43 r'var\s+config\s*=\s*({.+?});', webpage, 'config', default=None)
44 if config_string:
45 config = self._parse_json(config_string, server_id, fatal=False)
46 camera_info = config.get('ivTvAppOptions', {}).get('currentCameraInfo')
47 if camera_info:
48 camera_name = camera_info.get('camera_name')
49 description = camera_info.get('misc', {}).get('description')
50 if not camera_name:
51 camera_name = self._html_search_meta(
52 'name', webpage, 'camera name', default=None) or self._search_regex(
53 r'<h1[^>]+class="b-video-title"[^>]*>([^<]+)', webpage, 'camera name', default=None)
54
55 quality = qualities(self._QUALITIES)
56
57 formats = [{
58 'url': 'https://streaming.ivideon.com/flv/live?{}'.format(urllib.parse.urlencode({
59 'server': server_id,
60 'camera': camera_id,
61 'sessionId': 'demo',
62 'q': quality(format_id),
63 })),
64 'format_id': format_id,
65 'ext': 'flv',
66 'quality': quality(format_id),
67 } for format_id in self._QUALITIES]
68
69 return {
70 'id': server_id,
71 'title': camera_name or server_id,
72 'description': description,
73 'is_live': True,
74 'formats': formats,
75 }