From f2d76e361a3267bcc67167c933f42ee5195199e4 Mon Sep 17 00:00:00 2001 From: Cammy Date: Wed, 10 Jul 2019 20:02:55 +0200 Subject: [PATCH 1/3] Fix improper duration timestamps, count downloader as live viewer too --- pyinstalive/dlfuncs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyinstalive/dlfuncs.py b/pyinstalive/dlfuncs.py index a1d2d95..babf797 100644 --- a/pyinstalive/dlfuncs.py +++ b/pyinstalive/dlfuncs.py @@ -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 @@ -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: From 6d1d705eedf700b72ae1d8d4f8ab764e73469097 Mon Sep 17 00:00:00 2001 From: Cammy Date: Thu, 11 Jul 2019 18:04:57 +0200 Subject: [PATCH 2/3] Show stderr output for run_command() --- pyinstalive/helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyinstalive/helpers.py b/pyinstalive/helpers.py index 80c0da2..180d8e9 100644 --- a/pyinstalive/helpers.py +++ b/pyinstalive/helpers.py @@ -4,6 +4,7 @@ import shutil import json import shlex +import sys try: import pil @@ -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) From 433bf862e2d38f9131772905ceab17343053dc3b Mon Sep 17 00:00:00 2001 From: Dirk Vingerhoeds Date: Fri, 12 Jul 2019 20:50:42 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3cc53bb..b86aad7 100644 --- a/README.md +++ b/README.md @@ -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)