From d43f5f532062673ff30ea4e2bb9976b3094d78c3 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Sun, 16 Dec 2018 00:53:02 -0600 Subject: [PATCH] Skip restricted songs from playback --- src/controller/mainController.py | 5 +++++ src/controller/player.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 3a34dc6..f517375 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -231,6 +231,11 @@ class Controller(object): call_threaded(utils.download_file, url, filename, self.window) def play_audio(self, audio_object): + # Restricted audios does not include an URL paramether. + # Restriction can be due to licensed content to unauthorized countries. + if "url" in audio_object and audio_object["url"] =="": + self.notify(message=_(u"This file could not be played because it is not allowed in your country")) + return call_threaded(player.player.play, audio_object) def play_audios(self, audios): diff --git a/src/controller/player.py b/src/controller/player.py index 040f3bf..e2cc675 100644 --- a/src/controller/player.py +++ b/src/controller/player.py @@ -91,7 +91,8 @@ class audioPlayer(object): def play_all(self, list_of_urls, shuffle=False): self.stop() - self.queue = list_of_urls + # Skip all country restricted tracks as they are not playable here. + self.queue = [i for i in list_of_urls if i["url"] != ""] if shuffle: random.shuffle(self.queue) self.play(self.queue[0])