Merge branch 'master' into suppress_colors

This commit is contained in:
Jesse Bannon 2025-05-03 19:40:42 -07:00
commit ddfbe0df54
9 changed files with 97 additions and 15 deletions

View file

@ -14,9 +14,9 @@ else
endif
lint:
@-isort .
@-black .
@-pylint src/
python3 -m isort . && \
python3 -m black . && \
python3 -m pylint src
check_lint:
isort . --check-only --diff \
&& black . --check \

View file

@ -21,6 +21,9 @@ echo "Starting ytdl-sub..."
chown -R ${PUID:-abc}:${PGID:-abc} \
/config
# always create empty cron log file on start
echo "" > "$LOGS_TO_STDOUT"
# set up cron
if [ "$CRON_SCHEDULE" != "" ] ; then
[[ ! -e "$CRON_SCRIPT" ]] && \
@ -51,19 +54,15 @@ if [ "$CRON_SCHEDULE" != "" ] ; then
echo "Cron enabled with schedule $CRON_SCHEDULE_CLEAN"
if [ "$CRON_RUN_ON_START" = true ] ; then
echo "Running cron script on start"
. "$CRON_WRAPPER_SCRIPT"
echo "Running cron script on start in the background"
# ensure it runs as abc to respect puid/guid with delay for tail to start
su -s "/bin/bash" -c "sleep 5 && . '$CRON_WRAPPER_SCRIPT'" abc > /dev/null 2>&1 &
fi
else
echo "Error in CRON_SCHEDULE definition, disabling cron."
exit 1
fi
else
echo "CRON_SCHEDULE not specified, disabling cron."
echo "# min hour day month weekday command" > /config/crontabs/abc
echo "" >> /config/crontabs/abc
echo "CRON_SCHEDULE not specified, leaving crontabs as-is. Current configuration in /config/crontabs/abc"
cat /config/crontabs/abc
fi
# always create cron log file, after cron runs
# on start to not tail it again
echo "" > "$LOGS_TO_STDOUT"

View file

@ -15,7 +15,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
]
dependencies = [
"yt-dlp[default]==2025.3.31",
"yt-dlp[default]==2025.4.30",
"colorama~=0.4",
"mergedeep~=1.3",
"mediafile~=0.12",

View file

@ -35,11 +35,29 @@ presets:
# TV show from one or more sources. Uses {url}'s avatar and banner as poster and fanart
_tv_show_by_date:
preset: "_multi_url_bilateral"
preset:
- "_multi_url_bilateral"
- "_tv_show_by_date_asserts"
overrides:
avatar_uncropped_thumbnail_file_name: "{tv_show_poster_file_name}"
banner_uncropped_thumbnail_file_name: "{tv_show_fanart_file_name}"
_tv_show_by_date_asserts:
overrides:
s01_url: ""
s01_name: ""
assert_not_collection: >-
{
%assert(
%and(
%not( %bool(s01_url) ),
%not( %bool(s01_name) )
),
"Provided `s01_url` or `s01_name` variable to TV Show by Date preset when it expects `url`. Perhaps you meant to use the `TV Show Collection` preset?"
)
}
####################################################################################################
_season_by_year:

View file

@ -62,6 +62,7 @@ presets:
_tv_show_collection:
preset:
- "_tv_show_collection_bilateral"
- "_tv_show_collection_asserts"
download:
- url: "{collection_season_1_url}"
@ -1015,6 +1016,16 @@ presets:
ytdl_options:
playlist_items: "-1:0:-1"
_tv_show_collection_asserts:
overrides:
url: ""
assert_not_by_date: >-
{
%assert(
%not( %bool(url) ),
"Provided `url` to TV Show Collection preset when it expects `s01_url`. Perhaps you meant to use the `TV Show by Date` preset?"
)
}
####################################################################################################
# DEPRECATED SEASON PRESETS

View file

View file

@ -0,0 +1,26 @@
import re
import pytest
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
from ytdl_sub.subscriptions.subscription import Subscription
class TestTvShowByDatePreset:
def test_s01_error_thrown(self, default_config):
with pytest.raises(
UserThrownRuntimeError,
match=re.escape(
"Provided `s01_url` or `s01_name` variable to TV Show by Date preset when it "
"expects `url`. Perhaps you meant to use the `TV Show Collection` preset?"
),
):
_ = Subscription.from_dict(
config=default_config,
preset_name="test",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {"tv_show_directory": "abc", "s01_url": "test"},
},
)

View file

@ -0,0 +1,26 @@
import re
import pytest
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
from ytdl_sub.subscriptions.subscription import Subscription
class TestTvShowCollectionPreset:
def test_url_error_thrown(self, default_config):
with pytest.raises(
UserThrownRuntimeError,
match=re.escape(
"Provided `url` to TV Show Collection preset when it expects `s01_url`. "
"Perhaps you meant to use the `TV Show by Date` preset?"
),
):
_ = Subscription.from_dict(
config=default_config,
preset_name="test",
preset_dict={
"preset": "Jellyfin TV Show Collection",
"overrides": {"tv_show_directory": "abc", "url": "test"},
},
)

View file

@ -1,3 +1,4 @@
import os
import tempfile
from pathlib import Path
@ -34,7 +35,8 @@ class TestStringFormatterFilePathValidator:
Script({"file_name": formatter.format_string}).resolve().get_str("file_name")
)
assert truncated_file_path.count(".") == ext.count(".")
_, truncated_file_name = os.path.split(truncated_file_path)
assert truncated_file_name.count(".") == ext.count(".")
assert str(Path(temp_dir)) in truncated_file_path
assert ext in truncated_file_path