# PlexMALSync - sync your Plex library to MyAnimeList

**URL:** <https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977>\
**Category:** Apps & Creations\
**Tags:** other-third-party\
**Created:** [January 25, 2018, 7:32pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977 "2018-01-25T19:32:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [January 25, 2018, 7:32pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/1 "2018-01-25T19:32:05Z")

</div>

This project started as I was tired of iffy scrobble support or having to use Trakt with an external service ([txm.huere.net](http://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:

> **[RickDB/PlexMALSync](https://github.com/RickDB/PlexMALSync)**
>
> Sync Plex anime library to MyAnimeList. Contribute to RickDB/PlexMALSync development by creating an account on GitHub.

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.

---

<div class="post-metadata">

**Author:** ![ccooluke](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ccooluke/32/84295_2.png) [@ccooluke](https://forums.plex.tv/u/ccooluke)\
**Post date:** [February 1, 2018, 3:19pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/2 "2018-02-01T15:19:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![OriginalFool](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/originalfool/32/114638_2.png) [@OriginalFool](https://forums.plex.tv/u/OriginalFool)\
**Post date:** [February 2, 2018, 9:29pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/3 "2018-02-02T21:29:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [February 2, 2018, 9:38pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/4 "2018-02-02T21:38:00Z")

</div>

Completely watched will check now 🙂

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.

---

<div class="post-metadata">

**Author:** ![OriginalFool](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/originalfool/32/114638_2.png) [@OriginalFool](https://forums.plex.tv/u/OriginalFool)\
**Post date:** [February 2, 2018, 10:59pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/5 "2018-02-02T22:59:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [February 2, 2018, 11:28pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/6 "2018-02-02T23:28:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![OriginalFool](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/originalfool/32/114638_2.png) [@OriginalFool](https://forums.plex.tv/u/OriginalFool)\
**Post date:** [February 2, 2018, 11:35pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/7 "2018-02-02T23:35:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [February 2, 2018, 11:56pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/8 "2018-02-02T23:56:25Z")

</div>

No problem 🙂 , 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 😛

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [February 3, 2018, 11:49am UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/9 "2018-02-03T11:49:32Z")

</div>

@OriginalFool Changes merged and thanks again 🙂

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.

---

<div class="post-metadata">

**Author:** ![ben.holub\_gmail.com](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@ben.holub\_gmail.com](https://forums.plex.tv/u/ben.holub_gmail.com)\
**Post date:** [March 12, 2018, 5:02pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/10 "2018-03-12T17:02:42Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [March 12, 2018, 5:04pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/11 "2018-03-12T17:04:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [March 12, 2018, 6:07pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/12 "2018-03-12T18:07:42Z")

</div>

@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 😄

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.

---

<div class="post-metadata">

**Author:** ![ben.holub\_gmail.com](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@ben.holub\_gmail.com](https://forums.plex.tv/u/ben.holub_gmail.com)\
**Post date:** [March 12, 2018, 6:35pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/13 "2018-03-12T18:35:08Z")

</div>

@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!

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [March 12, 2018, 7:13pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/14 "2018-03-12T19:13:13Z")

</div>

It’s no problem 🙂 , 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.

---

<div class="post-metadata">

**Author:** ![ststephen](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ststephen/32/16272_2.png) [@ststephen](https://forums.plex.tv/u/ststephen)\
**Post date:** [March 12, 2018, 7:35pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/15 "2018-03-12T19:35:29Z")

</div>

Just sent

Sent from the Grateful iPhone  
of Dr. Steve Fassman

---

<div class="post-metadata">

**Author:** ![ben.holub\_gmail.com](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@ben.holub\_gmail.com](https://forums.plex.tv/u/ben.holub_gmail.com)\
**Post date:** [March 12, 2018, 9:04pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/16 "2018-03-12T21:04:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [March 12, 2018, 9:11pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/17 "2018-03-12T21:11:32Z")

</div>

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 😄

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [March 30, 2018, 12:34pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/18 "2018-03-30T12:34:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TheHoudhini](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@TheHoudhini](https://forums.plex.tv/u/TheHoudhini)\
**Post date:** [May 11, 2018, 12:18am UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/19 "2018-05-11T00:18:08Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Rick164](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/rick164/32/206080_2.png) [@Rick164](https://forums.plex.tv/u/Rick164)\
**Post date:** [May 12, 2018, 1:56pm UTC](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977/20 "2018-05-12T13:56:36Z")

</div>

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://codeload.github.com/RickDB/PlexMALSync/zip/master>
>
> //codeload.github.com/RickDB/PlexMALSync/zip/master

Unzip anywhere and afterwards follow the installation chapter:

> <https://github.com/RickDB/PlexMALSync/blob/master/README.md>

You just need Python 3.6.4 or higher installed and should be good to go 😄 , 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.

[Next page](https://forums.plex.tv/t/plexmalsync-sync-your-plex-library-to-myanimelist/222977.md?page=2)
