From 225f83f5a5f077d7b7f7c476f825a0ded8008b74 Mon Sep 17 00:00:00 2001 From: Pawky Languish Date: Thu, 28 Nov 2024 18:49:54 +0000 Subject: add apple music --- youtube.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'youtube.py') diff --git a/youtube.py b/youtube.py index f15613e..1e60546 100755 --- a/youtube.py +++ b/youtube.py @@ -96,6 +96,9 @@ class YouTube: video_id = None try: playlist_id = qs["list"][0] + #ignore the "random mix" and "radio" lists + if playlist_id.startswith("RD"): + playlist_id = None except KeyError: playlist_id = None if (self.prefer_playlist and playlist_id) or (playlist_id and not video_id): @@ -104,7 +107,7 @@ class YouTube: url = url.scheme + "://" + url.netloc + url.path + "?v=" + video_id url = f"https://www.youtube.com/oembed?{urlencode([('url',url),('format','json')])}" try: - #print(url, " and ", playlist_id) + # print(url, " and ", playlist_id) data = urlopen(url).read().decode() data = json_loads(data) title = data["title"] @@ -125,8 +128,8 @@ class YouTube: if __name__ == "__main__": import sys - #if url is a video that's part of a playlist, - #return playlist (True) or video (False, default)? - #YouTube.prefer_playlist=False + # if url is a video that's part of a playlist, + # return playlist (True) or video (False, default)? + # YouTube.prefer_playlist=False YouTube().yt(sys.argv[1]) - #YouTube.yt(YouTube, sys.argv[1]) + # YouTube.yt(YouTube, sys.argv[1]) -- cgit 1.4.1-2-gfad0