Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import shutil
import traceback

sys.stdout.reconfigure(encoding="utf-8")

# Exit codes used by NZBGet
POSTPROCESS_SUCCESS = 93
POSTPROCESS_NONE = 95
Expand Down Expand Up @@ -280,7 +282,7 @@ def construct_path(filename):

except Exception as e:
errors = True
print("[ERROR] Failed: %s" % old_filename)
print("[ERROR] Failed: %s" % old_path)
print("[ERROR] %s" % e)
traceback.print_exc()

Expand Down
23 changes: 23 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ def test_move_file_with_category_and_nzb_parent(self):
shutil.rmtree(tmp_dir)
self.assertEqual(code, POSTPROCESS_SUCCESS)

def test_move_file_with_unicode_diacritics(self):
unicode_nzb = "Sōmething.Vol.2"
unicode_category = "Möviés"
unicode_file = "Sōmething.Vol.2.mp4"
unicode_dwn_dir = root + "/tmp/dwn_sōmething/"

os.mkdir(tmp_dir)
os.mkdir(unicode_dwn_dir)
shutil.copyfile(test_data_dir + test_file, unicode_dwn_dir + unicode_file)
set_defaults_env()
os.environ["NZBPP_DIRECTORY"] = unicode_dwn_dir
os.environ["NZBPP_NZBNAME"] = unicode_nzb
os.environ["NZBPP_CATEGORY"] = unicode_category
os.environ["NZBPO_USENZBPARENTDIR"] = "yes"
os.environ["NZBPO_USECATEGORYDIR"] = "yes"
os.environ["NZBPO_VERBOSE"] = "yes"

[out, code, err] = run_script()
expected_path = os.path.join(dst_dir, unicode_category, unicode_nzb, unicode_file)
self.assertTrue(os.path.exists(expected_path))
shutil.rmtree(tmp_dir)
self.assertEqual(code, POSTPROCESS_SUCCESS)

def test_manifest(self):
with open(root + "/manifest.json", encoding="utf-8") as file:
try:
Expand Down
Loading