dvingerh / PyInstaStories

Python script to download Instagram stories from Instagram users.
MIT License
329 stars 74 forks source link

Error: URL can't contain control characters #37

Closed JCGithu closed 4 years ago

JCGithu commented 4 years ago

Hey, first off thanks for the great project, it's been really helpful.

I'm trying to embed your code into a project, which has so far worked pretty well! When running the code as an import the username to download works perfectly fine, however, once I package the project with PyInstaller I'm now recieving this issue with all usernames:

[E] (1) Download failed: InvalidURL URL can't contain control characters. '/api/v1/users/USERNAME\r\n/usernameinfo/' (found at least '\r').

This is stemming from line 409:

user_res = ig_client.username_info(user)

I wanted to reach out to see if you had any ideas regarding the issue, or whether I need to dig deeper into the Instagram API to fix this.

P.S. For my needs I had to add an output location argument into the code, so if you're still looking for suggestions on improvements that would be mine! Thanks again.

dvingerh commented 4 years ago

What seems to happen is that either some other part of your code (or pyinstaller, in a way) is adding an EOL character \r\n to the username string variable which is obviously not accepted in an URL

Try using rstrip() to remove trailing newlines

JCGithu commented 4 years ago

@dvingerh

Thank you for your help! I suspected it may not be related to your code but just wanted to check as relatively new to this and couldn't find any answers.