Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammy committed Jul 27, 2019
2 parents 49d3348 + 433bf86 commit adba9ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
![Version 3.1.6](https://img.shields.io/badge/Version-3.1.6-orange.svg)
![Python 2.7, 3.5](https://img.shields.io/badge/Python-2.7%2C%203.5%2B-3776ab.svg)

[![Support me!](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/dvingerh)


This Python script enables you to download any ongoing Instagram livestreams as well as any available replays. It is based on [another script](https://github.com/taengstagram/instagram-livestream-downloader) that has now been discontinued.

![](https://raw.githubusercontent.com/notcammy/PyInstaLive/5907fc866446d5f426389a5198560075848d770e/.github/spacer.png)
Expand Down
8 changes: 4 additions & 4 deletions pyinstalive/dlfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def get_stream_duration(duration_type):
try:
# For some reason the published_time is roughly 40 seconds behind real world time
if duration_type == 0: # Airtime duration
stream_started_mins, stream_started_secs = divmod((int(time.time()) - pil.livestream_obj.get("published_time") + 40), 60)
stream_started_mins, stream_started_secs = divmod((int(time.time()) - pil.livestream_obj.get("published_time")), 60)
if duration_type == 1: # Download duration
stream_started_mins, stream_started_secs = divmod((int(time.time()) - int(pil.epochtime)), 60)
if duration_type == 2: # Missing duration
if (int(pil.epochtime) - pil.livestream_obj.get("published_time") + 40) <= 0:
if (int(pil.epochtime) - pil.livestream_obj.get("published_time")) <= 0:
stream_started_mins, stream_started_secs = 0, 0 # Download started 'earlier' than actual broadcast, assume started at the same time instead
else:
stream_started_mins, stream_started_secs = divmod((int(pil.epochtime) - pil.livestream_obj.get("published_time") + 40), 60)
stream_started_mins, stream_started_secs = divmod((int(pil.epochtime) - pil.livestream_obj.get("published_time")), 60)

if stream_started_mins < 0:
stream_started_mins = 0
Expand Down Expand Up @@ -187,7 +187,7 @@ def print_status(sep=True):
heartbeat_info = pil.ig_api.broadcast_heartbeat_and_viewercount(pil.livestream_obj.get('id'))
if pil.verbose:
logger.plain(json.dumps(heartbeat_info))
viewers = pil.livestream_obj.get('viewer_count', 0)
viewers = pil.livestream_obj.get('viewer_count', 0) + 1
if sep:
logger.separator()
else:
Expand Down
5 changes: 3 additions & 2 deletions pyinstalive/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import json
import shlex
import sys

try:
import pil
Expand Down Expand Up @@ -42,14 +43,14 @@ def command_exists(command):
fnull = open(os.devnull, 'w')
subprocess.call([command], stdout=fnull, stderr=subprocess.STDOUT)
return True
except OSError as e:
except OSError:
return False


def run_command(command):
try:
fnull = open(os.devnull, 'w')
subprocess.Popen(shlex.split(command), stdout=fnull, stderr=subprocess.STDOUT)
subprocess.Popen(shlex.split(command), stdout=fnull, stderr=sys.stdout)
return False
except Exception as e:
return str(e)
Expand Down

0 comments on commit adba9ec

Please sign in to comment.