PlexAniSync
PlexAniSync copied to clipboard
Use "Sort title" and "Original title" as alternative titles for search
I have a lot of anime movies and series that doesn't use english or japanese titles. It would be great if PlexAniSync could use "Sort title" and "Original title" from Plex, as alternative titles when searching Anilist for the movie/series fails. The sort title is usually the same as the title, but I like to add the english title together with the translated title there, so for my situation it would be nice if the sort title was used as well. But the "Original title" field would probably give the correct result from anilist most of the time.
Added š
Small caveat is that PlexAPI doesn't seem to always supply the original title or is limited to movie objects.
Awesome! š Maybe the HamaTV or TheTVDB agents doesn't import "original title" to Plex? After looking through my anime library, I couldn't find any shows with original titles, that I hadn't added myself.
Unfortunately the new feature doesn't work for me. All of the movies it is trying to sync have japanese characters in the original title, and I just get unicode encode errors when it tries to encode the title.
Should be fixable with forcing unicode encoding but believe that is also OS related with Python, if you can post both logs (debug and standard) will take a look :)
Here you go: PlexAniSync-logs.zip
Don't see any encoding error tracebacks in log, could you make a screenshot and post the title of one that it's having issues with.
You can also try the docker image which rules out any Python or local OS issues:
https://hub.docker.com/r/rickdb/plexanisync
Sorry, I thought the logfiles reflected what I could see in the console. Here's the console output: PlexAniSync-console.log I will try docker next time I restart my machine since I have to logout to install it.
It should have logged to file so that's odd, thanks and will check the console logs now :)
Our guessit implementation looks like the root cause so will try some solutions now.
Could you retry with replacing anilist.py with this one:
https://gist.github.com/RickDB/d533c4d6f94a324bf8f049293a97bc85
This will force encoding to UTF8 for guessit, since it also break logging it could be an operating system + Python issue where it doesn't properly translates these characters. So would still test the docker image as well just in case to rule this out.
Guessit Exception: PlexAniSync-logs.zip
What operating system and Python version are you currently testing under?
Found some other user reports for Guessit but it seems only under Python 2 and certain Windows versions, for now will add a workaround which logs + skips over Guessit if error occured. We only use that as an extra title so should not matter much anyway for these kind of titles.
Windows 10 64bit Python 3.8.2
Added some checks and forcing locale in below Python files, also includes PlexAniSync.py this time:
https://gist.github.com/RickDB/d533c4d6f94a324bf8f049293a97bc85 https://gist.github.com/RickDB/dcd0158f2b84fd857041d27152a2171a
What seems to happen is Guessit is throwing error and logger fails to output it because Python locale under Windows is cp1252 (non-unicode) which explains the lack of log output, either way this is fixable but probably need a few tries to get it right :)
New logs: PlexAniSync.zip
Updated to include encoding in logger creation:
https://gist.github.com/RickDB/d533c4d6f94a324bf8f049293a97bc85 https://gist.github.com/RickDB/dcd0158f2b84fd857041d27152a2171a
For some reason it's not taking the logging parameters, could you post a few problematic titles here so I can test locally as well.
In the meantime a new try with logger changes:
They did show up in the console log I attached. Does it not show the japanese characters for you? Here's a few:
åććććć®ć¢ćŖćØććć£
čØć®čć®åŗ
ćć¦ć«ć®åćå
ē«ć®ę©čæć
é儳ć®å®
ę„ä¾æ
The debug log wasn't created this time: PlexAniSync.zip
Seems to be working now judging by console output but hard to see if there are real matches for the other titles, when testing those problematic titles show no more errors in logger so gonna clean up and restore a few functions.
Noticed title in the console log before just not sure if that got trimmed down :)
Still no debug log for me: PlexAniSync.zip
The debug logs are back now: PlexAniSync.zip
Logs look clean now with no more crashes, OVA / Movie matching is still experimental so for now would use custom mappings for those that are not lining up until a better solution is added :)
Pushed fixes to repo and updated docker image should be out soon.
But did you manage to sync anything using "original title" as alternate title? None of the movies with alternative titles got synced for me. It doesn't say anything about it attempting it in the log either.
Those get included in the generic matching pool of potential titles and don't log those as those can flood the log.
Attached a debug version of anilist.py which will output all 3 Plex titles which among others get included for lookup, if the original title there is the same as the standard / sort title it means PlexAPI sadly didn't supply it.
Thank you for the debug version.
There are some movies that doesn't match with Anilist using the japanese title, even though they should be able to. Like with Ponyo; searching for ćć®ć®ć姫
on Anilist gives me the correct result, but in the console I get Failed to find valid match on AniList for: Ponyo pƄ klippen ved havet
.
It also seems like the output of the print function for the plex titles is offset to the previous movie/series (which is probably not related to the issue).
Logs: PlexAniSync.zip
Console output for it could look a bit off as there's no new line before it but it's for the entry after it for sure. Will take a look at the AniList GraphQL queries to see what they return, would try with the Docker image as well so we know it's not an encoding issue somewhere further along.
Pretty sure I found the bug and new version below, it will be a bit slower when searching AniList as there's a 100ms delay between each potential title search and for no results that could mean 1.2s per show worse case.