python-plexlibrary
python-plexlibrary copied to clipboard
Can't run recipes via cron
I use unRAID which allows me to schedule scripts via cron. If I run:
python plexlibrary movies_recommended
via SSH all works fine. But if I run in a script:
#!/bin/bash
cd /mnt/user/appdata/other/python-plexlibrary-master
python plexlibrary movies_recommended
exit
All hell breaks lose with failures and errors:
Running the recipe 'movies_recommended'
Retrieving the trakt list: https://api.trakt.tv/recommendations/movies?limit=100
Trying to match with items from the 'Movies' library
1 Maleficent: Mistress of Evil (2019)
2 Ford v Ferrari (2019)
3 Joker (2019)
4 Frozen II (2019)
5 Zombieland: Double Tap (2019)
6 6 Underground (2019)
7 Ad Astra (2019)
8 Black and Blue (2019)
9 Gemini Man (2019)
10 The Addams Family (2019)
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/mnt/user/appdata/other/python-plexlibrary-master/plexlibrary/__main__.py", line 3, in
main()
File "plexlibrary/plexlibrary.py", line 61, in main
r.run(args.sort_only)
File "plexlibrary/recipe.py", line 696, in run
missing_items, list_count = self._run()
File "plexlibrary/recipe.py", line 172, in _run
matching_total, item['title'], item['year']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 19: ordinal not in range(128)
Script Finished Tue, 07 Jan 2020 20:23:25 +0000
Full logs for this script are available at /tmp/user.scripts/tmpScripts/PlexLibrary/log.txt
From this post https://www.reddit.com/r/PleX/comments/b632y5/help_running_adamgotplexlibrary_python_script_via/ it appears maybe the script is failing on special characters, and when I run via SSH #11 is:
11 Once Upon a Time… in Hollywood (2019)
So, I think the ... is tripping up the bash script.
Is there a way to fix this please?
Thanks in advance
I ran into the same problem and the solution was to define utf8 for how python encodes those characters in the crontab. E.g:
PYTHONIOENCODING=utf8
* * * * * /path/to/script.sh
https://github.com/adamgot/python-plexlibrary/issues/80
@skuid87 @BinsonBuzz