Ver Fonte

Update gitignore, improve logging output, add error handling for video stitching

Cammy há 7 anos atrás
pai
commit
dc14ed04df
4 ficheiros alterados com 22 adições e 13 exclusões
  1. 3 1
      .gitignore
  2. 0 6
      pyinstalive/auth.py
  3. 10 5
      pyinstalive/downloader.py
  4. 9 1
      pyinstalive/pyinstalive.py

+ 3 - 1
.gitignore

@@ -1,7 +1,9 @@
 *.pyc
 
-credentials\.json
+pyinstalive/credentials\.json
 
 last_stream\.html
 
 looper\.sh
+
+pyinstalive/pyinstalive\.ini

+ 0 - 6
pyinstalive/auth.py

@@ -18,9 +18,6 @@ except ImportError:
         __version__ as client_version)
 
 
-scriptVersion = "2.1.3"
-
-
 def to_json(python_object):
     if isinstance(python_object, bytes):
         return {'__class__': 'bytes',
@@ -42,9 +39,6 @@ def onlogin_callback(api, settings_file):
 
 
 def login(username, password):
-    logger.log('PYINSTALIVE DOWNLOADER (SCRIPT v{0!s})'.format(scriptVersion), "GREEN")
-    logger.seperator("GREEN")
-
     device_id = None
     try:
         

+ 10 - 5
pyinstalive/downloader.py

@@ -66,7 +66,7 @@ def recordStream(broadcast):
 		logger.log('[I] Username    : ' + record, "GREEN")
 		logger.log('[I] MPD URL     : ' + mpd_url, "GREEN")
 		printStatus(api, broadcast)
-		logger.log('[I] Recording broadcast...', "GREEN")
+		logger.log('[I] Recording broadcast... press [CTRL+C] to abort.', "GREEN")
 		dl.run()
 		stitchVideo(dl, broadcast)
 	except KeyboardInterrupt:
@@ -80,10 +80,15 @@ def stitchVideo(dl, broadcast):
 		isRecording = False
 		logger.log('[I] Stitching downloaded files into video...', "GREEN")
 		output_file = savePath + '{}_{}_{}_{}.mp4'.format(currentDate ,record, broadcast['id'], currentTime)
-		dl.stitch(output_file, cleartempfiles=False)
-		logger.log('[I] Successfully stitched downloaded files!', "GREEN")
-		logger.seperator("GREEN")
-		sys.exit(0)
+		try:
+			dl.stitch(output_file, cleartempfiles=False)
+			logger.log('[I] Successfully stitched downloaded files!', "GREEN")
+			logger.seperator("GREEN")
+			sys.exit(0)
+		except Exception as e:
+			logger.log('[E] Could not stitch downloaded files: ' + str(e), "RED")
+			logger.seperator("GREEN")
+			sys.exit(0)
 
 def getUserInfo(record):
 	try:

+ 9 - 1
pyinstalive/pyinstalive.py

@@ -7,6 +7,12 @@ import auth, downloader, logger
 
 
 def run():
+
+	scriptVersion = "2.1.3"
+
+    logger.log('PYINSTALIVE DOWNLOADER (SCRIPT v{0!s})'.format(scriptVersion), "GREEN")
+    logger.seperator("GREEN")
+
 	logging.disable(logging.CRITICAL)
 	config = configparser.ConfigParser()
 
@@ -15,8 +21,10 @@ def run():
 			config.read('pyinstalive.ini')
 		except Exception as e:
 			logger.log("[E] Could not read configuration file! Try passing the required arguments manually.", "RED")
+			logger.seperator("GREEN")
 	else:
-		logger.log("[E] Could not find configuration file! Exiting...", "RED")
+		logger.log("[E] Could not find configuration file!", "RED")
+		logger.seperator("GREEN")
 		sys.exit(0)