Jump to content

Plex Migrations Scripts


CloudWing93
Go to solution Solved by lionn1,

Recommended Posts

CloudWing93
13 minutes ago, Tangsgod said:

Yes, that would be great if it could skip  the updated ones! As it lost connection at the letter "A" movie "Alien" it didn't have to reupdate a lot, but for sure at the letter "Y" it would be something else :)

About the speed I am on a wired 1gb/s connection so I didn't think it would slowdown the process, don't you think?

There would still be a fairly significant slowdown. The api calls the scrips uses don’t necessarily use a lot of bandwidth. It’s more about latency. How long does it take to initiate the connection. That will always be much faster in a local network.

  • Thanks 1
Link to comment
Share on other sites

Tangsgod
1 minute ago, CloudWing93 said:

There would still be a fairly significant slowdown. The api calls the scrips uses don’t necessarily use a lot of bandwidth. It’s more about latency. How long does it take to initiate the connection. That will always be much faster in a local network.

Ok! I'll leave it for now like this, but I'll change it for the large series librairie :)

Link to comment
Share on other sites

Tangsgod

Hi @CloudWing93 thanx for the update!

 

I was running in few errors:
 

Error updating metadata for - The Wrong Trousers
movie match success using imdb -- The Wrong Trousers
Failed to parse json response for Emby API cmd '/Users/None/Items/167617?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - The Wrong Trousers
movie match success using imdb -- The Wrong Trousers
Failed to parse json response for Emby API cmd '/Users/None/Items/4807?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - A Close Shave
movie match success using imdb -- A Close Shave
Failed to parse json response for Emby API cmd '/Users/None/Items/167618?Recursive=true': b'Input string was not in a correct format.'
Traceback (most recent call last):
  File "C:\Users\Tangs\Desktop\plex-to-emby-migration-master\metadata-migration.py", line 191, in <module>
    data['Name'] = plexMovie.title
TypeError: 'NoneType' object does not support item assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Tangs\Desktop\plex-to-emby-migration-master\metadata-migration.py", line 204, in <module>
    print(f'Error updating metadata for - {m["Name"]}')
KeyError: 'Name'

C:\Users\Tangs\Desktop\plex-to-emby-migration-master>

So I couldn't finish the scan, is there something I can do?

Link to comment
Share on other sites

Tangsgod

So, I retried the previous version: it did the job until the end, sorted all the movies that didn't match but obviously did a full scan of all the movies.

Now I just retry the new version and all I have is those errors:

Error updating metadata for - The Bourne Legacy
movie match success using imdb -- The Bourne Legacy
Failed to parse json response for Emby API cmd '/Users/None/Items/512?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - Jason Bourne
movie match success using imdb -- Jason Bourne
Failed to parse json response for Emby API cmd '/Users/None/Items/5332?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - Jason Bourne
movie match success using imdb -- Jason Bourne
Failed to parse json response for Emby API cmd '/Users/None/Items/3452?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - The Box
movie match success using imdb -- The Box

Also, i wonder if the match could be done rather with the file name instead of the imdb ID ? 

I' m asking this because Emby agent isn't good as the plex one, so it matched few movies with bad imdb ID choices and then the script don't find them

Edited by Tangsgod
Link to comment
Share on other sites

CloudWing93
On 2/6/2022 at 9:25 AM, Tangsgod said:

So, I retried the previous version: it did the job until the end, sorted all the movies that didn't match but obviously did a full scan of all the movies.

Now I just retry the new version and all I have is those errors:

Error updating metadata for - The Bourne Legacy
movie match success using imdb -- The Bourne Legacy
Failed to parse json response for Emby API cmd '/Users/None/Items/512?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - Jason Bourne
movie match success using imdb -- Jason Bourne
Failed to parse json response for Emby API cmd '/Users/None/Items/5332?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - Jason Bourne
movie match success using imdb -- Jason Bourne
Failed to parse json response for Emby API cmd '/Users/None/Items/3452?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - The Box
movie match success using imdb -- The Box

Also, i wonder if the match could be done rather with the file name instead of the imdb ID ? 

I' m asking this because Emby agent isn't good as the plex one, so it matched few movies with bad imdb ID choices and then the script don't find them

Have you been setting EMBY_USERNAME? in one of the more recent versions I updated it to use your emby username instead of the userID because it was hard for some people to find and was a little unnecessary. 

I can maybe add a fallback match for name

Edited by CloudWing93
Link to comment
Share on other sites

Tangsgod
On 2/1/2022 at 3:26 AM, CloudWing93 said:

It's also possible that there is a typo or something like that in the library name you are passing through so plex isn't actually returning any tv shows.

Hi!
Yes, I use exactly the same settings as the previous version. The previous one is working while this one retrun errors for each files

Link to comment
Share on other sites

CloudWing93
20 hours ago, Tangsgod said:

Hi @CloudWing93,

Do you think you will update the last script to make it work? :)

I haven't been able to replicate your issues with the current version. The None in /Users/None/Items/512?Recursive=true tells me that EMBY_USERNAME is not getting set with the username and not the userID.

Did you see my previous posts explaining that you need to change that?

 

On 2/7/2022 at 10:00 PM, CloudWing93 said:

Have you been setting EMBY_USERNAME? in one of the more recent versions I updated it to use your emby username instead of the userID because it was hard for some people to find and was a little unnecessary. 

 

On 2/3/2022 at 10:37 AM, CloudWing93 said:

This is fixed now with the latest version.  I replaced the EMBY_USER_ID variable with the EMBY_USERNAME field. So you'll need to swap that out.

It's also worth noting that it's looking for the local username not the emby connect username.

Edited by CloudWing93
Link to comment
Share on other sites

Tangsgod
On 2/15/2022 at 7:15 PM, CloudWing93 said:

I haven't been able to replicate your issues with the current version. The None in /Users/None/Items/512?Recursive=true tells me that EMBY_USERNAME is not getting set with the username and not the userID.

Did you see my previous posts explaining that you need to change that?

 

 

It's also worth noting that it's looking for the local username not the emby connect username.

Hi!

I saw your post and I changed it to my EMBY_USERNAME however, I'm still facing the same errors.
I sent you more infos to look at by MP. Could you have a look?

@mbuhmann did you managed to run the last script without errors?

Link to comment
Share on other sites

Tangsgod

@CloudWing93 do you think that it would be possible to make the script detects the changes made in Plex and apply it automaticly to Emby ?

Like, if we change a poster, or a title of a movie it will then change it to Emby without having to run it manually ? 

Edited by Tangsgod
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...
griebs

Awesome script! Exactly what I was looking for, thanks so much for your efforts.

Is there any way to export subtitle and audio track preference? I know Plex remembers this setting for future views so it must be saved somewhere in the metadata.

I spent about 2 hours going through every MKV in my archive (on Plex) and would prefer not to do it anew with Emby.

Thanks again!

Link to comment
Share on other sites

  • 1 month later...
bigverm23

is this still active? I ran to attempt to import Plex tags as I understood it would work, but nothing appears to be imported into Emby, although the script would indicate success...any thoughts?

Link to comment
Share on other sites

  • 2 weeks later...
bigverm23

how exactly does the metadata migration work?  I have custom labels/tags on my Plex stuff but after running the script Emby only seems to show as "migrated"...what does that mean?

Link to comment
Share on other sites

80srule
On 7/30/2020 at 1:41 PM, CloudWing93 said:

I spent lots of  time looking for a script that would migrate user watched history from plex to emby without luck so I decided to just write one myself. This project contains a few python scripts that will help you migrate some of the data from your plex server to you emby server. The scripts match using IMDB, TVDB , and TMDB.  Right now there are two main scripts.

