Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

Cammy před 6 roky
rodič
revize
d120f8c8d3

+ 10 - 7
.github/issue_template.md

@@ -1,6 +1,7 @@
-### Please check the boxes below by filling [ ] with an x so it looks like [x].
-###### Remove all spaces already present in the box.
-
+## Fill in this template completely. Issues not following this template will be closed and ignored.
+#### 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.1.0.
 - [ ] I have installed either Python 2.7.x or 3.5+: `YOUR VERSION HERE`
 - [ ] I have read the [README](https://github.com/notcammy/pyinstalive/blob/master/README.md).
@@ -59,7 +60,8 @@ $ pyinstalive --info
 ```
 
 ###### Command used
-Paste the command here that you are running. Don't forget to omit your **username** and **password**.
+Paste the command here that you are running. Don't forget to omit your **username** and **password**.  
+If you can reproduce the problem then, if possible, run the same command again with `--verbose` prior to uploading the log files.
 
 **Example:** ```pyinstalive -u "johndoe" -p "grapefruits" -d "justinbieber"```
 
@@ -69,9 +71,10 @@ Accurately describe the issue you're experiencing with the script.
 ###### Steps to reproduce issue
 Specify the exact steps taken to reproduce the problem. If you can't reproduce the issue try to describe the steps you've taken that eventually resulted in the issue you have experienced.
 
-###### Log files
-Please attach the log file of the user you were trying to download (if applicable) and the `pyinstalive.default.log` log file.
-If any of the files exceed 10MB in size please use [WeTransfer](https://wetransfer.com/) or a similar service to upload these files.
+###### Required dditional files
+Please attach the log file of the user you were trying to download (if applicable) and the `pyinstalive.default.log` log file.  
+If your issue is related to assembling segment files please also include the JSON file and a zipped segment files directory.  
+If any of these files exceed 10MB in size please use [WeTransfer](https://wetransfer.com/) or a similar service to upload these files.
 
 ##
 

+ 4 - 0
pyinstalive/assembler.py

@@ -35,6 +35,10 @@ def assemble(user_called=True, retry_with_zero_m4v=False):
         ass_json_file = pil.assemble_arg if pil.assemble_arg.endswith(".json") else pil.assemble_arg + ".json"
         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", "")
+
+        if pil.verbose:
+            logger.plain("{}\n{}\n{}".format(ass_json_file, ass_mp4_file, ass_segment_dir))
+
         broadcast_info = {}
         if not os.path.isdir(ass_segment_dir) or not os.listdir(ass_segment_dir):
             logger.error('The segment directory does not exist or does not contain any files: %s' % ass_segment_dir)

+ 6 - 2
pyinstalive/auth.py

@@ -83,12 +83,16 @@ def authenticate(username, password, force_use_login_args=False):
 
     except (ClientLoginError, ClientError) as e:
         logger.separator()
+        if pil.verbose:
+            logger.plain(json.dumps(e.error_response))
         logger.error('Could not login: {:s}'.format(
-            json.loads(e.error_response).get("error_title", "Error title not available.")))
-        logger.error('{:s}'.format(json.loads(e.error_response).get("message", "Not available")))
+            json.loads(e.error_response).get("error_title", e.error_response)))
+        logger.error('{:s}'.format(json.loads(e.error_response).get("message", e.error_response)))
         # logger.error('{:s}'.format(e.error_response))
         logger.separator()
     except Exception as e:
+        if pil.verbose:
+            logger.plain(json.dumps(e.error_response))
         if str(e).startswith("unsupported pickle protocol"):
             logger.warn("This cookie file is not compatible with Python {}.".format(sys.version.split(' ')[0][0]))
             logger.warn("Please delete your cookie file '{}.json' and try again.".format(username))

+ 4 - 0
pyinstalive/comments.py

@@ -54,6 +54,8 @@ class CommentsDownloader(object):
         try:
             comments_res = self.api.broadcast_comments(
                 self.broadcast.get('id'), last_comment_ts=first_comment_created_at)
+            if pil.verbose:
+                logger.plain(json.dumps(comments_res))
             comments = comments_res.get('comments', [])
             first_comment_created_at = (
                 comments[0]['created_at_utc'] if comments else int(time.time() - 5))
@@ -91,6 +93,8 @@ class CommentsDownloader(object):
             try:
                 comments_res = self.api.replay_broadcast_comments(
                     self.broadcast.get('id'), starting_offset=starting_offset, encoding_tag=encoding_tag)
+                if pil.verbose:
+                    logger.plain(json.dumps(comments_res))
                 starting_offset = comments_res.get('ending_offset', 0)
                 comments = comments_res.get('comments', [])
                 comments_collected.extend(comments)

+ 1 - 0
pyinstalive/constants.py

@@ -21,4 +21,5 @@ use_locks = True
 clear_temp_files = False
 do_heartbeat = False
 proxy =
+verbose = False
     """

+ 8 - 0
pyinstalive/dlfuncs.py

@@ -64,6 +64,8 @@ def get_user_id():
     except ValueError:
         try:
             user_res = pil.ig_api.username_info(pil.dl_user)
+            if pil.verbose:
+                logger.plain(json.dumps(user_res))
             user_id = user_res.get('user', {}).get('pk')
         except ClientConnectionError as cce:
             logger.error(
@@ -101,6 +103,8 @@ def get_broadcasts_info():
         user_id = get_user_id()
         if user_id:
             broadcasts = pil.ig_api.user_story_feed(user_id)
+            if pil.verbose:
+                logger.plain(json.dumps(broadcasts))
             pil.livestream_obj = broadcasts.get('broadcast')
             pil.replays_obj = broadcasts.get('post_live_item', {}).get('broadcasts', [])
             return True
@@ -178,6 +182,8 @@ def download_livestream():
         def print_status(sep=True):
             if pil.do_heartbeat:
                 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)
             if sep:
                 logger.separator()
@@ -362,6 +368,8 @@ def download_following():
             is_checking = 'replays'
         logger.info("Checking following users for any {:s}.".format(is_checking))
         broadcast_f_list = pil.ig_api.reels_tray()
+        if pil.verbose:
+            logger.plain(json.dumps(broadcast_f_list))
         usernames_available_livestreams = []
         usernames_available_replays = []
         if broadcast_f_list['broadcasts'] and pil.dl_lives:

+ 3 - 1
pyinstalive/pil.py

@@ -44,6 +44,7 @@ def initialize():
     global has_guest
     global do_heartbeat
     global proxy
+    global verbose
     ig_api = None
     ig_user = ""
     ig_pass = ""
@@ -75,4 +76,5 @@ def initialize():
     clear_temp_files = False
     has_guest = None
     do_heartbeat = False
-    proxy = None
+    proxy = None
+    verbose = False

+ 12 - 1
pyinstalive/startup.py

@@ -82,6 +82,7 @@ def validate_inputs(config, args, unknown_args):
         pil.run_at_start = config.get('pyinstalive', 'run_at_start')
         pil.run_at_finish = config.get('pyinstalive', 'run_at_finish')
         pil.ffmpeg_path = config.get('pyinstalive', 'ffmpeg_path')
+        pil.verbose = config.get('pyinstalive', 'verbose')
         pil.args = args
         pil.config = config
         pil.proxy = config.get('pyinstalive', 'proxy')
@@ -104,6 +105,14 @@ def validate_inputs(config, args, unknown_args):
         else:
             pil.show_cookie_expiry = False
 
+        if helpers.bool_str_parse(config.get('pyinstalive', 'verbose')) == "Invalid":
+            pil.verbose = False
+            error_arr.append(['verbose', 'False'])
+        elif helpers.bool_str_parse(config.get('pyinstalive', 'verbose')):
+            pil.verbose = True
+        else:
+            pil.verbose = False
+
         if helpers.bool_str_parse(config.get('pyinstalive', 'use_locks')) == "Invalid":
             pil.use_locks = False
             error_arr.append(['use_locks', 'False'])
@@ -256,7 +265,9 @@ def run():
     parser.add_argument('-nhb', '--no-heartbeat', dest='noheartbeat', action='store_true', help="Disable heartbeat "
                                                                                                 "check for "
                                                                                                 "livestreams.")
-
+    parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help="PyInstaLive will output JSON "
+                                                                                     "responses and some misc "
+                                                                                     "variables.")
     # Workaround to 'disable' argument abbreviations
     parser.add_argument('--usernamx', help=argparse.SUPPRESS, metavar='IGNORE')
     parser.add_argument('--passworx', help=argparse.SUPPRESS, metavar='IGNORE')