Skip to content

Connection hangs when download an image. no way to recover #579

@fcoulombe

Description

@fcoulombe

Describe the issue
Every 10 seconds, I download a new image from my photo library and the downloading of image hangs when using an account that is being shared a photo album.

This seems to work fine when I use a token and the address to my local plex server but I didn't want to use a token that gave full access to my plex server.
So I created a new user and shared my plex photo library to it.
Then I used MyPlexAccount to connect instead of just PlexServer(baseurl, token) which seems to work but after a while, downloading will hang and never finish.

I can't even ctrl-C to kill the job.

Code snipppets

account = MyPlexAccount(shared_username, shared_password)
token = account.authenticationToken
plex = account.resources()[0].connect()  # returns a PlexServer instance
token = plex.createToken()
photoAlbums  = plex.library.section('Photos')
photo = photoList[photoIndex]
media = photo.media[0]
part = media.parts[0]
downloadUrl = plex.url(part.key)
tempFilename = GetTempFilePath()
try:
    plexapi.utils.download(downloadUrl, token, tempFilename)
except:
    e = sys.exc_info()[0]
    print('Failed to download: %s at: %s for: %s' % (downloadUrl, tempFilename, e))
    raise

after a while, it stops. it never except, it never finishes...

baseurl = 'http://raspberrypi.local:32400'
token = 'some token looked up on my main account that i can't find equivalent on my shared account'
plex = PlexServer(baseurl, token)
photoAlbums  = plex.library.section('Photos')
photo = photoList[photoIndex]
media = photo.media[0]
part = media.parts[0]
downloadUrl = plex.url(part.key)
tempFilename = GetTempFilePath()
try:
    plexapi.utils.download(downloadUrl, token, tempFilename)
except:
    e = sys.exc_info()[0]
    print('Failed to download: %s at: %s for: %s' % (downloadUrl, tempFilename, e))
    raise

This can work for days but I can only get the token to my main account which has full access to the server. I want to avoid this.

Expected behavior
Just don't hang.

Enviroment (please complete the following information):

  • OS: [Windows]
  • Plex version [4.20.2]
  • Python Version [3.7.9]
  • PlexAPI version [ 4.1.0]

Additional context
I can probably provide my full code with credentials since it's a "shared account". just not on public github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions