From fa9b816d0650594033f3392cd3034717f12a307c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 4 Aug 2019 17:36:06 +0200 Subject: [PATCH] Return the parsed raw YouTube URL only if available, otherwise the original URL --- platypush/plugins/media/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/media/__init__.py b/platypush/plugins/media/__init__.py index 91d406f7e..9015f30cc 100644 --- a/platypush/plugins/media/__init__.py +++ b/platypush/plugins/media/__init__.py @@ -465,7 +465,8 @@ class MediaPlugin(Plugin): url = 'https://www.youtube.com/watch?v={}'.format(m.group(1)) proc = subprocess.Popen(['youtube-dl', '-f', 'best', '-g', url], stdout=subprocess.PIPE) - return proc.stdout.read().decode("utf-8", "strict")[:-1] + raw_url = proc.stdout.read().decode("utf-8", "strict")[:-1] + return raw_url if raw_url else url @action def get_youtube_info(self, url):