Преглед на файлове

Merge branch 'master' of https://github.com/notcammy/PyInstaLive

Cammy преди 6 години
родител
ревизия
0fa3ead3a5
променени са 9 файла, в които са добавени 189 реда и са изтрити 80 реда
  1. 4 4
      .github/issue_template.md
  2. 10 5
      MOREHELP.md
  3. 15 9
      README.md
  4. 39 15
      pyinstalive/auth.py
  5. 1 1
      pyinstalive/comments.py
  6. 43 14
      pyinstalive/downloader.py
  7. 75 31
      pyinstalive/initialize.py
  8. 1 0
      pyinstalive/settings.py
  9. 1 1
      setup.py

+ 4 - 4
.github/issue_template.md

@@ -1,7 +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.
 
-- [ ] I am using the latest version of PyInstaLive: 2.5.5.
+- [ ] I am using the latest version of PyInstaLive: 2.5.6.
 - [ ] I have installed either Python 2.7.x or 3.5>=. (If applicable)
 - [ ] I have read the [README](https://github.com/notcammy/pyinstalive/blob/master/README.md).
 - [ ] I have read the [FAQ](https://github.com/notcammy/pyinstalive/blob/master/FAQ.md).
@@ -30,11 +30,11 @@ Run ```pyinstalive --info``` and paste its output below. Don't forget to omit yo
 ```bash
 $ pyinstalive --info
 ----------------------------------------------------------------------
-PYINSTALIVE (SCRIPT V2.5.5 - PYTHON V3.6.3) - 11:50:00 AM
+PYINSTALIVE (SCRIPT V2.5.6 - PYTHON V3.6.3) - 11:50:00 AM
 ----------------------------------------------------------------------
-[I] To see all the available flags, use the -h flag.
+[I] To see all the available arguments, use the -h argument.
 
-[I] PyInstaLive version:        2.5.5
+[I] PyInstaLive version:        2.5.6
 [I] Python version:             3.6.3
 [I] FFmpeg framework:           Available
 [I] Cookie files:               2 (username.json matches config user)

+ 10 - 5
MOREHELP.md

@@ -1,7 +1,7 @@
 # Commands
 
 
-- ```-h``` or ```--help```  **—**  When this flag is passed, PyInstaLive's help message will be shown containing all available commands.
+- ```-h``` or ```--help```  **—**  When this argument is passed, PyInstaLive's help message will be shown containing all available commands.
 
 - ```-u``` or ```--username```  **—**  Instagram username to login with. Requires:  ```--password```, ```--download```.
 
@@ -11,11 +11,13 @@
 
 - ```-r``` or ```--record```  **—**  The username of the user whose livestream or replay you want to save (legacy).
 
-- ```-i``` or ```--info```  **—**  When this flag is passed, PyInstaLive will show information such as its current version, the configuration file contents, available cookie files and more.
+- ```-i``` or ```--info```  **—**  When this argument is passed, PyInstaLive will show information such as its current version, the configuration file contents, available cookie files and more.
 
-- ```-nr``` or ```--noreplays```  **—**  When this flag is passed, PyInstaLive will not download any available replays. Overrides the configuration file.
+- ```-nr``` or ```--noreplays```  **—**  When this argument is passed, PyInstaLive will not download any available replays. Overrides the configuration file.
 
-- ```-cl``` or ```--clean```  **—**  When this flag is passed, PyInstaLive clean the current download folder by deleting folders ending in `_downloads`. Any folders that contain a `folder.lock` file (e.g. folders for ongoing downloads) will be skipped.
+- ```-nl``` or ```--nolives```  **—**  When this argument is passed, PyInstaLive will not download livestreams. Overrides the configuration file.
+
+- ```-cl``` or ```--clean```  **—**  When this argument is passed, PyInstaLive clean the current download folder by deleting folders ending in `_downloads`. Any folders that contain a `folder.lock` file (e.g. folders for ongoing downloads) will be skipped.
 
 
 # Default configuration file
@@ -27,6 +29,7 @@ password = grapefruits
 save_path = 
 show_cookie_expiry = true
 clear_temp_files = false
+save_lives = true
 save_replays = true
 run_at_start =
 run_at_finish =
@@ -44,7 +47,9 @@ log_to_file = false
 
 ```clear_temp_files```  **—**  When set to True, PyInstaLive will delete all temporary files that were downloaded as well as the folders which contained these files. Replay folders created by PyInstaLive will not be deleted because they are used to determine if a replay has already been downloaded.
 
-```save_replays```  **—**  When set to True, PyInstaLive will check for and download any available replays.
+```save_lives```  **—**  When set to True, PyInstaLive will download livestreams.
+
+```save_replays```  **—**  When set to True, PyInstaLive will download any available replays.
 
 ```run_at_start```  **—**  Command to run when PyInstaLive starts downloading a livestream. Leave empty to disable. (Experimental, use at own risk.)
 

+ 15 - 9
README.md

@@ -1,5 +1,5 @@
 # PyInstaLive
-![Version 2.5.5](https://img.shields.io/badge/Version-2.5.5-pink.svg?style=for-the-badge)
+![Version 2.5.6](https://img.shields.io/badge/Version-2.5.6-pink.svg?style=for-the-badge)
 
 This CLI 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.
 
@@ -57,15 +57,15 @@ In case it doesn't work or you just prefer building PyInstaLive from source foll
 
 Run the following command in Command Prompt (might need to be run as administrator on Windows) or a terminal:
 ```bash
-pip install git+https://github.com/notcammy/PyInstaLive.git@2.5.5 --process-dependency-links
+pip install git+https://github.com/notcammy/PyInstaLive.git@2.5.6 --process-dependency-links
 ```
 
 #### Updating
 
-To update PyInstaLive to the latest version (currently **2.5.5**) run the following command:
+To update PyInstaLive to the latest version (currently **2.5.6**) run the following command:
 
 ```bash
-pip install git+https://github.com/notcammy/PyInstaLive.git@2.5.5 --process-dependency-links --upgrade
+pip install git+https://github.com/notcammy/PyInstaLive.git@2.5.6 --process-dependency-links --upgrade
 ```
 
 #### Specific versions
@@ -94,6 +94,7 @@ password = grapefruits
 save_path = 
 show_cookie_expiry = true
 clear_temp_files = false
+save_lives = true
 save_replays = true
 run_at_start =
 run_at_finish =
@@ -114,11 +115,14 @@ pyinstalive -d "janedoe"
 Below is an example of PyInstaLive's output after downloading a livestream:
 
 ```
+> pyinstalive -d "janedoe"
+
+----------------------------------------------------------------------
+PYINSTALIVE (SCRIPT V2.5.6 - PYTHON V3.6.3) - 06:45:30 PM
 ----------------------------------------------------------------------
-PYINSTALIVE (SCRIPT V2.5.5 - PYTHON V3.6.3) - 06:45:30 PM
+[I] Successfully logged into user "johndoe".
+[I] Cookie file expiry date: 2018-09-01 at 04:38:08 PM
 ----------------------------------------------------------------------
-[I] Using cached login cookie for "johndoe".
-[I] Login cookie expiry date: 2018-01-31 at 10:30:00 PM
 [I] Getting info for "janedoe" successful.
 ----------------------------------------------------------------------
 [I] Checking for livestreams and replays...
@@ -149,9 +153,11 @@ PYINSTALIVE (SCRIPT V2.5.5 - PYTHON V3.6.3) - 06:45:30 PM
 ![](https://raw.githubusercontent.com/notcammy/PyInstaLive/5907fc866446d5f426389a5198560075848d770e/.github/spacer.png)
 
 ## Notes
-- Python 2 cannot save most unicode characters in comments such as emojis if it's not built from source using the `--enable-unicode=ucs4` flag. Read more about this [here](https://emoji-unicode.readthedocs.io/en/latest/python2.html). This should probably not affect pre-installed Python 2 installations on Linux-based systems such as Ubuntu or Debian.
+- I have not much time to extensively test the changes I make to the code, so when you do encounter a problem please [open an issue](https://github.com/notcammy/PyInstaLive/issues/new) and try using an older version of PyInstaLive in the meantime.
+
+- Python 2 cannot save most unicode characters in comments such as emojis if it's not built from source using the `--enable-unicode=ucs4` argument. Read more about this [here](https://emoji-unicode.readthedocs.io/en/latest/python2.html). This should probably not affect pre-installed Python 2 installations on Linux-based systems such as Ubuntu or Debian.
 
-- If the script is ran and there are available replays as well as an ongoing Instagram livestream, only the livestream will be downloaded. Run the script again after the livestream has ended to download the available replays.
+- If the script is ran and there are available replays as well as an ongoing Instagram livestream, only the livestream will be downloaded. Run the script again after the livestream has ended to download the available replays. Alternatively you can set `save_lives` to `False` in the configuration file or pass the `--nolives` argument to skip downloading of livestreams.
 
 
 ## Help

+ 39 - 15
pyinstalive/auth.py

@@ -38,7 +38,8 @@ def onlogin_callback(api, cookie_file):
 	cache_settings = api.settings
 	with open(cookie_file, 'w') as outfile:
 		json.dump(cache_settings, outfile, default=to_json)
-		log('[I] New user cookie file was made: {0!s}'.format(cookie_file), "GREEN")
+		log('[I] New cookie file was made: {0!s}'.format(cookie_file), "GREEN")
+		seperator("GREEN")
 
 
 def login(username, password, show_cookie_expiry, force_use_login_args):
@@ -52,7 +53,8 @@ def login(username, password, show_cookie_expiry, force_use_login_args):
 			cookie_file = "{}.json".format(username)
 			if not os.path.isfile(cookie_file):
 				# settings file does not exist
-				log('[W] Unable to find user cookie file: {0!s}'.format(cookie_file), "YELLOW")
+				log('[W] Unable to find cookie file: {0!s}'.format(cookie_file), "YELLOW")
+				log('[I] Creating a new cookie file...', "YELLOW")
 
 				# login new
 				api = Client(
@@ -64,20 +66,34 @@ def login(username, password, show_cookie_expiry, force_use_login_args):
 				# log('[I] Using settings file: {0!s}'.format(cookie_file), "GREEN")
 
 				device_id = cached_settings.get('device_id')
-				# reuse auth settings
+				# reuse auth cached_settings
 				api = Client(
 					username, password,
 					settings=cached_settings)
 
-	except (ClientCookieExpiredError, ClientLoginRequiredError) as e:
-		log('[E] ClientCookieExpiredError/ClientLoginRequiredError: {0!s}'.format(e), "RED")
+	except (ClientCookieExpiredError) as e:
+		log('[W] The current cookie file for "{:s}" has expired, creating a new one...'.format(username), "YELLOW")
 
 		# Login expired
 		# Do relogin but use default ua, keys and such
-		api = Client(
-			username, password,
-			device_id=device_id,
-			on_login=lambda x: onlogin_callback(x, cookie_file))
+		try:
+			api = Client(
+				username, password,
+				device_id=device_id,
+				on_login=lambda x: onlogin_callback(x, cookie_file))
+		except Exception as ee:
+			seperator("GREEN")
+			log('[E] An error occurred while trying to create a new cookie file: {:s}'.format(str(ee)), "RED")
+			if "getaddrinfo failed" in str(ee):
+				log('[E] Could not resolve host, check your internet connection.', "RED")
+			elif "timed out" in str(ee):
+				log('[E] The connection timed out, check your internet connection.', "RED")
+			elif "bad_password" in str(ee):
+				log('[E] The password you entered is incorrect. Please try again.', "RED")
+			else:
+				log('[E] {:s}'.format(ee.message), "RED")
+			seperator("GREEN")
+			exit(1)
 
 	except ClientLoginError as e:
 		seperator("GREEN")
@@ -86,7 +102,14 @@ def login(username, password, show_cookie_expiry, force_use_login_args):
 		sys.exit(9)
 	except ClientError as e:
 		seperator("GREEN")
-		log('[E] Client Error: {0!s}\n[E] Message: {1!s}\n[E] Code: {2:d}\n\n[E] Full response:\n{3!s}\n'.format(e.msg, json.loads(e.error_response).get("message", "Additional error information not available."), e.code, e.error_response), "RED")
+		try:
+			log('[E] Unexpected exception: {0!s}\n[E] Message: {1!s}\n[E] Code: {2:d}\n\n[E] Full response:\n{3!s}\n'.format(e.msg, json.loads(e.error_response).get("message", "Additional error information not available."), e.code, e.error_response), "RED")
+		except Exception as ee:
+			log('[E] An error occurred while trying to handle a previous exception.\n[E] 1: {:s}\n[E] 2: {:s}'.format(str(e), str(ee)), "RED")
+			if "getaddrinfo failed" in str(ee):
+				log('[E] Could not resolve host, check your internet connection.', "RED")
+			if "timed out" in str(ee):
+				log('[E] The connection timed out, check your internet connection.', "RED")
 		seperator("GREEN")
 		sys.exit(9)
 	except Exception as e:
@@ -94,7 +117,8 @@ def login(username, password, show_cookie_expiry, force_use_login_args):
 			log("[W] This cookie file is not compatible with Python {}.".format(sys.version.split(' ')[0][0]), "YELLOW")
 			log("[W] Please delete your cookie file '{}.json' and try again.".format(username), "YELLOW")
 		else:
-			log('[E] Unexpected Exception: {0!s}'.format(e), "RED")
+			seperator("GREEN")
+			log('[E] Unexpected exception: {0!s}'.format(e), "RED")
 		seperator("GREEN")
 		sys.exit(99)
 	except KeyboardInterrupt as e:
@@ -103,13 +127,13 @@ def login(username, password, show_cookie_expiry, force_use_login_args):
 		seperator("GREEN")
 		sys.exit(0)
 
-	log('[I] Using user cookie for "{:s}".'.format(str(api.authenticated_user_name)), "GREEN")
+	log('[I] Successfully logged into user "{:s}".'.format(str(api.authenticated_user_name)), "GREEN")
 	if show_cookie_expiry.title() == 'True' and not force_use_login_args:
 		try:
 			cookie_expiry = api.cookie_jar.auth_expires
-			log('[I] User cookie expiry date: {0!s}'.format(datetime.datetime.fromtimestamp(cookie_expiry).strftime('%Y-%m-%d at %I:%M:%S %p')), "GREEN")
+			log('[I] Cookie file expiry date: {0!s}'.format(datetime.datetime.fromtimestamp(cookie_expiry).strftime('%Y-%m-%d at %I:%M:%S %p')), "GREEN")
 		except AttributeError as e:
-			log('[W] An error occurred while getting the cookie expiry date: {0!s}'.format(e), "YELLOW")
-
+			log('[W] An error occurred while getting the cookie file expiry date: {0!s}'.format(e), "YELLOW")
 
+	seperator("GREEN")		
 	return api

+ 1 - 1
pyinstalive/comments.py

@@ -167,7 +167,7 @@ class CommentsDownloader(object):
 				
 			with codecs.open(log_file, 'w', 'utf-8-sig') as log_outfile:
 				if python_version.startswith('2') and not wide_build:
-					log_outfile.write('This log was generated using Python {:s} without wide unicode support. This means characters such as emojis are not saved.\nUser comments without any text usually are comments that only had emojis.\nBuild Python 2 with the --enable-unicode=ucs4 flag or use Python 3 for full unicode support.\n\n'.format(python_version) + ''.join(subs))
+					log_outfile.write('This log was generated using Python {:s} without wide unicode support. This means characters such as emojis are not saved.\nUser comments without any text usually are comments that only had emojis.\nBuild Python 2 with the --enable-unicode=ucs4 argument or use Python 3 for full unicode support.\n\n'.format(python_version) + ''.join(subs))
 				else:
 					log_outfile.write(''.join(subs))
 			return comment_errors, total_comments

+ 43 - 14
pyinstalive/downloader.py

@@ -227,27 +227,40 @@ def get_user_info(user_to_download):
 	try:
 		user_res = instagram_api.username_info(user_to_download)
 		user_id = user_res.get('user', {}).get('pk')
-	except ClientConnectionError as e:
-		if "timed out" in str(e):
-			log('[E] Could not get information for "{:s}": The connection has timed out.'.format(user_to_download), "RED")
-		else:
-			log('[E] Could not get information for "{:s}".\n[E] Error message: {:s}\n[E] Code: {:d}\n[E] Response: {:s}'.format(user_to_download, str(e), e.code, e.error_response), "RED")
+	except ClientConnectionError as cce:
+		log('[E] Could not get user info for "{:s}": {:d} {:s}'.format(user_to_download, cce.code, str(cce)), "RED")
+		if "getaddrinfo failed" in str(cce):
+			log('[E] Could not resolve host, check your internet connection.', "RED")
+		if "timed out" in str(cce):
+			log('[E] The connection timed out, check your internet connection.', "RED")
+		seperator("GREEN")
+		sys.exit(1)
+	except ClientThrottledError as cte:
+		log('[E] Could not get user info for "{:s}": {:d} {:s}\n[E] You are making too many requests at this time.'.format(user_to_download, cte.code, str(cte)), "RED")
+		seperator("GREEN")
+		sys.exit(1)
+	except ClientError as ce:
+		log('[E] Could not get user info for "{:s}": {:d} {:s}'.format(user_to_download, ce.code, str(ce)), "RED")
+		if ("Not Found") in str(ce):
+			log('[E] The specified user does not exist.', "RED")
 		seperator("GREEN")
 		sys.exit(1)
 	except Exception as e:
-		log('[E] Could not get information for "{:s}".\n[E] Error message: {:s}\n[E] Code: {:d}\n[E] Response: {:s}'.format(user_to_download, str(e), e.code, e.error_response), "RED")
+		log('[E] Could not get user info for "{:s}": {:s}'.format(user_to_download, str(e)), "RED")
+
 		seperator("GREEN")
 		sys.exit(1)
 	except KeyboardInterrupt:
-		log('[W] Aborted getting information for "{:s}", exiting...'.format(user_to_download), "YELLOW")
+		log('[W] Aborted getting user info for "{:s}", exiting...'.format(user_to_download), "YELLOW")
 		seperator("GREEN")
-		sys.exit(1)
+		sys.exit(0)
 	log('[I] Getting info for "{:s}" successful.'.format(user_to_download), "GREEN")
 	get_broadcasts_info(user_id)
 
 
 
 def get_broadcasts_info(user_id):
+	seperator("GREEN")
 	try:
 		seperator("GREEN")
 		log('[I] Checking for livestreams and replays...', "GREEN")
@@ -257,10 +270,15 @@ def get_broadcasts_info(user_id):
 		livestream = broadcasts.get('broadcast')
 		replays = broadcasts.get('post_live_item', {}).get('broadcasts', [])
 
-		if livestream:
-			download_livestream(livestream)
+		if settings.save_lives.title() == "True":
+			if livestream:
+				download_livestream(livestream)
+			else:
+				log('[I] There are no available livestreams.', "YELLOW")
 		else:
-			log('[I] There are no available livestreams.', "YELLOW")
+			log("[I] Livestream saving is disabled either with an argument or in the config file.", "BLUE")
+			
+
 		if settings.save_replays.title() == "True":
 			if replays:
 				seperator("GREEN")
@@ -270,13 +288,24 @@ def get_broadcasts_info(user_id):
 			else:
 				log('[I] There are no available replays.', "YELLOW")
 		else:
-			log("[I] Replay saving is disabled either with a flag or in the config file.", "BLUE")
+			seperator("GREEN")
+			log("[I] Replay saving is disabled either with an argument or in the config file.", "BLUE")
+
 		seperator("GREEN")
 	except Exception as e:
 		log('[E] Could not finish checking: {:s}'.format(str(e)), "RED")
+		if "timed out" in str(e):
+			log('[E] The connection timed out, check your internet connection.', "RED")
+		seperator("GREEN")
+		exit(1)
+	except KeyboardInterrupt:
+		log('[W] Aborted checking for livestreams and replays, exiting...'.format(user_to_download), "YELLOW")
+		seperator("GREEN")
+		sys.exit(1)
 	except ClientThrottledError as cte:
 		log('[E] Could not check because you are making too many requests at this time.', "RED")
-		log('[E] Error response: {:s}'.format(str(cte)), "RED")
+		seperator("GREEN")
+		exit(1)
 
 def download_replays(broadcasts):
 	try:
@@ -360,7 +389,7 @@ def download_replays(broadcasts):
 		sys.exit(1)
 	except KeyboardInterrupt:
 		seperator("GREEN")
-		log('[I] The download has been aborted by the user.', "YELLOW")
+		log('[I] The download has been aborted by the user, exiting...', "YELLOW")
 		seperator("GREEN")
 		try:
 			shutil.rmtree(output_dir)

+ 75 - 31
pyinstalive/initialize.py

@@ -15,7 +15,7 @@ from .logger import seperator
 from .logger import supports_color
 from .settings import settings
 
-script_version = "2.5.5"
+script_version = "2.5.6"
 python_version = sys.version.split(' ')[0]
 bool_values = {'True', 'False'}
 
@@ -71,6 +71,17 @@ def check_config_validity(config):
 			settings.save_replays = 'true'
 			has_thrown_errors = True
 
+		try:
+			settings.save_lives = config.get('pyinstalive', 'save_lives').title()
+			if not settings.save_lives in bool_values:
+				log("[W] Invalid or missing setting detected for 'save_lives', using default value (True)", "YELLOW")
+				settings.save_lives = 'true'
+				has_thrown_errors = True
+		except:
+			log("[W] Invalid or missing setting detected for 'save_lives', using default value (True)", "YELLOW")
+			settings.save_lives = 'true'
+			has_thrown_errors = True
+
 
 
 		try:
@@ -183,7 +194,7 @@ def show_info(config):
 	except Exception as e:
 		log("[W] Could not check for cookie files: {:s}".format(str(e)), "YELLOW")
 		log("", "ENDC")
-	log("[I] To see all the available flags, use the -h flag.", "BLUE")
+	log("[I] To see all the available arguments, use the -h argument.", "BLUE")
 	log("", "GREEN")
 	log("[I] PyInstaLive version:    	{:s}".format(script_version), "GREEN")
 	log("[I] Python version:         	{:s}".format(python_version), "GREEN")
@@ -234,9 +245,22 @@ def new_config():
 		else:
 			try:
 				log("[W] Could not find configuration file, creating a default one...", "YELLOW")
-				config_template = "[pyinstalive]\nusername = johndoe\npassword = grapefruits\nsave_path = {:s}\nshow_cookie_expiry = true\nclear_temp_files = false\nsave_replays = true\nrun_at_start = \nrun_at_finish = \nsave_comments = false\nlog_to_file = false\n".format(os.getcwd())
+				config_template = """
+[pyinstalive]
+username = johndoe
+password = grapefruits
+save_path = {:s}
+show_cookie_expiry = true
+clear_temp_files = false
+save_lives = true
+save_replays = true
+run_at_start = 
+run_at_finish = 
+save_comments = false
+log_to_file = false
+				""".format(os.getcwd())
 				config_file = open("pyinstalive.ini", "w")
-				config_file.write(config_template)
+				config_file.write(config_template.strip())
 				config_file.close()
 				log("[W] Edit the created 'pyinstalive.ini' file and run this script again.", "YELLOW")
 				seperator("GREEN")
@@ -245,7 +269,8 @@ def new_config():
 				log("[E] Could not create default config file: {:s}".format(str(e)), "RED")
 				log("[W] You must manually create and edit it with the following template: ", "YELLOW")
 				log("", "GREEN")
-				log(config_template, "YELLOW")
+				for line in config_template.strip().splitlines():
+					log("    {:s}".format(line.rstrip()), "YELLOW")
 				log("", "GREEN")
 				log("[W] Save it as 'pyinstalive.ini' and run this script again.", "YELLOW")
 				seperator("GREEN")
@@ -319,6 +344,7 @@ def run():
 	parser.add_argument('-i', '--info', dest='info', action='store_true', help="View information about PyInstaLive.")
 	parser.add_argument('-c', '--config', dest='config', action='store_true', help="Create a default configuration file if it doesn't exist.")
 	parser.add_argument('-nr', '--noreplays', dest='noreplays', action='store_true', help="When used, do not check for any available replays.")
+	parser.add_argument('-nl', '--nolives', dest='nolives', action='store_true', help="When used, do not check for any available livestreams.")
 	parser.add_argument('-cl', '--clean', dest='clean', action='store_true', help="PyInstaLive will clean the current download folder of all leftover files.")
 
 	# Workaround to 'disable' argument abbreviations
@@ -330,6 +356,7 @@ def run():
 	parser.add_argument('--noreplayx', help=argparse.SUPPRESS, metavar='IGNORE') 
 	parser.add_argument('--cleax', help=argparse.SUPPRESS, metavar='IGNORE')
 	parser.add_argument('-cx', help=argparse.SUPPRESS, metavar='IGNORE')
+	parser.add_argument('-nx', help=argparse.SUPPRESS, metavar='IGNORE')
 
 
 	args, unknown = parser.parse_known_args()
@@ -378,6 +405,7 @@ def run():
 	args.info and not
 	args.config and not
 	args.noreplays and not
+	args.nolives and not
 	args.clean):
 		show_info(config)
 		sys.exit(0)
@@ -399,42 +427,58 @@ def run():
 
 
 	if check_config_validity(config):
-		if (args.clean):
-			clean_download_dir()
-			sys.exit(0)
+		try:
+			if (args.clean):
+				clean_download_dir()
+				sys.exit(0)
 
-		if not check_ffmpeg():
-			log("[E] Could not find ffmpeg, the script will now exit. ", "RED")
-			seperator("GREEN")
-			sys.exit(1)
+			if not check_ffmpeg():
+				log("[E] Could not find ffmpeg, the script will now exit. ", "RED")
+				seperator("GREEN")
+				sys.exit(1)
 
-		if (args.download == None):
-			log("[E] Missing --download argument. Please specify an Instagram username.", "RED")
-			seperator("GREEN")
-			sys.exit(1)
+			if (args.noreplays):
+				settings.save_replays = "False"
 
-		if (args.noreplays):
-			settings.save_replays = "false"
+			if (args.nolives):
+				settings.save_lives = "False"
 
-		if (args.username is not None) and (args.password is not None):
-			api = login(args.username, args.password, settings.show_cookie_expiry, True)
-		elif (args.username is not None) or (args.password is not None):
-			log("[W] Missing -u or -p arguments, falling back to config file...", "YELLOW")
-			if (not len(settings.username) > 0) or (not len(settings.password) > 0):
-				log("[E] Username or password are missing. Please check your configuration settings and try again.", "RED")
+			if settings.save_lives == "False" and settings.save_replays == "False":
+				log("[W] Script will not run because both live and replay saving is disabled.", "YELLOW")
 				seperator("GREEN")
 				sys.exit(1)
-			else:
-				api = login(settings.username, settings.password, settings.show_cookie_expiry, False)
-		else:
-			if (not len(settings.username) > 0) or (not len(settings.password) > 0):
-				log("[E] Username or password are missing. Please check your configuration settings and try again.", "RED")
+
+			if not args.download:
+				log("[W] Missing --download argument. Please specify an Instagram username.", "YELLOW")
 				seperator("GREEN")
 				sys.exit(1)
+
+
+			if (args.username is not None) and (args.password is not None):
+				api = login(args.username, args.password, settings.show_cookie_expiry, True)
+			elif (args.username is not None) or (args.password is not None):
+				log("[W] Missing --username or --password argument, falling back to config file...", "YELLOW")
+				if (not len(settings.username) > 0) or (not len(settings.password) > 0):
+					log("[E] Username or password are missing. Please check your configuration settings and try again.", "RED")
+					seperator("GREEN")
+					sys.exit(1)
+				else:
+					api = login(settings.username, settings.password, settings.show_cookie_expiry, False)
 			else:
-				api = login(settings.username, settings.password, settings.show_cookie_expiry, False)
+				if (not len(settings.username) > 0) or (not len(settings.password) > 0):
+					log("[E] Username or password are missing. Please check your configuration settings and try again.", "RED")
+					seperator("GREEN")
+					sys.exit(1)
+				else:
+					api = login(settings.username, settings.password, settings.show_cookie_expiry, False)
 
-		main(api, args.download, settings)
+			main(api, args.download, settings)
+		except Exception as e:
+			log("[E] Could not finish pre-download checks:  {:s}".format(str(e)), "RED")
+			seperator("GREEN")
+		except KeyboardInterrupt as ee:
+			log("[W] Pre-download checks have been aborted, exiting...", "YELLOW")
+			seperator("GREEN")
 
 	else:
 		log("[E] The configuration file is not valid. Please check your configuration settings and try again.", "RED")

+ 1 - 0
pyinstalive/settings.py

@@ -10,6 +10,7 @@ class settings:
 	current_time = str(int(time.time()))
 	current_date = time.strftime("%Y%m%d")
 	save_replays = "true"
+	save_lives = "true"
 	run_at_start = "None"
 	run_at_finish = "None"
 	save_comments = "true"

+ 1 - 1
setup.py

@@ -2,7 +2,7 @@ from setuptools import setup
 
 __author__ = 'notcammy'
 __email__ = 'neus2benen@gmail.com'
-__version__ = '2.5.5'
+__version__ = '2.5.6'
 
 _api_version = '1.5.7'
 _api_extensions_version = '0.3.8'