Casvt / Plex-scripts

Plex, the arr's and tautulli scripts coming from user requests
GNU General Public License v3.0
338 stars 30 forks source link

plex_exporter_importer.py: Handle having no shared users #139

Closed razzamatazm closed 2 years ago

razzamatazm commented 2 years ago

I'm moving my intro markers from a baremetal install to a docker install on a separate machine. I ran into this error:

razzamatazm@vmi967163:~$ sudo python3 plexdbtool.py -t import -p intro_marker -L /home/razzamatazm/plexdbtool.db --AllShow
Importing from /home/razzamatazm/plexdbtool.db
You're going to import the following:
        The intro marker of episodes, which describes the beginning and end of the intro.
This is going to be done for all show libraries.

4K TV Shows
Shutting down...
Progress saved
AN ERROR OCCURED. ALL YOUR PROGRESS IS SAVED. PLEASE SHARE THE FOLLOWING WITH THE DEVELOPER:
Traceback (most recent call last):
  File "plexdbtool.py", line 1294, in <module>
    artist_name=args.ArtistName, album_name=args.AlbumName, track_name=args.TrackName
  File "plexdbtool.py", line 1225, in plex_exporter_importer
    _leave(**exit_args, e=e)
  File "plexdbtool.py", line 419, in _leave
    raise e
  File "plexdbtool.py", line 1111, in plex_exporter_importer
    response = method(type='show', data=show_info, watched_map=watched_map, timestamp_map=timestamp_map, **args)
  File "plexdbtool.py", line 614, in _import
    user_ids, user_tokens = user_data
ValueError: not enough values to unpack (expected 2, got 0)
Casvt commented 2 years ago

Do you have a library shared with anyone else? Probably not. You're probably the only one that has access to your server (you don't share it with someone). That is completely fine, but the script didn't account for that.

Don't worry though, I can fix it easily.

razzamatazm commented 2 years ago

I do share my server with some friends. They don't have direct access - just through the normal plex sharing user thing.

On Mon, Aug 29, 2022 at 3:10 PM Casvt @.***> wrote:

Do you have a library shared with anyone else? Probably not. You're probably the only one that has access to your server (you don't share it with someone). That is completely fine, but the script didn't account for that.

Don't worry though, I can fix it easily.

— Reply to this email directly, view it on GitHub https://github.com/Casvt/Plex-scripts/issues/139#issuecomment-1230917667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFOEFJTUQ4RQRLVWKPMOL43V3UYPBANCNFSM577LI2AA . You are receiving this because you authored the thread.Message ID: @.***>

Casvt commented 2 years ago

Oh okay. Even though that was not your problem, I still fixed it.

Could you do the following for me please?

  1. Get the new version of the script from github
  2. Inside the file, go to lines 991-994
  3. It currently looks like this:
    machine_id = _req_cache(ssn, f'{base_url}/')['MediaContainer']['machineIdentifier']
    shared_users = ssn.get(f'http://plex.tv/api/servers/{machine_id}/shared_servers').text
    result = map(lambda r: r.split('"')[0:3:2], shared_users.split('userID="')[1:])
    user_data = tuple(zip(*result)) or ((),())
  4. Please change it so that it'll look like the following (use tabs for identation):
    machine_id = _req_cache(ssn, f'{base_url}/')['MediaContainer']['machineIdentifier']
    shared_users = ssn.get(f'http://plex.tv/api/servers/{machine_id}/shared_servers').text
    print(shared_users)
    result = map(lambda r: r.split('"')[0:3:2], shared_users.split('userID="')[1:])
    print(list(map))
    user_data = tuple(zip(*result)) or ((),())
  5. Now run the script and share the output. You can redact the usernames, user ids, tokens, etc. Just replace them with something like REDACTED.

Thanks :)

razzamatazm commented 2 years ago

Hi There -

This worked! Unfortunately when i stuck the other commands in there it didn't work. I may have been tabbing wrong.

Casvt commented 2 years ago

Alright the print commands can be removed. Just leave the file "clean". Good to hear it works now :)