Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fcoulombe opened this issue Oct 4, 2020 · 2 comments · Fixed by #847
Closed

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

fcoulombe opened this issue Oct 4, 2020 · 2 comments · Fixed by #847

Comments

@fcoulombe
Copy link

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.

@blacktwin
Copy link
Collaborator

Photos should have a proper download() method. I'll create a PR to add it.

@blacktwin
Copy link
Collaborator

The PR doesn't address your connection issue but it does add the download methods to Photos and Photoalbums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants