瀏覽代碼

New info flag, improve logging, add support for Python 3.5>=

Cammy 7 年之前
父節點
當前提交
70ba2ab0f2
共有 2 個文件被更改,包括 45 次插入11 次删除
  1. 1 1
      pyinstalive/downloader.py
  2. 44 10
      pyinstalive/initialize.py

+ 1 - 1
pyinstalive/downloader.py

@@ -94,7 +94,7 @@ def stitch_video(dl, broadcast):
 
 def get_user_info(record):
 	try:
-		log('[I] Getting required user info for user "' + record + '"...', "GREEN")
+		log("[I] Checking user: '"+ record + "'", "GREEN")
 		user_res = api.username_info(record)
 		user_id = user_res['user']['pk']
 	except Exception as e:

+ 44 - 10
pyinstalive/initialize.py

@@ -6,9 +6,15 @@ import sys
 import subprocess
 
 from .auth import login
-from .logger import log, seperator
+from .logger import log, seperator, supports_color
 from .downloader import main
 
+
+script_version = "2.2.2"
+python_version = sys.version.split(' ')[0]
+bool_values = {'True', 'False'}
+
+
 def check_ffmpeg():
 	try:
 		FNULL = open(os.devnull, 'w')
@@ -38,10 +44,7 @@ def check_config_validity(config):
 
 def run():
 
-	script_version = "2.2.2"
-	bool_values = {'True', 'False'}
-
-	log('PYINSTALIVE DOWNLOADER (SCRIPT v{0!s})'.format(script_version), "GREEN")
+	log('PYINSTALIVE (SCRIPT V{} - PYTHON V{})'.format(script_version, python_version), "GREEN")
 	seperator("GREEN")
 
 	logging.disable(logging.CRITICAL)
@@ -67,25 +70,56 @@ def run():
 			log("[E] Could not create default config file: " + str(e), "RED")
 			log("[W] You must manually create and edit it with the following template: ", "YELLOW")
 			log("", "GREEN")
-			log(config_template, "BLUE")
+			log(config_template, "YELLOW")
 			log("", "GREEN")
 			log("[W] Save it as 'pyinstalive.ini' and run this script again.", "YELLOW")
 			log("", "GREEN")
 			sys.exit(1)
 
 
-	parser = argparse.ArgumentParser(description='Login')
-	parser.add_argument('-u', '--username', dest='username', type=str, required=False)
-	parser.add_argument('-p', '--password', dest='password', type=str, required=False)
-	parser.add_argument('-r', '--record', dest='record', type=str, required=True)
+	parser = argparse.ArgumentParser(description='You are running PyInstaLive ' + script_version + " with Python " + python_version)
+	parser.add_argument('-u', '--username', dest='username', type=str, required=False, help="Instagram username to login with.")
+	parser.add_argument('-p', '--password', dest='password', type=str, required=False, help="Instagram password to login with.")
+	parser.add_argument('-r', '--record', dest='record', type=str, required=False, help="The username of the Instagram whose livestream or replay you want to save.")
+	parser.add_argument('-i', '--info', dest='info', action='store_true', help="View information about PyInstaLive.")
 
 	args = parser.parse_args()
 
+
 	if check_config_validity(config):
 
 		username = config['pyinstalive']['username']
 		password = config['pyinstalive']['password']
 
+		def show_info():
+			log("[I] To see all the available flags, use the -h flag.", "BLUE")
+			log("", "GREEN")
+			log("[I] PyInstaLive version:    " + script_version, "GREEN")
+			log("[I] Python version:         " + python_version, "GREEN")
+			if check_ffmpeg() == False:
+				log("[E] FFmpeg available:       False", "RED")
+			else:
+				log("[I] FFmpeg available:       True", "GREEN")
+			if not os.path.isfile('credentials.json'):
+				log("[I] Cookie file:            Not available", "GREEN")
+			else:
+				log("[I] Cookie file:            Available", "GREEN")
+			log("[I] CLI supports color:     " + str(supports_color()), "GREEN")
+			log("[I] Config file:", "GREEN")
+			log("", "GREEN")
+			with open('pyinstalive.ini') as f:
+				for line in f:
+					log("    " + line.rstrip(), "YELLOW")
+			log("", "GREEN")
+			log("Usage: ", "GREEN")
+			log("[I] End of PyInstaLive information screen.", "GREEN")
+			seperator("GREEN")
+
+
+		if (args.username == None and args.password == None and args.record == None and args.info == False) or (args.info != False):
+			show_info()
+			sys.exit(0)
+
 		if check_ffmpeg() == False:
 			log("[E] Could not find ffmpeg, the script will now exit. ", "RED")
 			seperator("GREEN")