From 85ce40bdbd8642e8dd67ef3f42f8ab67946c3926 Mon Sep 17 00:00:00 2001 From: Et0h Date: Tue, 26 Jan 2016 23:48:33 +0000 Subject: [PATCH] Relay error if file format is not recognized by mpv --- syncplay/constants.py | 2 ++ syncplay/players/mpv.py | 11 ++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index 488093f..568520b 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -111,6 +111,8 @@ MPV_ICONPATH = "mpv.png" MPC_ICONPATH = "mpc-hc.png" MPC64_ICONPATH = "mpc-hc64.png" +MPV_ERROR_MESSAGES_TO_REPEAT = ['[ytdl_hook] Your version of youtube-dl is too old', '[ytdl_hook] youtube-dl failed', 'Failed to recognize file format.'] + #Changing these is usually not something you're looking for PLAYER_ASK_DELAY = 0.1 PING_MOVING_AVERAGE_WEIGHT = 0.85 diff --git a/syncplay/players/mpv.py b/syncplay/players/mpv.py index 2439a15..3167f8b 100644 --- a/syncplay/players/mpv.py +++ b/syncplay/players/mpv.py @@ -83,7 +83,7 @@ class OldMpvPlayer(MpvPlayer): self._paused = not self._paused self._listener.sendLine('cycle pause') - def mpvVersionErrorCheck(self, line): + def mpvErrorCheck(self, line): if "Error parsing option" in line or "Error parsing commandline option" in line: self.quitReason = getMessage("mpv-version-error") @@ -91,14 +91,11 @@ class OldMpvPlayer(MpvPlayer): self.reactor.callFromThread(self._client.ui.showErrorMessage, getMessage("mpv-version-error"), True) self.drop() - elif "[ytdl_hook] Your version of youtube-dl is too old" in line: - self._client.ui.showErrorMessage(line) - - elif "[ytdl_hook] youtube-dl failed" in line: + if any(errormsg in line for errormsg in constants.MPV_ERROR_MESSAGES_TO_REPEAT): self._client.ui.showErrorMessage(line) def _handleUnknownLine(self, line): - self.mpvVersionErrorCheck(line) + self.mpvErrorCheck(line) if "Playing: " in line: newpath = line[9:] oldpath = self._filepath @@ -208,7 +205,7 @@ class NewMpvPlayer(OldMpvPlayer): self._storePosition(0) def _handleUnknownLine(self, line): - self.mpvVersionErrorCheck(line) + self.mpvErrorCheck(line) if line == "" or "Playing:" in line: self._clearFileLoaded()