Compare commits

...

2 Commits

Author SHA1 Message Date
lauren n. liberda
6a3ae2c0bc [extractor/sejm] review changes 2024-01-12 01:56:15 +01:00
lauren n. liberda
acdb8236db [extrator/redge] review change 2024-01-12 01:55:48 +01:00
2 changed files with 17 additions and 17 deletions

View File

@ -104,7 +104,7 @@ class RedCDNLivxIE(InfoExtractor):
nvr_urlh = self._request_webpage( nvr_urlh = self._request_webpage(
HEADRequest(livx_mode('nvr')), video_id, 'Follow flv file redirect', fatal=False, HEADRequest(livx_mode('nvr')), video_id, 'Follow flv file redirect', fatal=False,
expected_status=lambda _: True) expected_status=lambda _: True)
if nvr_urlh and nvr_urlh.getcode() == 200: if nvr_urlh and nvr_urlh.status == 200:
formats.append({ formats.append({
'url': nvr_urlh.url, 'url': nvr_urlh.url,
'ext': 'flv', 'ext': 'flv',

View File

@ -6,15 +6,24 @@ from ..utils import (
strip_or_none, strip_or_none,
traverse_obj, traverse_obj,
update_url_query, update_url_query,
ExtractorError,
) )
import datetime from datetime import datetime, timedelta
try:
from zoneinfo import ZoneInfo
_HAS_ZONEINFO = True def is_dst(date):
except ImportError: year = date.year
_HAS_ZONEINFO = False # last sunday of march and october, respectively. might break on switch days.
# but if they meet on a sunday, we probably got bigger problems than videos, right?
dst_start = datetime(year, 3, 31, 2) - timedelta(days=(datetime(year, 3, 31).weekday() + 1) % 7)
dst_end = datetime(year, 10, 31, 3) - timedelta(days=(datetime(year, 10, 31).weekday() + 1) % 7)
return dst_start <= date <= dst_end
def rfc3339_to_atende(date):
date = datetime.fromisoformat(date)
date = date + timedelta(hours=1 if is_dst(date) else 0)
return int((date.timestamp() - 978307200) * 1000)
class SejmIE(InfoExtractor): class SejmIE(InfoExtractor):
@ -121,8 +130,6 @@ class SejmIE(InfoExtractor):
}] }]
def _real_extract(self, url): def _real_extract(self, url):
if not _HAS_ZONEINFO:
raise ExtractorError('zoneinfo is required. Use Python 3.9+', expected=True)
term, video_id = self._match_valid_url(url).group('term', 'id') term, video_id = self._match_valid_url(url).group('term', 'id')
frame = self._download_webpage( frame = self._download_webpage(
f'https://sejm-embed.redcdn.pl/Sejm{term}.nsf/VideoFrame.xsp/{video_id}', f'https://sejm-embed.redcdn.pl/Sejm{term}.nsf/VideoFrame.xsp/{video_id}',
@ -135,13 +142,6 @@ class SejmIE(InfoExtractor):
title = data['title'].strip() title = data['title'].strip()
def rfc3339_to_atende(date):
date = datetime.datetime.fromisoformat(date)
# marks naive as CET/CEST
date.replace(tzinfo=ZoneInfo('Europe/Warsaw'))
# UTC timestamp with an offset
return int((date.astimezone(datetime.timezone.utc).timestamp() - 978307200) * 1000)
if data.get('status') == 'VIDEO_ENDED': if data.get('status') == 'VIDEO_ENDED':
live_status = 'was_live' live_status = 'was_live'
elif data.get('status') == 'VIDEO_PLAYING': elif data.get('status') == 'VIDEO_PLAYING':