2024-06-11 19:09:58 -04:00
|
|
|
|
import urllib.parse
|
|
|
|
|
|
2016-01-07 01:24:32 -05:00
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
from ..utils import qualities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class IvideonIE(InfoExtractor):
|
|
|
|
|
IE_NAME = 'ivideon'
|
|
|
|
|
IE_DESC = 'Ivideon TV'
|
2016-01-07 18:11:23 -05:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?ivideon\.com/tv/(?:[^/]+/)*camera/(?P<id>\d+-[\da-f]+)/(?P<camera_id>\d+)'
|
2016-01-07 01:24:32 -05:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://www.ivideon.com/tv/camera/100-916ca13b5c4ad9f564266424a026386d/0/',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '100-916ca13b5c4ad9f564266424a026386d',
|
|
|
|
|
'ext': 'flv',
|
|
|
|
|
'title': 're:^Касса [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
|
|
|
|
'description': 'Основное предназначение - запись действий кассиров. Плюс общий вид.',
|
|
|
|
|
'is_live': True,
|
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
2024-06-11 19:09:58 -04:00
|
|
|
|
},
|
2016-01-07 01:24:32 -05:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.ivideon.com/tv/camera/100-c4ee4cb9ede885cf62dfbe93d7b53783/589824/?lang=ru',
|
|
|
|
|
'only_matching': True,
|
2016-01-07 18:11:23 -05:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.ivideon.com/tv/map/22.917923/-31.816406/16/camera/100-e7bc16c7d4b5bbd633fd5350b66dfa9a/0',
|
|
|
|
|
'only_matching': True,
|
2016-01-07 01:24:32 -05:00
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
_QUALITIES = ('low', 'mid', 'hi')
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-18 21:41:24 -04:00
|
|
|
|
mobj = self._match_valid_url(url)
|
2016-01-07 01:24:32 -05:00
|
|
|
|
server_id, camera_id = mobj.group('id'), mobj.group('camera_id')
|
|
|
|
|
camera_name, description = None, None
|
2024-06-11 19:09:58 -04:00
|
|
|
|
camera_url = urllib.parse.urljoin(
|
|
|
|
|
url, f'/tv/camera/{server_id}/{camera_id}/')
|
2016-01-07 01:24:32 -05:00
|
|
|
|
|
2016-01-07 18:11:23 -05:00
|
|
|
|
webpage = self._download_webpage(camera_url, server_id, fatal=False)
|
2016-01-07 01:24:32 -05:00
|
|
|
|
if webpage:
|
|
|
|
|
config_string = self._search_regex(
|
|
|
|
|
r'var\s+config\s*=\s*({.+?});', webpage, 'config', default=None)
|
|
|
|
|
if config_string:
|
|
|
|
|
config = self._parse_json(config_string, server_id, fatal=False)
|
|
|
|
|
camera_info = config.get('ivTvAppOptions', {}).get('currentCameraInfo')
|
|
|
|
|
if camera_info:
|
|
|
|
|
camera_name = camera_info.get('camera_name')
|
|
|
|
|
description = camera_info.get('misc', {}).get('description')
|
|
|
|
|
if not camera_name:
|
|
|
|
|
camera_name = self._html_search_meta(
|
|
|
|
|
'name', webpage, 'camera name', default=None) or self._search_regex(
|
|
|
|
|
r'<h1[^>]+class="b-video-title"[^>]*>([^<]+)', webpage, 'camera name', default=None)
|
|
|
|
|
|
|
|
|
|
quality = qualities(self._QUALITIES)
|
|
|
|
|
|
|
|
|
|
formats = [{
|
2024-06-11 19:09:58 -04:00
|
|
|
|
'url': 'https://streaming.ivideon.com/flv/live?{}'.format(urllib.parse.urlencode({
|
2016-01-07 01:24:32 -05:00
|
|
|
|
'server': server_id,
|
|
|
|
|
'camera': camera_id,
|
|
|
|
|
'sessionId': 'demo',
|
|
|
|
|
'q': quality(format_id),
|
2024-06-11 19:09:58 -04:00
|
|
|
|
})),
|
2016-01-07 01:24:32 -05:00
|
|
|
|
'format_id': format_id,
|
|
|
|
|
'ext': 'flv',
|
|
|
|
|
'quality': quality(format_id),
|
|
|
|
|
} for format_id in self._QUALITIES]
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'id': server_id,
|
2021-12-15 11:00:46 -05:00
|
|
|
|
'title': camera_name or server_id,
|
2016-01-07 01:24:32 -05:00
|
|
|
|
'description': description,
|
|
|
|
|
'is_live': True,
|
|
|
|
|
'formats': formats,
|
|
|
|
|
}
|