mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 19:21:27 +01:00
Compare commits
2 Commits
d009450b4f
...
e2d05bf782
Author | SHA1 | Date | |
---|---|---|---|
|
e2d05bf782 | ||
|
e3b0697939 |
|
@ -1,3 +1,5 @@
|
||||||
|
import functools
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..networking import HEADRequest
|
from ..networking import HEADRequest
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
@ -9,11 +11,9 @@ from ..utils import (
|
||||||
update_url_query,
|
update_url_query,
|
||||||
)
|
)
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
|
|
||||||
class RedCDNLivxIE(InfoExtractor):
|
class RedCDNLivxIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://[^.]+\.(?:dcs\.redcdn|atmcdn)\.pl/(?:live(?:dash|hls|ss)|nvr)/o2/(?P<tenant>[^/]+)/(?P<id>[^?#]+)\.livx'
|
_VALID_URL = r'https?://[^.]+\.(?:dcs\.redcdn|atmcdn)\.pl/(?:live(?:dash|hls|ss)|nvr)/o2/(?P<tenant>[^/?#]+)/(?P<id>[^?#]+)\.livx'
|
||||||
IE_NAME = 'redcdnlivx'
|
IE_NAME = 'redcdnlivx'
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
@ -118,7 +118,7 @@ class RedCDNLivxIE(InfoExtractor):
|
||||||
|
|
||||||
time_scale = traverse_obj(ism_doc, ('@TimeScale', {int_or_none})) or 10000000
|
time_scale = traverse_obj(ism_doc, ('@TimeScale', {int_or_none})) or 10000000
|
||||||
duration = traverse_obj(
|
duration = traverse_obj(
|
||||||
ism_doc, ('@Duration', {partial(float_or_none, scale=time_scale)})) or None
|
ism_doc, ('@Duration', {functools.partial(float_or_none, scale=time_scale)})) or None
|
||||||
|
|
||||||
live_status = None
|
live_status = None
|
||||||
if traverse_obj(ism_doc, '@IsLive') == 'TRUE':
|
if traverse_obj(ism_doc, '@IsLive') == 'TRUE':
|
||||||
|
|
|
@ -8,20 +8,20 @@ from ..utils import (
|
||||||
update_url_query,
|
update_url_query,
|
||||||
)
|
)
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
def is_dst(date):
|
def is_dst(date):
|
||||||
year = date.year
|
year = date.year
|
||||||
# last sunday of march and october, respectively. might break on switch days.
|
# last sunday of march and october, respectively. might break on switch days.
|
||||||
dst_start = datetime(year, 3, 31, 2) - timedelta(days=(datetime(year, 3, 31).weekday() + 1) % 7)
|
dst_start = datetime.datetime(year, 3, 31, 2) - datetime.timedelta(days=(datetime.datetime(year, 3, 31).weekday() + 1) % 7)
|
||||||
dst_end = datetime(year, 10, 31, 3) - timedelta(days=(datetime(year, 10, 31).weekday() + 1) % 7)
|
dst_end = datetime.datetime(year, 10, 31, 3) - datetime.timedelta(days=(datetime.datetime(year, 10, 31).weekday() + 1) % 7)
|
||||||
return dst_start <= date <= dst_end
|
return dst_start <= date <= dst_end
|
||||||
|
|
||||||
|
|
||||||
def rfc3339_to_atende(date):
|
def rfc3339_to_atende(date):
|
||||||
date = datetime.fromisoformat(date)
|
date = datetime.datetime.fromisoformat(date)
|
||||||
date = date + timedelta(hours=1 if is_dst(date) else 0)
|
date = date + datetime.timedelta(hours=1 if is_dst(date) else 0)
|
||||||
return int((date.timestamp() - 978307200) * 1000)
|
return int((date.timestamp() - 978307200) * 1000)
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,17 +155,16 @@ class SejmIE(InfoExtractor):
|
||||||
# end the stream at that time, while the session actually keeps going.
|
# end the stream at that time, while the session actually keeps going.
|
||||||
if live_status == 'was_live':
|
if live_status == 'was_live':
|
||||||
stop_time = rfc3339_to_atende(params['stop'])
|
stop_time = rfc3339_to_atende(params['stop'])
|
||||||
|
duration = (stop_time - start_time) // 1000
|
||||||
else:
|
else:
|
||||||
stop_time = None
|
stop_time, duration = None, None
|
||||||
|
|
||||||
duration = (stop_time - start_time) // 1000 if stop_time else None
|
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
|
|
||||||
def add_entry(file, legacy_file=False):
|
def add_entry(file, legacy_file=False):
|
||||||
if not file:
|
if not file:
|
||||||
return
|
return
|
||||||
file = f'https:{file}' if file.startswith('//') else file
|
file = self._proto_relative_url(file)
|
||||||
if not legacy_file:
|
if not legacy_file:
|
||||||
file = update_url_query(file, {'startTime': start_time})
|
file = update_url_query(file, {'startTime': start_time})
|
||||||
if stop_time is not None:
|
if stop_time is not None:
|
||||||
|
@ -193,7 +192,7 @@ class SejmIE(InfoExtractor):
|
||||||
cameras = self._search_json(
|
cameras = self._search_json(
|
||||||
r'var\s+cameras\s*=', frame, 'camera list', video_id,
|
r'var\s+cameras\s*=', frame, 'camera list', video_id,
|
||||||
contains_pattern=r'\[(?s:.+)\]', transform_source=js_to_json,
|
contains_pattern=r'\[(?s:.+)\]', transform_source=js_to_json,
|
||||||
fatal=not self.get_param('ignore_no_formats_error')) or []
|
fatal=False) or []
|
||||||
for camera_file in traverse_obj(cameras, (..., 'file', {dict})):
|
for camera_file in traverse_obj(cameras, (..., 'file', {dict})):
|
||||||
if camera_file.get('flv'):
|
if camera_file.get('flv'):
|
||||||
add_entry(camera_file['flv'])
|
add_entry(camera_file['flv'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user