PlexMALSync - sync your Plex library to MyAnimeList

other-third-party

#1

This project started as I was tired of iffy scrobble support or having to use Trakt with an external service (txm.huere.net) to sync it that way, while the latter is fine it relies on having a public Trakt list and no options to correct mappings which I plan to add later.
Originally it was written in C# but the MAL library support isn't ideal so switched to Python 3 where everything just works out of the box.

So here's what the current version (0.0.1) can do:

  • Sync any Plex library / section to MyAnimeList and update status / watch count
  • Compare watch counts and only increment if we have new, so you don't mess up watch history
  • Title matching currently is based on standard and english title, improvements are planned like custom mappings and exact year matches (tricky with MAL it seems)

Documentation and code is located here:

https://github.com/RickDB/PlexMALSync

I recommend using HAMA with Plex like mentioned there as matching works pretty well with it, this is the first release so errors may occur but please let me know what you think.


#2

God, I’ve been waiting for something like this. I already have plex sync up with trackt but this will help so much.


#3

So gave this script a test run and it does not seem to update the shows correctly.

For shows I already had on my watching list it would update the episode count but won’t move to completed if the series is watched completely.

Secondly for shows not on any of my lists yet it does not add them in to a list (Watching, Completed, Etc) or actually update the episode count.
This can be fixed by using the add command in addition to the update command through spice.


#4

Completely watched will check now :slight_smile:

For the second question need a bit more info:

  • Are the shows not on your MAL list watched on Plex i.e. at least 1 episode fully watched?
  • Does the show name in Plex match exactly to that of MAL?

Because currently I only update shows that have a watch count in Plex, otherwise might end up with a lot of shows in your ‘plan to watch’ as MAL doesn’t have something like a general collection category.


#5

So the watch count in plex is >0.
MAL has not yet had the anime added to any list and has zero episodes watched.
I belive it happened with both titles that matched exactly and titles it had to find a match for.

It seems it shows up under anime history correctly but it does not get added to a list properly.
Without being added to a list when you visit the show page it shows 0 episodes watched.
I’m doing some edits on my own and using the add function seems to work in this case to properly add it to a list.

Still have a couple bugs to finish up fixing in my edited version.


#6

Gonna push a new version in a few minutes so if you want to do a PR best to base it off that one, corrected some matching and status updating.


#7

Ah whoops just put one in now, will redo it.

Also as a nice to have would be an output of all the titles that failed for not matching.


#8

No problem :slight_smile: , changes pushed and also added failure logging.
Tested here with a few shows and seems to work but let me how it goes, still learning Python so code might not be ideal right now however did clean it up a bit.

Next update gonna focus on config file to make it easier to push updates and year matching, next week though so feel free to make a pull request.
Be prepared for a bunch of MAL API bugs / limitations as it’s know for that :stuck_out_tongue:


#9

@OriginalFool Changes merged and thanks again :slight_smile:

Added settings file support and updated readme, will be a one time change as to make it easier to update with no messing in actual code for settings changes.
In short after updating to current the required steps are:

  • Copy settings.ini.example to settings.ini
  • Edit settings.ini with your mal / plex details
  • Done

Make sure to re-run pip install for the requirements (see readme) as a new one was added for console colors.


#10

First off, thank you so much for making this!

I’m having an issue when attempting to run the PlexMALSync.py script. Below is the issue (I’ve included the last successful item):

2018-03-12 12:59:36 Watched 14 episodes of show: The Melancholy of Haruhi Suzumiya
Traceback (most recent call last):
File “PlexMALSync.py”, line 89, in get_plex_watched_shows
if ((lookup_result.index > watched_episode_count[0] and lookup_result.seasonNumber == watched_episode_count[1]) or (lookup_result.seasonNumber > watched_episode_count[1])):
TypeError: ‘>’ not supported between instances of ‘NoneType’ and ‘int’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “PlexMALSync.py”, line 355, in
start()
File “PlexMALSync.py”, line 343, in start
plex_watched_shows = get_plex_watched_shows(plex_shows)
File “PlexMALSync.py”, line 92, in get_plex_watched_shows
logger.error(Back.RED +‘Error during lookup_result processing’)
NameError: name ‘Back’ is not defined

I’m guessing that lookup_result.index is resolving to a NoneType type, which I’m guessing is from a bad MAL sync? I’ve included my MAL details in settings.ini and confirmed that the user/pass I have in there is correct. Any ideas?

Thanks!


#11

Yeah Plex supplies us with incorrect data in that case, will patch that up today :smile:


#12

@ben.holub@gmail.com Pushed fixes, also had an old log message format which was the cause of the 2nd exception.
It does mean for that show we have no season number so might not be able to process that later on (defaults to season 1 if that’s the case), no such shows here so can’t test but let me know how it goes :smile:

Could also still be that an episode is watched in Plex but has no index which will make it skip over as it can’t reliably tell it has watched episodes, not sure how that can happen but you should see that during sync.


#13

@Rick164 Thank you so much! I made it past that point, and it looks like I might have hit the final error in this process.

2018-03-12 14:20:05 [MAL] Retrieving updated list for season matching…
Traceback (most recent call last):
File “PlexMALSync.py”, line 361, in
start()
File “PlexMALSync.py”, line 353, in start
updated_mal_list = update_mal_list_with_seasons(seasoned_list,plex_watched_shows)
File “PlexMALSync.py”, line 177, in update_mal_list_with_seasons
original_name_treated = matched_list[0][0].title
IndexError: list index out of range

I really appreciate your super fast response to the last one, completely understand if this one takes a little more time.

Thanks!


#14

It’s no problem :slight_smile: , think that one is MAL related as it’s missing either a date or range is invalid.
Added some additional checks which will log these and continue operation, plan to improve the overall code as with the new season lookups it’s harder to keep track of that many internal lists.


#15

Just sent

Sent from the Grateful iPhone
of Dr. Steve Fassman


#16

Hey @Rick164 just wanted to let you know I finally got it all of the way through the process, but I had to make a modification to where you’re casting lookup_show in update_mal_entry.

I wrapped that declaration in a try/except and logged an error if spice wasn’t able to get a MAL match on the show ID (in my case, the show exists and confirmed by checking the URL with the ID but w/e). Once that was wrapped in a try/except the whole process worked flawlessly.

Thanks again for all of your help!


#17

Awesome, might be that MAL isn’t returning anything or we run into a spice library error.
Added the try/catch there and just let me know if you spot any more bugs :smile:


#18

Lots of updates in the recent commits so worth checking out as other developers added some great improvements, readme has been updated so highly recommend to follow the new installation steps as we switched to pipenv for requirement management.


#19

Is there anyway you could clarify the installation process? I am fairly new to this kind of stuff, not even sure how I managed to build an ubuntu server from scratch and get plex running. Anywho, what do you mean by “project directory”? Like what do I download and where do I put them? Thanks!


#20

Project directory is where you placed the PlexMalSync files, I usually do a git clone as it makes updating easier but you can also download it directly in zip format:

https://github.com/RickDB/PlexMALSync/archive/master.zip

Unzip anywhere and afterwards follow the installation chapter:

You just need Python 3.6.4 or higher installed and should be good to go :smile: , would schedule the sync in a daily cronjob as that is what I do here so you don’t have to remind yourself to run it.