Parcourir la source

Improve path handling, fix slash in output files on Linux based systems

Cammy il y a 7 ans
Parent
commit
117e940d34
2 fichiers modifiés avec 8 ajouts et 4 suppressions
  1. 2 2
      pyinstalive/downloader.py
  2. 6 2
      pyinstalive/pyinstalive.py

+ 2 - 2
pyinstalive/downloader.py

@@ -36,7 +36,7 @@ def recordStream(broadcast):
 				   or broadcast.get('dash_abr_playback_url')
 				   or broadcast['dash_playback_url'])
 
-		outputDir = savePath + '\{}_{}_{}_{}_downloads'.format(currentDate ,record, broadcast['id'], currentTime)
+		outputDir = savePath + '{}_{}_{}_{}_downloads'.format(currentDate ,record, broadcast['id'], currentTime)
 
 		dl = live.Downloader(
 			mpd=mpd_url,
@@ -79,7 +79,7 @@ def recordStream(broadcast):
 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)
+		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")

+ 6 - 2
pyinstalive/pyinstalive.py

@@ -31,9 +31,13 @@ def run():
 		api = auth.login(args.username, args.password)
 	else:
 		api = auth.login(config['pyinstalive']['username'], config['pyinstalive']['password'])
+    
+    savePath = config['pyinstalive']['save_path']
+    if not savePath.endswith('/'):
+    	savePath = savePath + '/'
 
-	if (os.path.exists(config['pyinstalive']['save_path'])):
-		downloader.main(api, args.record, config['pyinstalive']['save_path'])
+	if (os.path.exists(savePath)):
+		downloader.main(api, args.record, savePath)
 	else:
 		logger.log("[W] Invalid save path was specified! Falling back to location: " + os.getcwd(), "RED")
 		downloader.main(api, args.record, os.getcwd())