Skip to content

Commit

Permalink
Rename variables, update markdowns, fix bad quality dash stream
Browse files Browse the repository at this point in the history
  • Loading branch information
dvingerh committed Aug 26, 2021
1 parent 513bd14 commit 69bfe2c
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 168 deletions.
33 changes: 16 additions & 17 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#### Check the boxes below by filling `[ ]` with an `x` so it looks like `[x]`.
#### Use the Preview button to ensure the template is filled in correctly.
##
- [ ] I am using the latest version of PyInstaLive: 3.2.4.
- [ ] I have installed either Python 2.7.x or 3.5+: `YOUR VERSION HERE`
- [ ] I am using the latest version of PyInstaLive: 3.3.0.
- [ ] I have installed 3.6+: `YOUR VERSION HERE`
- [ ] I have read the [README](https://github.com/notcammy/pyinstalive/blob/master/README.md).
- [ ] I have read the [FAQ](https://github.com/notcammy/pyinstalive/blob/master/FAQ.md).
- [ ] I have checked all [existing issues](https://github.com/notcammy/PyInstaLive/issues?q=is%3Aissue), none of which could solve my issue.
Expand Down Expand Up @@ -34,33 +34,32 @@ Run ```pyinstalive --info``` and paste its output below. Don't forget to omit yo
```bash
$ pyinstalive --info
---------------------------------------------------------------------------
[I] PYINSTALIVE (SCRIPT V3.2.4 - PYTHON V3.6.3) - 01-02-2019 07:00:17 PM
[I] PYINSTALIVE (SCRIPT V3.3.0 - PYTHON V3.8.10) - 08-21-2021 03:33:23 AM
---------------------------------------------------------------------------
[I] To see all the available arguments, use the -h argument.

[I] PyInstaLive version: 3.2.4
[I] Python version: 3.6.3
[I] PyInstaLive version: 3.3.0
[I] Python version: 3.8.10
[I] FFmpeg framework: Available
[I] Cookie files: 2 (johndoe.json matches config user)
[I] Login session files: 1 (johndoe.dat matches config user)
[I] CLI supports color: Yes
[I] Command to run at start: None
[I] Command to run at finish: None
[I] Config file contents:

[pyinstalive]
username = *removed*
password = *removed*
username = johndoe
password = grapefruits
download_path = \path\to\downloads
download_lives = True
download_replays = True
show_session_expires = True
download_comments = True
show_cookie_expiry = False
ffmpeg_path =
log_to_file = True
run_at_start =
run_at_finish =
use_locks = True
clear_temp_files = False
skip_assemble = False
cmd_on_started =
cmd_on_ended =
ffmpeg_path =
log_to_file = True
use_locks = False

[I] End of PyInstaLive information screen.
---------------------------------------------------------------------------
Expand All @@ -71,7 +70,7 @@ Paste the command here that you are running. Don't forget to omit your **usernam

**Example:** ```pyinstalive -u "johndoe" -p "grapefruits" -d "justinbieber"```

###### Behavior
###### Behaviour
Accurately describe the issue you're experiencing with the script.

###### Steps to reproduce issue
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ venv/


*_downloads\

*.txt
15 changes: 4 additions & 11 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This means you are making too many requests to Instagram and is usually the case

#### Option 1 - Checking your following users

You can use the `--download-following` function to check for available livestreams and replays from your following user list. Read the [Help Documents](https://github.com/notcammy/PyInstaLive/blob/master/MOREHELP.md) for more information.
You can use the `--download-following` function to check for available livestreams from your following user list. Read the [Help Documents](https://github.com/notcammy/PyInstaLive/blob/master/MOREHELP.md) for more information.

#### Option 2 - Using external scripts
##### Note: Continuously checking for livestreams with an external script is considered suspicious behaviour by Instagram. Use a timeout as large as possible to decrease the chances of your account, device or IP from getting flagged as suspicious and getting blocked as a result of that. Use the scripts below at your own risk.
Expand Down Expand Up @@ -57,20 +57,13 @@ Use the scripts provided in the previous question, they'll infinitely run the Py

No. This is because livestream_dl is no longer being maintained and as such uses an older version of libraries required by PyInstaLive. Installing PyInstaLive and livestream_dl on different Python versions (2/3) will probably work though.

### PyInstaLive failed to generate a video file after the download has ended. What do I do?
### PyInstaLive failed to assemble a video file after the download has ended. What do I do?

Don't get your hopes up because manually generating a video file has no guarantee of success, but read below for instructions on what you can do in case this has happened to you.

If it failed to generate a video file from a **livestream** you have two options:
If it failed to assemble a video there are two options:
* Use the `--assemble` command as described in the [FAQ](https://github.com/notcammy/PyInstaLive/blob/master/MOREHELP.md#commands).

If that didn't work, you can still attempt to concatenate the segment files yourself:

* Open the segment video directory in your command line.
* Windows: `copy /b *.m4v video.mp4 && copy /b *.m4a audio.mp4 && ffmpeg -i video.mp4 -i audio.mp4 -c copy output.mp4`
* Linux: `cat *.m4v > video.mp4 && cat *.m4a > audio.mp4 && ffmpeg -i video.mp4 -i audio.mp4 -c copy output.mp4`

##

If it failed to generate a video file from a **replay** you can try the following:
- Open the segment video directory in your command line and run `ffmpeg -i video.mp4 -i audio.mp4 -c copy output.mp4`.
* Linux: `cat *.m4v > video.mp4 && cat *.m4a > audio.mp4 && ffmpeg -i video.mp4 -i audio.mp4 -c copy output.mp4`
39 changes: 14 additions & 25 deletions MOREHELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- ```-cl``` or ```--clean``` **** PyInstaLive clean the current download folder by deleting folders ending in `_downloads`. Any folders that contain a `folder.lock` file (e.g. folders for ongoing downloads) will be skipped.

- ```-df``` or ```--download-following``` **** PyInstaLive will check if any users from your following list have any available livestreams or replays and start a daemon process running PyInstaLive in the background for those that do. You cannot cancel the launched processes or start them with any extra arguments. It's recommended to enable ```log_to_file``` when using this argument. (Experimental, use at own risk.)
- ```-df``` or ```--download-following``` **** PyInstaLive will check if any users from your following list have any available livestreams and start a daemon process running PyInstaLive in the background for those that do. You cannot cancel the launched processes or start them with any extra arguments. It's recommended to enable ```log_to_file``` when using this argument. (Experimental, use at own risk.)

- ```-cp``` or ```--config-path``` **** Passing this argument along with a valid path to a different configuration file will override the default path used by PyInstaLive (the current directory you are executing the script in).

Expand All @@ -23,7 +23,7 @@

- ```-b``` or ```--batch-file``` **** PyInstaLive will check the users inside a text file for any available livestreams or replays.

- ```-o``` or ```--organize``` **** (**In testing, use at your own discretion**) Passing this argument will create a folder for each user whose livestream(s) you have downloaded. The names of the folders will be their usernames. It will then move the video and log files of each user into their associated folder and rename the files to a more friendly format. Example filename: ```19-04-2020 06-02-10-PM johndoe (replay).mp4```. Temporary file segment folders will not be moved.
- ```-o``` or ```--organize``` **** (**In testing, use at your own discretion**) Passing this argument will create a folder for each user whose livestream(s) you have downloaded. The names of the folders will be their usernames. It will then move the video and log files of each user into their associated folder and rename the files to a more friendly format. Example filename: ```19-04-2020 06-02-10-PM johndoe.mp4```. Temporary file segment folders will not be moved.

- ```-sm``` or ```--skip-assemble``` **** PyInstaLive will not assemble any download livestream files when this argument is used.

Expand All @@ -35,46 +35,35 @@
username = johndoe
password = grapefruits
download_path =
show_cookie_expiry = True
log_to_file = True
ffmpeg_path =
run_at_start =
run_at_finish =
use_locks = True
show_session_expires = True
download_comments = True
clear_temp_files = False
do_heartbeat = True
proxy =
cmd_on_started =
cmd_on_ended =
ffmpeg_path =
log_to_file = True
skip_assemble = False
use_locks = True
```

```username``` **** Instagram username to login with.

```password``` **** Instagram password to login with.

```download_path``` **** Path to the folder where downloaded Instagram livestreams and replays will be saved. PyInstaLive must have permission to write files to this folder. If left empty, PyInstaLive will attempt to fall back to the folder where it's being run from.
```download_path``` **** Path to the folder where downloaded Instagram livestreams will be saved. PyInstaLive must have permission to write files to this folder. If left empty, PyInstaLive will attempt to fall back to the folder where it's being run from.

```download_lives``` **** When set to True, PyInstaLive will download livestreams.

```download_replays``` **** When set to True, PyInstaLive will download any available replays.

```download_comments``` **** When set to true, PyInstaLive will try to download comments from a livestream or replay to a log file. Verified users have *(v)* next to their name.
```download_comments``` **** When set to true, PyInstaLive will try to download comments from a livestream to a text file.

```show_cookie_expiry``` **** When set to True, PyInstaLive will show when the current cookie used to login will expire.

```log_to_file``` **** When set to true, PyInstaLive will save all its console logs to a text file. The filename will be `pyinstalive_<live-username>.log` where `<live_username>` will be the username of the Instagram user whose livestream or replay you want to download. If no username was given to download (e.g when running `pyinstalive --clean`) the file will be named `pyinstalive.default.log`.

```ffmpeg_path``` **** User-defined path to the FFmpeg binary (e.g. `C:\Users\Username\Desktop\ffmpeg.exe`). If left empty, PyInstaLive will fall back to the system's environment variable.

```run_at_start``` **** Command to run when PyInstaLive starts downloading a livestream. Leave empty to disable. (Experimental feature)
```cmd_on_started``` **** Command to run when PyInstaLive starts downloading a livestream. Leave empty to disable. (Experimental feature)

```run_at_finish``` **** Command to run when PyInstaLive finishes downloading a livestream. Leave empty to disable. (Experimental feature)
```cmd_on_ended``` **** Command to run when PyInstaLive finishes downloading a livestream. Leave empty to disable. (Experimental feature)

```use_locks``` **** When set to true, PyInstaLive will create several .lock files to prevent duplicate downloads from starting for the same user if you are running PyInstaLive using some form of automation such as batch/shell loops.

```clear_temp_files``` **** When set to True, PyInstaLive will delete all temporary files that were downloaded as well as the folders which contained these files. Replay folders created by PyInstaLive will not be deleted because they are used to determine if a replay has already been downloaded.

```do_heartbeat``` **** When set to True, PyInstaLive will check the livestream's active status. If set to False no checks will be conducted, and the logged in user will not show up as a viewer during the livestream. May cause degraded performance.

```proxy``` **** When set, PyInstaLive will use the specified HTTP proxy. The format should be similar to http://user:[email protected]:12345


```clear_temp_files``` **** When set to True, PyInstaLive will delete all temporary files that were downloaded as well as the folders which contained these files. Replay folders created by PyInstaLive will not be deleted because they are used to determine if a replay has already been downloaded.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ download_path =
show_cookie_expiry = True
log_to_file = True
ffmpeg_path =
run_at_start =
run_at_finish =
cmd_on_started =
cmd_on_ended =
use_locks = True
clear_temp_files = False
proxy =
Expand Down Expand Up @@ -138,7 +138,7 @@ Below is an example of PyInstaLive's output after downloading a livestream:
---------------------------------------------------------------------------
[I] Waiting for background threads to finish.
---------------------------------------------------------------------------
[I] Generating comments text file.
[I] Saving comments to text file.
---------------------------------------------------------------------------
[I] Successfully saved 59 comments.
---------------------------------------------------------------------------
Expand Down
22 changes: 11 additions & 11 deletions pyinstalive/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def assemble(user_called=True, retry_with_zero_m4v=False):
ass_mp4_file = os.path.join(pil.dl_path, os.path.basename(ass_json_file).replace("_downloads", "").replace(".json", ".mp4"))
ass_segment_dir = pil.assemble_arg if not pil.assemble_arg.endswith(".json") else pil.assemble_arg.replace(".json", "")

broadcast_info = {}
livestream_info = {}
if not os.path.isdir(ass_segment_dir):
logger.error("Could not create video file: The segment directory does not exist.")
logger.separator()
Expand All @@ -49,27 +49,27 @@ def assemble(user_called=True, retry_with_zero_m4v=False):
if not os.path.isfile(ass_json_file):
logger.warn("No matching JSON file found for the segment directory, trying to continue without it.")
ass_stream_id = os.listdir(ass_segment_dir)[0].split('-')[0]
broadcast_info["broadcast_dict"]['id'] = ass_stream_id
broadcast_info["broadcast_dict"]['broadcast_status'] = "active"
broadcast_info['segments'] = {}
livestream_info["broadcast_dict"]['id'] = ass_stream_id
livestream_info["broadcast_dict"]['broadcast_status'] = "active"
livestream_info['segments'] = {}
else:
with open(ass_json_file) as info_file:
try:
broadcast_info = json.load(info_file)
livestream_info = json.load(info_file)
except Exception as e:
logger.warn("Could not decode JSON file, trying to continue without it.")
ass_stream_id = os.listdir(ass_segment_dir)[0].split('-')[0]
broadcast_info["broadcast_dict"]['id'] = ass_stream_id
broadcast_info["broadcast_dict"]['broadcast_status'] = "active"
broadcast_info['segments'] = {}
livestream_info["broadcast_dict"]['id'] = ass_stream_id
livestream_info["broadcast_dict"]['broadcast_status'] = "active"
livestream_info['segments'] = {}

stream_id = str(broadcast_info["broadcast_dict"]['id'])
stream_id = str(livestream_info["broadcast_dict"]['id'])

segment_meta = broadcast_info.get('segments', {})
segment_meta = livestream_info.get('segments', {})
if segment_meta:
all_segments = [
os.path.join(ass_segment_dir, k)
for k in broadcast_info['segments'].keys()]
for k in livestream_info['segments'].keys()]
else:
all_segments = list(filter(
os.path.isfile,
Expand Down
6 changes: 3 additions & 3 deletions pyinstalive/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Constants:
show_session_expires = True
download_comments = True
clear_temp_files = False
run_at_start =
run_at_finish =
cmd_on_started =
cmd_on_ended =
ffmpeg_path =
log_to_file = True
skip_assemble = False
Expand All @@ -26,6 +26,6 @@ class Constants:
REELS_TRAY_URL = 'https://i.instagram.com/api/v1/live/reels_tray_broadcasts/'
BROADCAST_HEALTH_URL = 'https://i.instagram.com/api/v1/live/{:s}/info/'
BROADCAST_HEALTH2_URL = 'https://i.instagram.com/api/v1/live/{:s}/heartbeat_and_get_viewer_count/'
BROADCAST_INFO_URL = 'https://www.instagram.com/{:s}/live/?__a=1'
livestream_info_URL = 'https://www.instagram.com/{:s}/live/?__a=1'
BROADCAST_COMMENTS_URL = 'https://i.instagram.com/api/v1/live/{:s}/get_comment/?last_comment_ts={:s}'
MAIN_SITE_URL = 'https://www.instagram.com/'
Loading

0 comments on commit 69bfe2c

Please sign in to comment.