The first one is named metadata-migration.py . It will migrate the following data:

  • Posters
  • Title
  • Original Title
  • Sort Title
  • Parental Rating
  • Labels/Tags

 

The second one is named watched-history-migration.py . This script can migrate watched history for any user but there is a caveat. You have to be able to get that user's plex token. Checkout the readme in the project repository for more details. It will migrate the following data:

  • Watched History


https://gitlab.com/CloudWing93/plex-to-emby-migration

I get nothing but errors when running this. 

Link to comment
Share on other sites

  • 9 months later...
Sarge88

Just tried this script on windows using the power shell and it worked flawlessly! Wonder if there is a way to help it match movies and shows that it couldn't match. Maybe forcing Plex to use IMDb as it's meta source and force a meta refresh??? Will look into that tomorrow.

 

Thanks for the script, Ive been searching for something like this ever since I switched from Plex to emby. 

Link to comment
Share on other sites

  • 1 month later...

Hi Everyone!

 

Firstly, Thanks for this. It has made my move from plex of 10+ years to Emby a no brainer.

 

I was able to get things working for the primary plex user by NOT using the token and using the username and password directly. This is great, but I am trying to also move my managed users (mainly my wife... the kids and deal with it 😉 ).  When trying to use the primary plex token OR the token associated to her managed user, I receive the follow error:

 

Traceback (most recent call last):
  File "/mnt/cache/appdata/scripts/plex-to-emby-migration/watch-history-migration.py", line 144, in <module>
    account = MyPlexAccount(PLEX_TOKEN)
  File "/usr/lib64/python3.9/site-packages/plexapi/myplex.py", line 122, in __init__
    data, initpath = self._signin(username, password, code, remember, timeout)
  File "/usr/lib64/python3.9/site-packages/plexapi/myplex.py", line 135, in _signin
    data = self.query(self.SIGNIN, method=self._session.post, data=payload, timeout=timeout)
  File "/usr/lib64/python3.9/site-packages/plexapi/myplex.py", line 241, in query
    raise BadRequest(message)
plexapi.exceptions.BadRequest: (400) bad_request; https://plex.tv/api/v2/users/signin <?xml version="1.0" encoding="UTF-8"?> <errors>   <error code="1004" message="password is missing" status="400"/> </errors> 

My script has the following for plex token 

## The plex token should be for the user you are trying to migrate history for.
# Check out the readme for more info
PLEX_TOKEN = "zzz123zzz" <--actual plex token removed

Line 144:

account = MyPlexAccount(PLEX_TOKEN)

I tried looking at the plex api documentation, and that is how I was able to get the username and password to work properly, but no joy with the token.

Can anyone please point me in the right direction?

Link to comment
Share on other sites

CloudWing93

I wrote this 3 years ago and have done basically no maintenance since. In that time it looks like Plex might have changed their API a little bit. I think the second code block from this section of the docs is what you are looking for.

https://github.com/pkkid/python-plexapi#getting-a-plexserver-instance

I haven't tested this but I think this should work:

# Add this to the import section at the top of the script
from plexapi.server import PlexServer

# Replace lines 144-145 in the watch history migration script with:
# Replace lines 160-161 in the metadata migration script with:
plexClient = PlexServer(PLEX_URL, PLEX_TOKEN)

 

Edited by CloudWing93
Link to comment
Share on other sites

Awesome thanks so much. I will try it..

 

Do you happen to know if there's a way to copy the watch status for a Plex user that I share my server with but they don't have their own Plex server?

Link to comment
Share on other sites

That tweak worked, but only for the plex master user.

Also 1 More thing,  Doing this for managed users doesn't seem to produce any results at all even when using the proper plex token for that user, the proper username in emby.. I just get empty sets.

 

Any guidance on that piece would also be greatly appreciated.

Link to comment
Share on other sites

CloudWing93

I spun up a test server and made some tweaks to the script. It should work for your home users now. I was able to leverage the 'switchHomeUser' function so you will only need the admin user token.

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...