Skip to content

Commit

Permalink
Error Handling 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kanehekili committed Apr 8, 2022
1 parent 4ceff1c commit 98a35ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/FFMPEGTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def __init__(self, video_file):
def _readData(self):
result = Popen(["ffprobe", "-show_format", "-show_streams", self.path, "-v", "quiet"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if len(result[0]) == 0:
raise IOError('No such media file ' + self.path)
raise IOError('Not a media file ' + self.path)
self.streams = []
datalines = []
self.video = []
Expand Down Expand Up @@ -653,6 +653,11 @@ def _readData(self):
self.video.append(a)
elif a.isSubTitle():
self.subtitle.append(a)
self.sanityCheck()

def sanityCheck(self):
if self.getVideoStream() is None:
raise IOError("No video stream available")

def getVideoStream(self):
if len(self.video) == 0:
Expand Down
2 changes: 1 addition & 1 deletion src/VideoCut.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ def setFile(self, filePath):
self.gui.updateWindowTitle(OSTools().getFileNameOnly(filePath))
self._initVideoViews()
except Exception as ex:
Log.logException("Error 2")
Log.logException("Setting file")
if not OSTools().fileExists(filePath):
self.lastError = "File not found"
else:
Expand Down

0 comments on commit 98a35ed

Please sign in to comment.