ping / instagram_private_api_extensions

An extension module to https://github.com/ping/instagram_private_api
MIT License
124 stars 26 forks source link

Invalid string in stream file variable produces [Errno 22] Invalid argument for Replays #7

Closed dvingerh closed 6 years ago

dvingerh commented 6 years ago

Please follow the guide below


Before submitting an issue make sure you have:

Purpose of your issue?


The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here:

Code: Python 3.5.4

https://github.com/notcammy/PyInstaLive/blob/2.5.3/pyinstalive/downloader.py#L298

Error/Log:

[Errno 22] Invalid argument: 'D:\\InstaLive/20180523_targetIG_17913947659170493_1527093876_replay_downloads\\33148056_118291655718614_8624200296354021376_n.mp4?_nc_eui2=AeEFp8QXDnJH68Zmeq3uV-YC4ZJS9jZFgG4R4fKgLlsUk9xYeM2df3qZjWuuyecfig57tNHBhMuqyeEG8x2gZVkJ'

Describe your issue

Instagram may return stream filename with a certain string after the file extension like

33148056_118291655718614_8624200296354021376_n.mp4?_nc_eui2=AeEFp8QXDnJH68Zmeq3uV-YC4ZJS9jZFgG4R4fKgLlsUk9xYeM2df3qZjWuuyecfig57tNHBhMuqyeEG8x2gZVkJ.

Issue is first encountered here: https://github.com/notcammy/PyInstaLive/issues/16.

Because the file extension is no longer correct and ? is an illegal filename character this will cause an error while trying to download the replay or otherwise merge the video and audio file with FFmpeg.

Solution

I believe this invalid string first appears in replay.py#L125 and may be solved by using .split('?')[0] on the video_stream (and maybe audio_stream) variables.