PlexAniSync icon indicating copy to clipboard operation
PlexAniSync copied to clipboard

Use "Sort title" and "Original title" as alternative titles for search

Open MrDemocracy opened this issue 4 years ago ā€¢ 43 comments

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.

MrDemocracy avatar Apr 22 '20 23:04 MrDemocracy

Added šŸ‘

Small caveat is that PlexAPI doesn't seem to always supply the original title or is limited to movie objects.

RickDB avatar Apr 24 '20 22:04 RickDB

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.

MrDemocracy avatar Apr 25 '20 00:04 MrDemocracy

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 :)

RickDB avatar Apr 25 '20 00:04 RickDB

Here you go: PlexAniSync-logs.zip

MrDemocracy avatar Apr 25 '20 00:04 MrDemocracy

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.

RickDB avatar Apr 25 '20 08:04 RickDB

You can also try the docker image which rules out any Python or local OS issues:

https://hub.docker.com/r/rickdb/plexanisync

RickDB avatar Apr 25 '20 09:04 RickDB

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.

MrDemocracy avatar Apr 25 '20 11:04 MrDemocracy

It should have logged to file so that's odd, thanks and will check the console logs now :)

RickDB avatar Apr 25 '20 11:04 RickDB

Our guessit implementation looks like the root cause so will try some solutions now.

RickDB avatar Apr 25 '20 11:04 RickDB

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.

RickDB avatar Apr 25 '20 11:04 RickDB

Guessit Exception: PlexAniSync-logs.zip

MrDemocracy avatar Apr 25 '20 12:04 MrDemocracy

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.

RickDB avatar Apr 25 '20 12:04 RickDB

Windows 10 64bit Python 3.8.2

MrDemocracy avatar Apr 25 '20 12:04 MrDemocracy

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 :)

RickDB avatar Apr 25 '20 12:04 RickDB

New logs: PlexAniSync.zip

MrDemocracy avatar Apr 25 '20 12:04 MrDemocracy

Updated to include encoding in logger creation:

https://gist.github.com/RickDB/d533c4d6f94a324bf8f049293a97bc85 https://gist.github.com/RickDB/dcd0158f2b84fd857041d27152a2171a

RickDB avatar Apr 25 '20 13:04 RickDB

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:

PlexAniSync_1.2.2a.zip

RickDB avatar Apr 25 '20 13:04 RickDB

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

MrDemocracy avatar Apr 25 '20 13:04 MrDemocracy

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 :)

RickDB avatar Apr 25 '20 14:04 RickDB

New version with debug logging restored:

PlexAniSync_1.2.2b.zip

RickDB avatar Apr 25 '20 14:04 RickDB

Still no debug log for me: PlexAniSync.zip

MrDemocracy avatar Apr 25 '20 15:04 MrDemocracy

Fixed in below version.

PlexAniSync_1.2.2c.zip

RickDB avatar Apr 25 '20 15:04 RickDB

The debug logs are back now: PlexAniSync.zip

MrDemocracy avatar Apr 25 '20 16:04 MrDemocracy

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.

RickDB avatar Apr 25 '20 17:04 RickDB

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.

MrDemocracy avatar Apr 25 '20 17:04 MrDemocracy

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.

PlexAniSync_1.2.2d.zip

RickDB avatar Apr 25 '20 17:04 RickDB

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

MrDemocracy avatar Apr 25 '20 19:04 MrDemocracy

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.

RickDB avatar Apr 25 '20 20:04 RickDB

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.

PlexAniSync_1.2.3.zip

RickDB avatar Apr 25 '20 20:04 RickDB