[DEV] Unit test NFO tags (#1064)
This commit is contained in:
parent
6c3150ac0c
commit
f963125398
3 changed files with 326 additions and 31 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
Files created:
|
Files created:
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
{output_directory}
|
{output_directory}
|
||||||
.ytdl-sub-kodi_safe_xml-download-archive.json
|
.ytdl-sub-subscription_test-download-archive.json
|
||||||
test.nfo
|
test.nfo
|
||||||
NFO tags:
|
NFO tags:
|
||||||
kodi_safe_root 🎸:
|
kodi_safe_root 🎸:
|
||||||
|
|
@ -34,22 +34,22 @@ Files created:
|
||||||
tag:
|
tag:
|
||||||
the
|
the
|
||||||
tag 🎸🎸
|
tag 🎸🎸
|
||||||
{output_directory}/kodi_safe_xml
|
{output_directory}/subscription_test
|
||||||
Can you hear the difference? 🎸🔥 #shorts.info.json
|
Mock Entry 20-1.info.json
|
||||||
Can you hear the difference? 🎸🔥 #shorts.jpg
|
Mock Entry 20-1.jpg
|
||||||
Can you hear the difference? 🎸🔥 #shorts.mp4
|
Mock Entry 20-1.mp4
|
||||||
Video Tags:
|
Video Tags:
|
||||||
album: Music Videos
|
album: Music Videos
|
||||||
artist: kodi_safe_xml
|
artist: subscription_test
|
||||||
genre: ytdl-sub
|
genre: ytdl-sub
|
||||||
premiered: 2022-06-30
|
premiered: 2020-08-08
|
||||||
title: Can you hear the difference? 🎸🔥 #shorts
|
title: Mock Entry 20-1
|
||||||
year: 2022
|
year: 2020
|
||||||
Can you hear the difference? 🎸🔥 #shorts.nfo
|
Mock Entry 20-1.nfo
|
||||||
NFO tags:
|
NFO tags:
|
||||||
musicvideo:
|
musicvideo:
|
||||||
album: Music Videos
|
album: Music Videos
|
||||||
artist: kodi_safe_xml
|
artist: subscription_test
|
||||||
genre: ytdl-sub
|
genre: ytdl-sub
|
||||||
kodi_safe_multi_title 🎸:
|
kodi_safe_multi_title 🎸:
|
||||||
- value 1 🎸
|
- value 1 🎸
|
||||||
|
|
@ -80,5 +80,146 @@ Files created:
|
||||||
tag:
|
tag:
|
||||||
the
|
the
|
||||||
tag 🎸🎸
|
tag 🎸🎸
|
||||||
premiered: 2022-06-30
|
premiered: 2020-08-08
|
||||||
title: Can you hear the difference? 🎸🔥 #shorts
|
title: Mock Entry 20-1
|
||||||
|
Mock Entry 20-2.info.json
|
||||||
|
Mock Entry 20-2.jpg
|
||||||
|
Mock Entry 20-2.mp4
|
||||||
|
Video Tags:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
premiered: 2020-08-08
|
||||||
|
title: Mock Entry 20-2
|
||||||
|
year: 2020
|
||||||
|
Mock Entry 20-2.nfo
|
||||||
|
NFO tags:
|
||||||
|
musicvideo:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
kodi_safe_multi_title 🎸:
|
||||||
|
- value 1 🎸
|
||||||
|
- value 2 🎸
|
||||||
|
kodi_safe_multi_title_with_attrs:
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 1 🎸🎸
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 2 🎸🎸
|
||||||
|
kodi_safe_title 🎸: kodi_safe_value 🎸
|
||||||
|
kodi_safe_title_with_attrs:
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 🎸🎸
|
||||||
|
premiered: 2020-08-08
|
||||||
|
title: Mock Entry 20-2
|
||||||
|
Mock Entry 20-3.info.json
|
||||||
|
Mock Entry 20-3.jpg
|
||||||
|
Mock Entry 20-3.mp4
|
||||||
|
Video Tags:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
premiered: 2020-08-07
|
||||||
|
title: Mock Entry 20-3
|
||||||
|
year: 2020
|
||||||
|
Mock Entry 20-3.nfo
|
||||||
|
NFO tags:
|
||||||
|
musicvideo:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
kodi_safe_multi_title 🎸:
|
||||||
|
- value 1 🎸
|
||||||
|
- value 2 🎸
|
||||||
|
kodi_safe_multi_title_with_attrs:
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 1 🎸🎸
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 2 🎸🎸
|
||||||
|
kodi_safe_title 🎸: kodi_safe_value 🎸
|
||||||
|
kodi_safe_title_with_attrs:
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 🎸🎸
|
||||||
|
premiered: 2020-08-07
|
||||||
|
title: Mock Entry 20-3
|
||||||
|
Mock Entry 21-1.info.json
|
||||||
|
Mock Entry 21-1.jpg
|
||||||
|
Mock Entry 21-1.mp4
|
||||||
|
Video Tags:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
premiered: 2021-08-08
|
||||||
|
title: Mock Entry 21-1
|
||||||
|
year: 2021
|
||||||
|
Mock Entry 21-1.nfo
|
||||||
|
NFO tags:
|
||||||
|
musicvideo:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
kodi_safe_multi_title 🎸:
|
||||||
|
- value 1 🎸
|
||||||
|
- value 2 🎸
|
||||||
|
kodi_safe_multi_title_with_attrs:
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 1 🎸🎸
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 2 🎸🎸
|
||||||
|
kodi_safe_title 🎸: kodi_safe_value 🎸
|
||||||
|
kodi_safe_title_with_attrs:
|
||||||
|
attributes:
|
||||||
|
🎸?:
|
||||||
|
value
|
||||||
|
newlines 🎸
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 🎸🎸
|
||||||
|
premiered: 2021-08-08
|
||||||
|
title: Mock Entry 21-1
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Files created:
|
Files created:
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
{output_directory}
|
{output_directory}
|
||||||
.ytdl-sub-kodi_safe_xml-download-archive.json
|
.ytdl-sub-subscription_test-download-archive.json
|
||||||
test.nfo
|
test.nfo
|
||||||
NFO tags:
|
NFO tags:
|
||||||
kodi_safe_root □:
|
kodi_safe_root □:
|
||||||
|
|
@ -34,22 +34,22 @@ Files created:
|
||||||
tag:
|
tag:
|
||||||
the
|
the
|
||||||
tag □□
|
tag □□
|
||||||
{output_directory}/kodi_safe_xml
|
{output_directory}/subscription_test
|
||||||
Can you hear the difference? 🎸🔥 #shorts.info.json
|
Mock Entry 20-1.info.json
|
||||||
Can you hear the difference? 🎸🔥 #shorts.jpg
|
Mock Entry 20-1.jpg
|
||||||
Can you hear the difference? 🎸🔥 #shorts.mp4
|
Mock Entry 20-1.mp4
|
||||||
Video Tags:
|
Video Tags:
|
||||||
album: Music Videos
|
album: Music Videos
|
||||||
artist: kodi_safe_xml
|
artist: subscription_test
|
||||||
genre: ytdl-sub
|
genre: ytdl-sub
|
||||||
premiered: 2022-06-30
|
premiered: 2020-08-08
|
||||||
title: Can you hear the difference? 🎸🔥 #shorts
|
title: Mock Entry 20-1
|
||||||
year: 2022
|
year: 2020
|
||||||
Can you hear the difference? 🎸🔥 #shorts.nfo
|
Mock Entry 20-1.nfo
|
||||||
NFO tags:
|
NFO tags:
|
||||||
musicvideo:
|
musicvideo:
|
||||||
album: Music Videos
|
album: Music Videos
|
||||||
artist: kodi_safe_xml
|
artist: subscription_test
|
||||||
genre: ytdl-sub
|
genre: ytdl-sub
|
||||||
kodi_safe_multi_title □:
|
kodi_safe_multi_title □:
|
||||||
- value 1 □
|
- value 1 □
|
||||||
|
|
@ -80,5 +80,146 @@ Files created:
|
||||||
tag:
|
tag:
|
||||||
the
|
the
|
||||||
tag □□
|
tag □□
|
||||||
premiered: 2022-06-30
|
premiered: 2020-08-08
|
||||||
title: Can you hear the difference? □□ #shorts
|
title: Mock Entry 20-1
|
||||||
|
Mock Entry 20-2.info.json
|
||||||
|
Mock Entry 20-2.jpg
|
||||||
|
Mock Entry 20-2.mp4
|
||||||
|
Video Tags:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
premiered: 2020-08-08
|
||||||
|
title: Mock Entry 20-2
|
||||||
|
year: 2020
|
||||||
|
Mock Entry 20-2.nfo
|
||||||
|
NFO tags:
|
||||||
|
musicvideo:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
kodi_safe_multi_title □:
|
||||||
|
- value 1 □
|
||||||
|
- value 2 □
|
||||||
|
kodi_safe_multi_title_with_attrs:
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 1 □□
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 2 □□
|
||||||
|
kodi_safe_title □: kodi_safe_value □
|
||||||
|
kodi_safe_title_with_attrs:
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag □□
|
||||||
|
premiered: 2020-08-08
|
||||||
|
title: Mock Entry 20-2
|
||||||
|
Mock Entry 20-3.info.json
|
||||||
|
Mock Entry 20-3.jpg
|
||||||
|
Mock Entry 20-3.mp4
|
||||||
|
Video Tags:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
premiered: 2020-08-07
|
||||||
|
title: Mock Entry 20-3
|
||||||
|
year: 2020
|
||||||
|
Mock Entry 20-3.nfo
|
||||||
|
NFO tags:
|
||||||
|
musicvideo:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
kodi_safe_multi_title □:
|
||||||
|
- value 1 □
|
||||||
|
- value 2 □
|
||||||
|
kodi_safe_multi_title_with_attrs:
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 1 □□
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 2 □□
|
||||||
|
kodi_safe_title □: kodi_safe_value □
|
||||||
|
kodi_safe_title_with_attrs:
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag □□
|
||||||
|
premiered: 2020-08-07
|
||||||
|
title: Mock Entry 20-3
|
||||||
|
Mock Entry 21-1.info.json
|
||||||
|
Mock Entry 21-1.jpg
|
||||||
|
Mock Entry 21-1.mp4
|
||||||
|
Video Tags:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
premiered: 2021-08-08
|
||||||
|
title: Mock Entry 21-1
|
||||||
|
year: 2021
|
||||||
|
Mock Entry 21-1.nfo
|
||||||
|
NFO tags:
|
||||||
|
musicvideo:
|
||||||
|
album: Music Videos
|
||||||
|
artist: subscription_test
|
||||||
|
genre: ytdl-sub
|
||||||
|
kodi_safe_multi_title □:
|
||||||
|
- value 1 □
|
||||||
|
- value 2 □
|
||||||
|
kodi_safe_multi_title_with_attrs:
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 1 □□
|
||||||
|
-
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag 2 □□
|
||||||
|
kodi_safe_title □: kodi_safe_value □
|
||||||
|
kodi_safe_title_with_attrs:
|
||||||
|
attributes:
|
||||||
|
□?:
|
||||||
|
value
|
||||||
|
newlines □
|
||||||
|
tag:
|
||||||
|
the
|
||||||
|
tag □□
|
||||||
|
premiered: 2021-08-08
|
||||||
|
title: Mock Entry 21-1
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
from expected_transaction_log import assert_transaction_log_matches
|
from expected_transaction_log import assert_transaction_log_matches
|
||||||
|
from unit.conftest import mock_download_collection_entries
|
||||||
|
|
||||||
from ytdl_sub.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
|
|
||||||
|
|
@ -8,7 +9,7 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
def subscription_dict(output_directory):
|
def subscription_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "Jellyfin Music Videos",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/shorts/ucYmEqmlhFw",
|
"download": "https://your.name.here",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
"format": "best[height<=480]", # download the worst format so it is fast
|
"format": "best[height<=480]", # download the worst format so it is fast
|
||||||
|
|
@ -79,7 +80,15 @@ def subscription_dict(output_directory):
|
||||||
|
|
||||||
class TestNfoTagsPlugins:
|
class TestNfoTagsPlugins:
|
||||||
@pytest.mark.parametrize("kodi_safe", [True, False])
|
@pytest.mark.parametrize("kodi_safe", [True, False])
|
||||||
def test_nfo_tags(self, subscription_dict, default_config, output_directory, kodi_safe):
|
def test_nfo_tags(
|
||||||
|
self,
|
||||||
|
subscription_name,
|
||||||
|
subscription_dict,
|
||||||
|
config,
|
||||||
|
output_directory,
|
||||||
|
mock_download_collection_entries,
|
||||||
|
kodi_safe,
|
||||||
|
):
|
||||||
transaction_log_file_name = "test_nfo.txt"
|
transaction_log_file_name = "test_nfo.txt"
|
||||||
if kodi_safe:
|
if kodi_safe:
|
||||||
transaction_log_file_name = "test_nfo_kodi_safe.txt"
|
transaction_log_file_name = "test_nfo_kodi_safe.txt"
|
||||||
|
|
@ -87,13 +96,17 @@ class TestNfoTagsPlugins:
|
||||||
subscription_dict["output_directory_nfo_tags"]["kodi_safe"] = True
|
subscription_dict["output_directory_nfo_tags"]["kodi_safe"] = True
|
||||||
|
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=default_config,
|
config=config,
|
||||||
preset_name="kodi_safe_xml",
|
preset_name=subscription_name,
|
||||||
preset_dict=subscription_dict,
|
preset_dict=subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only dry run is needed to see if NFO values are kodi safe
|
# Only dry run is needed to see if NFO values are kodi safe
|
||||||
transaction_log = subscription.download(dry_run=True)
|
with mock_download_collection_entries(
|
||||||
|
is_youtube_channel=False, num_urls=1, is_extracted_audio=False
|
||||||
|
):
|
||||||
|
transaction_log = subscription.download(dry_run=False)
|
||||||
|
|
||||||
assert_transaction_log_matches(
|
assert_transaction_log_matches(
|
||||||
output_directory=output_directory,
|
output_directory=output_directory,
|
||||||
transaction_log=transaction_log,
|
transaction_log=transaction_log,
|
||||||
Loading…
Reference in a new issue