Jump to content

Plex Migrations Scripts


CloudWing93
Go to solution Solved by lionn1,

Recommended Posts

On 9/19/2023 at 8:10 AM, auroraemby said:

THANK YOU! are we allowed to slip you donations or something to keep this going?

I second this! This has saved me an ungodly amount of hours, a donation to the project is the least I can do.

Link to comment
Share on other sites

CloudWing93
On 10/2/2023 at 11:42 AM, Cr8iveLosr said:

Curious.

is it possible to use this script for plex skip intro and chapter thumbs to emby as well?

Thank you

Looking at the docs for the plexapi python library we can get whether plex has generated intro markers but it doesn't return what those markers are so I don't think it is possible at this time.

  • Thanks 1
Link to comment
Share on other sites

adminExitium
  • 2 weeks later...
Compulzive

Hi

Im new on emby - I alsp migrated from Plex. 

Then i saw that plex kill my acces, i ended up removing plex. Is it then still possible to Migrat the info?
im having some problems with identify tv show and episodes. 
 

Link to comment
Share on other sites

Hi there,

I'm trying to migrate the watch history and I am currently experiencing the below error once starting:

 

Starting Movie Matching for user: Kickflix.
movie match success using imdb -- Constantine
movie match success using imdb -- Dungeons & Dragons: Honor Among Thieves
movie match success using imdb -- Enemy
movie match success using imdb -- A Grand Day Out
movie match success using imdb -- A Perfect World

Starting TV Series Matching for user: Kickflix.
Traceback (most recent call last):
  File "/opt/p2e/watch-history-migration.py", line 200, in <module>
    migrateShowsHistory(plexClientAdminUser, EMBY_ADMIN_USERNAME)
  File "/opt/p2e/watch-history-migration.py", line 190, in migrateShowsHistory
    if embyWatched == False:
       ^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'embyWatched' where it is not associated with a value


Could you please share your insights and if there's something that has changed inside Emby? 

Link to comment
Share on other sites

  • Solution
On 16/10/2023 at 13:23, lionn1 said:

Hi there,

I'm trying to migrate the watch history and I am currently experiencing the below error once starting:

 

Starting Movie Matching for user: Kickflix.
movie match success using imdb -- Constantine
movie match success using imdb -- Dungeons & Dragons: Honor Among Thieves
movie match success using imdb -- Enemy
movie match success using imdb -- A Grand Day Out
movie match success using imdb -- A Perfect World

Starting TV Series Matching for user: Kickflix.
Traceback (most recent call last):
  File "/opt/p2e/watch-history-migration.py", line 200, in <module>
    migrateShowsHistory(plexClientAdminUser, EMBY_ADMIN_USERNAME)
  File "/opt/p2e/watch-history-migration.py", line 190, in migrateShowsHistory
    if embyWatched == False:
       ^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'embyWatched' where it is not associated with a value


Could you please share your insights and if there's something that has changed inside Emby? 

So going forward on this,

I have made a fork of the original and made some changes here.

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

*If anyone is going to use this, I am not aiming to make any public changes or fixes to this as this has mainly been to ensure that the scripts are working for myself, by no means would this mean I would be able to assist with many issues going forward at all. However if I do make any changes I will update the scripts accordingly.

Edits to the original:

I've split both migrations to be one for movies and one for tv. For myself, I have multiple TV libraries (Cartoons, TV, Anime etc) so to lighten the load on the script, I've split these apart so it's not constantly trying to migrate Movies every single time.

With this, the additions made to these are:

  • Watch data Scripts will run and output into "logs/[scriptname].log"
  • The initial coding has changed with small keyword changes to fit the changes in API's etc.

Learning from this I would ensure the below:

  • Ensure the Plex libraries are using either TVDB or TMDB instead of the Plex Series metadata, if you have to change this, I would highly recommend refreshing metadata. (Regarding the Hetzner difficulties, moving the plex server's full database into a local hosted service will assist in doing so)
  • Gaining the shared users' plex tokens has been difficult to do so without asking them to acquire this token for you. (I am looking into doing this via Plex User ID and just relying on the "Claimed Server Admin Token")
  • Some episodes in shows still have issues with matching. This can be a case where some words in episode names still aren't 100% accurate. EG: "Those Who Hunt: START" on Emby, and "Those Who Hunt: Start" on Plex. These won't migrate over until you change this on either Emby or Plex, however I would recommend changing this on Plex.

 

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

Hello,

I am also migrating from plex to emby and find this incredible script.

i'm using win 11, installed python and plex api.

i am only interested in migrating users watched history.

i have only one account on my plex server (no other home account) and a lot of users who i share my plex with.

The script worked perfectly for my account.

I managed to get my users plex token, but when i use the script with a user plex token of a shared user i got this error:

  File "C:\Users\Morgan\Downloads\watch-history-migration-movies.py", line 177, in <module>
    adminAccount = MyPlexAccount(token=PLEX_ADMIN_USER_TOKEN)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Morgan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\plexapi\myplex.py", line 125, in __init__
    data, initpath = self._signin(username, password, code, remember, timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Morgan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\plexapi\myplex.py", line 130, in _signin
    return self.query(self.key), self.key
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Morgan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\plexapi\myplex.py", line 240, in query
    raise Unauthorized(message)
plexapi.exceptions.Unauthorized: (401) unauthorized; https://plex.tv/api/v2/user <?xml version="1.0" encoding="UTF-8"?> <errors>   <error code="1001" message="User could not be authenticated" status="401"/> </errors>

Thanks for help.

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

I've used this script to migrate the admin user watched status and it worked great.  However I cannot figure out how to migrate the other shared users on Plex to a User on Emby.

Can someone please provide me with some help?

TIA

 

Link to comment
Share on other sites

  • 2 weeks later...
Adamaen
On 12/30/2023 at 6:53 AM, gregeeh said:

Hello,

I've used this script to migrate the admin user watched status and it worked great.  However I cannot figure out how to migrate the other shared users on Plex to a User on Emby.

Can someone please provide me with some help?

TIA

 

Hi,

Did you see my last post?

Link to comment
Share on other sites

  • 3 months later...

Hi!

Trying to use the script, but I'm getting the following error. Can someone help? Thanks :)

Getting Library Items. This can take a while.
Traceback (most recent call last):
  File "C:\Users\pierr\Downloads\plex-to-emby-migration-master (1)\plex-to-emby-migration-master\metadata-migration-tv.py", line 149, in <module>
    account = MyPlexAccount(PLEX_TOKEN)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pierr\AppData\Local\Programs\Python\Python312\Lib\site-packages\plexapi\myplex.py", line 125, in __init__
    data, initpath = self._signin(username, password, code, remember, timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pierr\AppData\Local\Programs\Python\Python312\Lib\site-packages\plexapi\myplex.py", line 138, in _signin
    data = self.query(self.SIGNIN, method=self._session.post, data=payload, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pierr\AppData\Local\Programs\Python\Python312\Lib\site-packages\plexapi\myplex.py", line 248, 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>

Link to comment
Share on other sites

Everything worked well, but I'm wondering if the script could also sync the episode title cards/posters for series? I see that the get emby episodes function is there, so it would be feasible right? Thanks!

Link to comment
Share on other sites

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...