Merge branch 'master' into suppress_colors
This commit is contained in:
commit
ddfbe0df54
9 changed files with 97 additions and 15 deletions
6
Makefile
6
Makefile
|
|
@ -14,9 +14,9 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@-isort .
|
python3 -m isort . && \
|
||||||
@-black .
|
python3 -m black . && \
|
||||||
@-pylint src/
|
python3 -m pylint src
|
||||||
check_lint:
|
check_lint:
|
||||||
isort . --check-only --diff \
|
isort . --check-only --diff \
|
||||||
&& black . --check \
|
&& black . --check \
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ echo "Starting ytdl-sub..."
|
||||||
chown -R ${PUID:-abc}:${PGID:-abc} \
|
chown -R ${PUID:-abc}:${PGID:-abc} \
|
||||||
/config
|
/config
|
||||||
|
|
||||||
|
# always create empty cron log file on start
|
||||||
|
echo "" > "$LOGS_TO_STDOUT"
|
||||||
|
|
||||||
# set up cron
|
# set up cron
|
||||||
if [ "$CRON_SCHEDULE" != "" ] ; then
|
if [ "$CRON_SCHEDULE" != "" ] ; then
|
||||||
[[ ! -e "$CRON_SCRIPT" ]] && \
|
[[ ! -e "$CRON_SCRIPT" ]] && \
|
||||||
|
|
@ -51,19 +54,15 @@ if [ "$CRON_SCHEDULE" != "" ] ; then
|
||||||
echo "Cron enabled with schedule $CRON_SCHEDULE_CLEAN"
|
echo "Cron enabled with schedule $CRON_SCHEDULE_CLEAN"
|
||||||
|
|
||||||
if [ "$CRON_RUN_ON_START" = true ] ; then
|
if [ "$CRON_RUN_ON_START" = true ] ; then
|
||||||
echo "Running cron script on start"
|
echo "Running cron script on start in the background"
|
||||||
. "$CRON_WRAPPER_SCRIPT"
|
# 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
|
fi
|
||||||
else
|
else
|
||||||
echo "Error in CRON_SCHEDULE definition, disabling cron."
|
echo "Error in CRON_SCHEDULE definition, disabling cron."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "CRON_SCHEDULE not specified, disabling cron."
|
echo "CRON_SCHEDULE not specified, leaving crontabs as-is. Current configuration in /config/crontabs/abc"
|
||||||
echo "# min hour day month weekday command" > /config/crontabs/abc
|
cat /config/crontabs/abc
|
||||||
echo "" >> /config/crontabs/abc
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# always create cron log file, after cron runs
|
|
||||||
# on start to not tail it again
|
|
||||||
echo "" > "$LOGS_TO_STDOUT"
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ classifiers = [
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"yt-dlp[default]==2025.3.31",
|
"yt-dlp[default]==2025.4.30",
|
||||||
"colorama~=0.4",
|
"colorama~=0.4",
|
||||||
"mergedeep~=1.3",
|
"mergedeep~=1.3",
|
||||||
"mediafile~=0.12",
|
"mediafile~=0.12",
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,29 @@ presets:
|
||||||
|
|
||||||
# TV show from one or more sources. Uses {url}'s avatar and banner as poster and fanart
|
# TV show from one or more sources. Uses {url}'s avatar and banner as poster and fanart
|
||||||
_tv_show_by_date:
|
_tv_show_by_date:
|
||||||
preset: "_multi_url_bilateral"
|
preset:
|
||||||
|
- "_multi_url_bilateral"
|
||||||
|
- "_tv_show_by_date_asserts"
|
||||||
overrides:
|
overrides:
|
||||||
avatar_uncropped_thumbnail_file_name: "{tv_show_poster_file_name}"
|
avatar_uncropped_thumbnail_file_name: "{tv_show_poster_file_name}"
|
||||||
banner_uncropped_thumbnail_file_name: "{tv_show_fanart_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:
|
_season_by_year:
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ presets:
|
||||||
_tv_show_collection:
|
_tv_show_collection:
|
||||||
preset:
|
preset:
|
||||||
- "_tv_show_collection_bilateral"
|
- "_tv_show_collection_bilateral"
|
||||||
|
- "_tv_show_collection_asserts"
|
||||||
|
|
||||||
download:
|
download:
|
||||||
- url: "{collection_season_1_url}"
|
- url: "{collection_season_1_url}"
|
||||||
|
|
@ -1015,6 +1016,16 @@ presets:
|
||||||
ytdl_options:
|
ytdl_options:
|
||||||
playlist_items: "-1:0:-1"
|
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
|
# DEPRECATED SEASON PRESETS
|
||||||
|
|
|
||||||
0
tests/unit/prebuilt_presets/__init__.py
Normal file
0
tests/unit/prebuilt_presets/__init__.py
Normal file
26
tests/unit/prebuilt_presets/test_tv_show_by_date.py
Normal file
26
tests/unit/prebuilt_presets/test_tv_show_by_date.py
Normal 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"},
|
||||||
|
},
|
||||||
|
)
|
||||||
26
tests/unit/prebuilt_presets/test_tv_show_collection.py
Normal file
26
tests/unit/prebuilt_presets/test_tv_show_collection.py
Normal 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"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -34,7 +35,8 @@ class TestStringFormatterFilePathValidator:
|
||||||
Script({"file_name": formatter.format_string}).resolve().get_str("file_name")
|
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 str(Path(temp_dir)) in truncated_file_path
|
||||||
assert ext in truncated_file_path
|
assert ext in truncated_file_path
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue