Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/sejmpl.py (Python)

Code before:
from .common import InfoExtractor
from .redge import RedCDNLivxIE
from ..utils import (
    clean_html,
    js_to_json,
    strip_or_none,
    traverse_obj,
    update_url_query,
)

import datetime


def is_dst(date):
    year = date.year
    # last sunday of march and october, respectively. might break on switch days.
    dst_start = datetime.datetime(year, 3, 31, 2) - datetime.timedelta(days=(datetime.datetime(year, 3, 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


def rfc3339_to_atende(date):
    date = datetime.datetime.fromisoformat(date)
    date = date + datetime.timedelta(hours=1 if is_dst(date) else 0)
    return int((date.timestamp() - 978307200) * 1000)


class SejmIE(InfoExtractor):
    _VALID_URL = (
        r'https?://(?:www\.)?sejm\.gov\.pl/[Ss]ejm(?P<term>\d+)\.nsf/transmisje(?:_arch)?\.xsp(?:\?[^#]*)?#(?P<id>[\dA-F]+)',
        r'https?://(?:www\.)?sejm\.gov\.pl/[Ss]ejm(?P<term>\d+)\.nsf/transmisje(?:_arch)?\.xsp\?(?:[^#]+&)?unid=(?P<id>[\dA-F]+)',
        r'https?://sejm-embed\.redcdn\.pl/[Ss]ejm(?P<term>\d+)\.nsf/VideoFrame\.xsp/(?P<id>[\dA-F]+)',
    )
    IE_NAME = 'sejm'

    _TESTS = [{
        # multiple cameras, polish SL iterpreter
        'url': 'https://www.sejm.gov.pl/Sejm10.nsf/transmisje_arch.xsp#6181EF1AD9CEEBB5C1258A6D006452B5',
        'info_dict': {
            'id': '6181EF1AD9CEEBB5C1258A6D006452B5',
            'title': '1. posiedzenie Sejmu X kadencji',
            'duration': 20145,
            'live_status': 'was_live',
            'location': 'Sala Posiedzeń',

Review comment (suggestion):
```suggestion
def is_dst(date):
    last_march = datetime.datetime(date.year, 3, 31)
    last_october = datetime.datetime(date.year, 10, 31)
    last_sunday_march = last_march - datetime.timedelta(days=last_march.isoweekday() % 7)
    last_sunday_october = last_october - datetime.timedelta(days=last_october.isoweekday() % 7)
    return last_sunday_march.replace(hour=2) <= date <= last_sunday_october.replace(hour=3)
```

Code after:
import datetime

from .common import InfoExtractor
from .redge import RedCDNLivxIE
from ..utils import (
    clean_html,
    join_nonempty,
    js_to_json,
    strip_or_none,
    update_url_query,
)
from ..utils.traversal import traverse_obj


def is_dst(date):
    last_march = datetime.datetime(date.year, 3, 31)
    last_october = datetime.datetime(date.year, 10, 31)
    last_sunday_march = last_march - datetime.timedelta(days=last_march.isoweekday() % 7)
    last_sunday_october = last_october - datetime.timedelta(days=last_october.isoweekday() % 7)
    return last_sunday_march.replace(hour=2) <= date <= last_sunday_october.replace(hour=3)


def rfc3339_to_atende(date):
    date = datetime.datetime.fromisoformat(date)
    date = date + datetime.timedelta(hours=1 if is_dst(date) else 0)
    return int((date.timestamp() - 978307200) * 1000)


class SejmIE(InfoExtractor):
    _VALID_URL = (
        r'https?://(?:www\.)?sejm\.gov\.pl/[Ss]ejm(?P<term>\d+)\.nsf/transmisje(?:_arch)?\.xsp(?:\?[^#]*)?#(?P<id>[\dA-F]+)',
        r'https?://(?:www\.)?sejm\.gov\.pl/[Ss]ejm(?P<term>\d+)\.nsf/transmisje(?:_arch)?\.xsp\?(?:[^#]+&)?unid=(?P<id>[\dA-F]+)',
        r'https?://sejm-embed\.redcdn\.pl/[Ss]ejm(?P<term>\d+)\.nsf/VideoFrame\.xsp/(?P<id>[\dA-F]+)',
    )
    IE_NAME = 'sejm'

    _TESTS = [{
        # multiple cameras, polish SL iterpreter
        'url': 'https://www.sejm.gov.pl/Sejm10.nsf/transmisje_arch.xsp#6181EF1AD9CEEBB5C1258A6D006452B5',
        'info_dict': {
            'id': '6181EF1AD9CEEBB5C1258A6D006452B5',
            'title': '1. posiedzenie Sejmu X kadencji',
            'duration': 20145,
            'live_status': 'was_live',