Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MrDemocracy opened this issue Apr 22, 2020 · 43 comments
Open

Comments

@MrDemocracy
Copy link

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.

RickDB pushed a commit that referenced this issue Apr 24, 2020
@RickDB
Copy link
Owner

RickDB commented Apr 24, 2020

Added 👍

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

@MrDemocracy
Copy link
Author

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.

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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

@MrDemocracy
Copy link
Author

Here you go: PlexAniSync-logs.zip

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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
Copy link
Owner

RickDB commented Apr 25, 2020

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

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

@MrDemocracy
Copy link
Author

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.

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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.

@MrDemocracy
Copy link
Author

Guessit Exception: PlexAniSync-logs.zip

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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.

@MrDemocracy
Copy link
Author

Windows 10 64bit
Python 3.8.2

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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

@MrDemocracy
Copy link
Author

New logs: PlexAniSync.zip

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

@MrDemocracy
Copy link
Author

PlexAniSync.zip

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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

@MrDemocracy
Copy link
Author

MrDemocracy commented Apr 25, 2020

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

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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
Copy link
Owner

RickDB commented Apr 25, 2020

New version with debug logging restored:

PlexAniSync_1.2.2b.zip

@MrDemocracy
Copy link
Author

Still no debug log for me: PlexAniSync.zip

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

Fixed in below version.

PlexAniSync_1.2.2c.zip

@MrDemocracy
Copy link
Author

The debug logs are back now: PlexAniSync.zip

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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.

@MrDemocracy
Copy link
Author

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.

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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

@MrDemocracy
Copy link
Author

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

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

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
Copy link
Owner

RickDB commented Apr 25, 2020

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

@MrDemocracy
Copy link
Author

MrDemocracy commented Apr 25, 2020

Okay, got one step further now. Ponyo got detected this time, but it was matched incorrectly to 5702. In fact it seems like all "original title" results have incorrect Anilist id's, though I haven't checked every one of them.
I'm also seeing a lot of Found match however started year is a mismatch in a row, with a varying years on each line.

Here's the latest logs: PlexAniSync.zip

I just realized I have a Raspberry Pi at the same location where my Plex server is, so I've installed docker on it and I did the pull command for rickdb/plexanisync. But I have no idea how to use docker, so I'm not sure how to proceed with doing the same kind of tests on docker.

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

For the mismatch it might be guessit fuzzy matching, new test version below to rule this out:

PlexAniSync_1.2.3a.zip

The docker docs need updating with some steps for users new to Docker and will see about adding them 👍

@MrDemocracy
Copy link
Author

PlexAniSync.zip

I will do some reading on docker later, but a guide would definitely be helpful for new users.

@RickDB
Copy link
Owner

RickDB commented Apr 25, 2020

Updated docs pushed some tweaks mostly for small fine tuning the title searches and reduce unnecessary load on the AniList API:

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

Back on this early next week but if you found out more please don't hesitate to post :)

@RickDB
Copy link
Owner

RickDB commented Apr 29, 2020

Updated docker docs and with the latest version do you still have issues with matching?

@MrDemocracy
Copy link
Author

When I try to run the docker image using docker run, with the same parameters as the create command from the docs, I get this error message:
ERRO[0003] error waiting for container: context canceled

On windows I've not been able to sync any movie using the "original title"-feature. It just adds some seemingly random other movie to anilist, for every movie.
I tried setting up custom_mappings, but I'm not sure how to do it for movies, and couldn't get it to work.
While doing this, I was also mapping some series and discovered another bug; When I map a season from a series that didn't have any problems being matched with anilist, plexanisync get's stuck in a loop.
I can make a new issue for this bug if you prefer that, but I probably won't have time to do it before in a couple of hours.

@RickDB
Copy link
Owner

RickDB commented Apr 30, 2020

Disabling original title for the time being and will test it again later, do have a rework on the matching in progress which uses XREF sources like HAMA does at the moment
Will improve matching so we rely less on what Plex supplies title wise at least, still a few weeks off depending on current workload though.

Keeping it in this issue is fine :)

@MrDemocracy
Copy link
Author

Not sure which cross reference sources HAMA uses (thetvdb?), but sound great!
Does this mean individual episodes could also be matched for series like Bleach where all the seasons are just merged into one season on Anilist? And the other way around for series like JoJo, where Stardust Crusaders is split up in two part on Anilist, unlike how it's listed on other databases.

Here's the logs for the loop issue described I above: PlexAniSync.1.2.4.zip
Just to clarify; When doing the sync with custom_mappings.ini disabled, The Familiar of Zero season 1 get matched automatically and it continues searching for the next series, but enabling custom mappings where the line The Familiar of Zero^1^1195 is added, causes it to get stuck in a loop when searching for it on Anilist.
This isn't a major issue, since you can just remove the series causing the issue from custom_mappings.ini and it will be matched anyway, so it's up to you if you think this is something that needs to be fixed or not.

@RickDB
Copy link
Owner

RickDB commented May 1, 2020

Hama uses several lists (AniDB / TVDB) and a cross reference table managed by anime community, integrating it will vastly improve matching but want to clean up the code first so it fits in perfectly :)

Thanks for the logs and will fix the loop today.

@RickDB
Copy link
Owner

RickDB commented May 1, 2020

Pushed fix for loop and if you can retry with latest version of this repo that would be great 👍

@MrDemocracy
Copy link
Author

Didn't get stuck in loop this time :)
Here's the logs: PlexAniSync.zip

@RickDB
Copy link
Owner

RickDB commented May 1, 2020

Awesome, thanks for testing again 👍

Hopefully by end of the month I can fork over the HAMA code for XREF matching (AniDB / TVDB) so we can get matching on par with that but it all depends on my workload.

@MrDemocracy
Copy link
Author

Looking forward to it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants