Jump to content

Plex Migrations Scripts


Go to solution Solved by lionn1,

Recommended Posts

Posted (edited)

Thank you for the non-match list, i think it will be really helpfull, specialy for large librairies. 

I'll dig into my series issu and let you know how it goes. 

About the metadata script, will it export the "title", "original title" and  the "sort title"? 

And would it be a big thing to ask you to make a "plex-emby-migration-var.py" like you did for the posters one?

Edited by Tangsgod
CloudWing93
Posted
9 hours ago, Tangsgod said:

About the metadata script, will it export the "title", "original title" and  the "sort title"? 

Good news. Originally the script didn't pull any of that information but I added the functionality with this script. It will set the "title", "original title", "sort title", "parental rating", and "labels/tags"

There is one notable change in required information. An addition variable needs to be set at the top of the script for "embyUserID" 

Any userID will work as long the user has access to the media files. You can find the user id by looking up the user in the admin console and then looking in the url. You will be looking for something that looks like this:
 

userId=xxxxxxxxxxx

poster-migration-var.py

thunderclap
Posted (edited)

Would it be possible to update the docker here? https://hub.docker.com/layers/cloudwing93/plex-emby-migration/latest/images/sha256-f6b54f51b1f6b580b2e9e17b1fa88454bb0707faae1350c51471f20c8a16c958?context=explore

Never mind. I saw in a follow-up post that it needs to be run manually, so now I need to figure out how best to do that in Unraid.

Also, do my users need to get their own Plex token, or is that something as the admin of my server can get?

Edited by mbuhmann
CloudWing93
Posted
16 minutes ago, mbuhmann said:

Never mind. I saw in a follow-up post that it needs to be run manually, so now I need to figure out how best to do that in Unraid.

Also, do my users need to get their own Plex token, or is that something as the admin of my server can get?

I just updated the repository with some updated scripts. Check them out here:
https://gitlab.com/CloudWing93/plex-to-emby-migration

The script in its current form is probably best run on your desktop.  Unfortunately your users will need to get you their own token. If there are members of your plex home that you can login as them you can get their tokens by following this guide:

 https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/

thunderclap
Posted (edited)
15 minutes ago, CloudWing93 said:

I just updated the repository with some updated scripts. Check them out here:
https://gitlab.com/CloudWing93/plex-to-emby-migration

The script in its current form is probably best run on your desktop.  Unfortunately your users will need to get you their own token. If there are members of your plex home that you can login as them you can get their tokens by following this guide:

 https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/

Downloaded.

So I'm no expert in Python, so here's what I've down. I've installed Python 3.10 onto my Windows system and moved your python scripts to its directory. I then run

python watch-history-migration.py --plexUrl "http://192.168.50.39:32400" --plexAuthToken "xxx" --plexServerName "My Plex" --plexMovieLibraries "Movies","Kids Movies" --plexSeriesLibraries "TV Shows" --embyUrl "http://192.168.50.39:8096" --embyApiKey "xxx" --embyUserID "xxx"

xxx being items not needed here, obviously.

I then get the following error:

 

Traceback (most recent call last):
  File "c:\Python\Python310\watch-history-migration.py", line 1, in <module>
    from plexapi.myplex import MyPlexAccount
ModuleNotFoundError: No module named 'plexapi'

Any pointers?

I guess it would help if I read the updated docs. 

Edited by mbuhmann
CloudWing93
Posted
1 minute ago, mbuhmann said:

Traceback (most recent call last):
  File "c:\Python\Python310\watch-history-migration.py", line 1, in <module>
    from plexapi.myplex import MyPlexAccount
ModuleNotFoundError: No module named 'plexapi'

Any pointers?

you need to install it using pip. It should look something like:
 

pip install plexapi

 

3 minutes ago, mbuhmann said:

Downloaded.

So I'm no expert in Python, so here's what I've down. I've installed Python 3.10 onto my Windows system and moved your python scripts to its directory. I then run

python watch-history-migration.py --plexUrl "http://192.168.50.39:32400" --plexAuthToken "xxx" --plexServerName "My Plex" --plexMovieLibraries "Movies","Kids Movies" --plexSeriesLibraries "TV Shows" --embyUrl "http://192.168.50.39:8096" --embyApiKey "xxx" --embyUserID "xxx"

I also just updated the script to not use arguments anymore. I also added a bunch of other improvements. You should download the latest version from the repository.
Now you just have to edit a few variables at the top of the python file.

  • Thanks 1
Posted

Ok, I made it worked with the series, the name of the librairie were not exactly the same and I was using the TVDB instead of the IMDB.

Now I'm updating my metadata in french because I want all my synopsis in french, then I'll use the new metadata-migration.py script and watch it make its magic :)

I'll let you know how it goes :)

CloudWing93
Posted
2 minutes ago, Tangsgod said:

Ok, I made it worked with the series, the name of the librairie were not exactly the same and I was using the TVDB instead of the IMDB.

Awesome, that's good to hear. Also it should still be able to match using TVDB as well as long as both plex and emby have downloaded the ID from that provider.

thunderclap
Posted

Can we still list multiple libraries (i.e. "Movies","Kid Movie") or only one? Because I'm getting the following error:

Getting Library Items. This can take a while.
Traceback (most recent call last):
  File "c:\Python\Python310\watch-history-migration.py", line 134, in <module>
    plexMovieLibraries = PLEX_MOVIE_LIBRARIES.split(",")
AttributeError: 'tuple' object has no attribute 'split'

Posted
1 minute ago, mbuhmann said:

Can we still list multiple libraries (i.e. "Movies","Kid Movie") or only one? Because I'm getting the following error:

Getting Library Items. This can take a while.
Traceback (most recent call last):
  File "c:\Python\Python310\watch-history-migration.py", line 134, in <module>
    plexMovieLibraries = PLEX_MOVIE_LIBRARIES.split(",")
AttributeError: 'tuple' object has no attribute 'split'

I also ran into this error, are you sure that your librairies in Plex and in Emby have exactly the same name? Double check ;)

thunderclap
Posted
2 minutes ago, Tangsgod said:

I also ran into this error, are you sure that your librairies in Plex and in Emby have exactly the same name? Double check ;)

Just looked and everything is named the same.

CloudWing93
Posted
3 minutes ago, Tangsgod said:

I also ran into this error, are you sure that your librairies in Plex and in Emby have exactly the same name? Double check ;)

You can I just got the example wrong. you don’t have to put quotes around each one. So it should look something like “movies,kids movies”

  • Like 2
thunderclap
Posted

That did it. Appreciate you taking the time to answer all the questions. :)

thunderclap
Posted

One more question: once the migration has happened so I need to log out and back in or restart Emby or anything? The migration seems like it worked but shows and movies I know I’ve watched or haven’t watched aren’t been flagged properly. 

CloudWing93
Posted
36 minutes ago, mbuhmann said:

One more question: once the migration has happened so I need to log out and back in or restart Emby or anything? The migration seems like it worked but shows and movies I know I’ve watched or haven’t watched aren’t been flagged properly. 

It could take a refresh or two for Emby to show some of the changes. There also could be some that weren’t matched correctly so they didn’t get marked as played in Emby. The new version of the script spits out a section at the bottom that shows which episodes and movies that didn’t get matched.

  • Like 1
  • Thanks 1
Posted (edited)

Mmmmh, I'm running into some errors:

 

Error updating metadata for - Wet Hot American Summer
movie match success using imdb -- Wet Hot American Summer
Error updating metadata for - Wet Hot American Summer
movie match success using imdb -- Wet Hot American Summer

It is like this for all the movies and Tv shows, it fails to update eveything

 

If I try with a previous version of the script here is what I get:
 

Error updating metadata for - Wet Hot American Summer
show match success using imdb -- Peacemaker bibi
Failed to parse json response for Emby API cmd '/Users/b75da479dbb64afa9655be20ff6cf2fd&/Items/76902?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - Wet Hot American Summer
show match success using imdb -- Peacemaker bibi
Failed to parse json response for Emby API cmd '/Users/b75da479dbb64afa9655be20ff6cf2fd&/Items/251789?Recursive=true': b'Input string was not in a correct format.'
Error updating metadata for - Wet Hot American Summer

If it can help...

Edited by Tangsgod
thunderclap
Posted

I'm getting something similar. The error I see is:

Failed to parse json response for Emby API cmd '/Users/Marc/PlayedItems/5127': b'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'

I tried changing the Emby API to match with the hyphens but then I get the error:

Failed to parse json response for Emby API cmd '/Items?Recursive=true&AnyProviderIdEquals=imdb.tt0096734&Fields=ProviderIds&IncludeItemTypes=Movie': b'Access token is invalid or expired.'
Traceback (most recent call last):
  File "c:\Python\Python310\watch-history-migration.py", line 148, in <module>
    if len(em['Items']) > 0 and embyWatched == False:
TypeError: 'NoneType' object is not subscriptable

CloudWing93
Posted
22 hours ago, Tangsgod said:

Mmmmh, I'm running into some errors:

Error updating metadata for - Wet Hot American Summer
movie match success using imdb -- Wet Hot American Summer
Error updating metadata for - Wet Hot American Summer
movie match success using imdb -- Wet Hot American Summer

It is like this for all the movies and Tv shows, it fails to update eveything

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.

CloudWing93
Posted
17 hours ago, mbuhmann said:

I'm getting something similar. The error I see is:

Failed to parse json response for Emby API cmd '/Users/Marc/PlayedItems/5127': b'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'

I tried changing the Emby API to match with the hyphens but then I get the error:

Failed to parse json response for Emby API cmd '/Items?Recursive=true&AnyProviderIdEquals=imdb.tt0096734&Fields=ProviderIds&IncludeItemTypes=Movie': b'Access token is invalid or expired.'
Traceback (most recent call last):
  File "c:\Python\Python310\watch-history-migration.py", line 148, in <module>
    if len(em['Items']) > 0 and embyWatched == False:
TypeError: 'NoneType' object is not subscriptable

This is also fixed with the latest version. 

  • Like 1
thunderclap
Posted
19 minutes ago, CloudWing93 said:

This is also fixed with the latest version. 

Thanks a lot for all your hard work and help. Do you accept donations? I'd love to send you a little something.

Posted

Hi @CloudWing93!

Here is an issue i'm running on:

movie match success using imdb -- Alien : Covenant
movie match success using imdb -- Alien : Covenant
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Program Files\Python310\lib\http\client.py", line 1374, in getresponse
    response.begin()
  File "C:\Program Files\Python310\lib\http\client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "C:\Program Files\Python310\lib\http\client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Program Files\Python310\lib\socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "C:\Program Files\Python310\lib\ssl.py", line 1273, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Program Files\Python310\lib\ssl.py", line 1129, in read
    return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\requests\adapters.py", line 440, in send
    resp = conn.urlopen(
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "C:\Program Files\Python310\lib\site-packages\urllib3\util\retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Program Files\Python310\lib\site-packages\urllib3\packages\six.py", line 770, in reraise
    raise value
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 451, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 340, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='192-168-1-89.41c570add2ab458d8e6581c75c71e304.plex.direct', port=32400): Read timed out. (read timeout=30)

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 178, in <module>
    for id in plexMovie.guids:
  File "C:\Program Files\Python310\lib\site-packages\plexapi\base.py", line 471, in __getattribute__
    self._reload(_autoReload=True)
  File "C:\Program Files\Python310\lib\site-packages\plexapi\base.py", line 350, in _reload
    data = self._server.query(key)
  File "C:\Program Files\Python310\lib\site-packages\plexapi\server.py", line 672, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='192-168-1-89.41c570add2ab458d8e6581c75c71e304.plex.direct', port=32400): Read timed out. (read timeout=30)

Is there something I can do?

CloudWing93
Posted
2 hours ago, Tangsgod said:

Hi @CloudWing93!

Here is an issue i'm running on:

movie match success using imdb -- Alien : Covenant
movie match success using imdb -- Alien : Covenant
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Program Files\Python310\lib\http\client.py", line 1374, in getresponse
    response.begin()
  File "C:\Program Files\Python310\lib\http\client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "C:\Program Files\Python310\lib\http\client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Program Files\Python310\lib\socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "C:\Program Files\Python310\lib\ssl.py", line 1273, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Program Files\Python310\lib\ssl.py", line 1129, in read
    return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\requests\adapters.py", line 440, in send
    resp = conn.urlopen(
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "C:\Program Files\Python310\lib\site-packages\urllib3\util\retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Program Files\Python310\lib\site-packages\urllib3\packages\six.py", line 770, in reraise
    raise value
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 451, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Program Files\Python310\lib\site-packages\urllib3\connectionpool.py", line 340, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='192-168-1-89.41c570add2ab458d8e6581c75c71e304.plex.direct', port=32400): Read timed out. (read timeout=30)

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 178, in <module>
    for id in plexMovie.guids:
  File "C:\Program Files\Python310\lib\site-packages\plexapi\base.py", line 471, in __getattribute__
    self._reload(_autoReload=True)
  File "C:\Program Files\Python310\lib\site-packages\plexapi\base.py", line 350, in _reload
    data = self._server.query(key)
  File "C:\Program Files\Python310\lib\site-packages\plexapi\server.py", line 672, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\requests\adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='192-168-1-89.41c570add2ab458d8e6581c75c71e304.plex.direct', port=32400): Read timed out. (read timeout=30)

Is there something I can do?

It looks like the script is trying to connect to your plex server but it can't reach it. Has your public plex address changed?

Posted
13 minutes ago, CloudWing93 said:

It looks like the script is trying to connect to your plex server but it can't reach it. Has your public plex address changed?

I didn't change anything, there is no reason it would have changed.

I restarted the script and it goes through, now it at the letter "B" .  I'm using it now and my large librairie (6000 movies). Seeing the speed ot the export I think it will finish the job in 20/24 hours from now :)

I'll keep you updated!

CloudWing93
Posted
10 minutes ago, Tangsgod said:

I didn't change anything, there is no reason it would have changed.

I restarted the script and it goes through, now it at the letter "B" .  I'm using it now and my large librairie (6000 movies). Seeing the speed ot the export I think it will finish the job in 20/24 hours from now :)

I'll keep you updated!

That’s quite I while. I can see if I can batch it by checking if a tag exists first so it would only try and update the ones that haven’t been migrated yet. That way if it fails you don’t have to start from the beginning again. Also it if possible I would recommend using your local IP address because it would speed things up by quite a bit.

Posted
1 minute ago, CloudWing93 said:

That’s quite I while. I can see if I can batch it by checking if a tag exists first so it would only try and update the ones that haven’t been migrated yet. That way if it fails you don’t have to start from the beginning again. Also it if possible I would recommend using your local IP address because it would speed things up by quite a bit.

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?

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