add option for following nightly yt-dlp releases (closes #999)

This commit is contained in:
Alex Shnitman
2026-06-06 09:42:26 +03:00
parent 897d52cd0d
commit ee20512410
6 changed files with 174 additions and 6 deletions
+16
View File
@@ -107,6 +107,22 @@ class ConfigTests(unittest.TestCase):
c = Config()
self.assertTrue(c.ALLOW_YTDL_OPTIONS_OVERRIDES)
def test_ytdl_nightly_update_time_empty_default(self):
with patch.dict(os.environ, _base_env(YTDL_NIGHTLY_UPDATE_TIME=""), clear=False):
c = Config()
self.assertEqual(c.YTDL_NIGHTLY_UPDATE_TIME, "")
def test_ytdl_nightly_update_time_valid(self):
with patch.dict(os.environ, _base_env(YTDL_NIGHTLY_UPDATE_TIME="04:00"), clear=False):
c = Config()
self.assertEqual(c.YTDL_NIGHTLY_UPDATE_TIME, "04:00")
def test_ytdl_nightly_update_time_invalid_exits(self):
for bad in ("25:00", "4am", "12:60"):
with patch.dict(os.environ, _base_env(YTDL_NIGHTLY_UPDATE_TIME=bad), clear=False):
with self.assertRaises(SystemExit):
Config()
def test_runtime_override_roundtrip(self):
with patch.dict(os.environ, _base_env(), clear=False):
c = Config()
+29
View File
@@ -0,0 +1,29 @@
"""Tests for nightly yt-dlp update scheduling helpers."""
from __future__ import annotations
import unittest
from datetime import datetime
from main import seconds_until_next_daily_time
class NightlyUpdateTests(unittest.TestCase):
def test_seconds_until_later_today(self):
now = datetime(2026, 6, 4, 10, 0, 0)
delay = seconds_until_next_daily_time("15:30", now)
self.assertEqual(delay, 5 * 3600 + 30 * 60)
def test_seconds_until_wraps_to_next_day(self):
now = datetime(2026, 6, 4, 18, 0, 0)
delay = seconds_until_next_daily_time("04:00", now)
self.assertEqual(delay, 10 * 3600)
def test_seconds_until_same_minute_is_next_day(self):
now = datetime(2026, 6, 4, 4, 0, 30)
delay = seconds_until_next_daily_time("04:00", now)
self.assertAlmostEqual(delay, 24 * 3600 - 30, delta=1)
if __name__ == "__main__":
unittest.main()