Ver código fonte

Merge remote-tracking branch 'origin/master'

Cammy 5 anos atrás
pai
commit
adba9ec473
3 arquivos alterados com 10 adições e 6 exclusões
  1. 3 0
      README.md
  2. 4 4
      pyinstalive/dlfuncs.py
  3. 3 2
      pyinstalive/helpers.py

+ 3 - 0
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)

+ 4 - 4
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 download_livestream():
                 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:

+ 3 - 2
pyinstalive/helpers.py

@@ -4,6 +4,7 @@ import os
 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)