From 53dddb1f13c148c6895872b4d6b10bca355f02a4 Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Tue, 7 Apr 2026 19:49:56 +0200 Subject: [PATCH] Added spotify --- media/.cache | 1 + media/spotify-rss.py | 58 +++++++++++++++++--------------------------- 2 files changed, 23 insertions(+), 36 deletions(-) create mode 100644 media/.cache diff --git a/media/.cache b/media/.cache new file mode 100644 index 0000000..bd187f7 --- /dev/null +++ b/media/.cache @@ -0,0 +1 @@ +{"access_token": "BQDgExV1x8UWOU7F4SlKfHZXvpt_BopkdNKRer5JVumrSLqUGyqob7TiynJoa7L6rruy9_i97PH7IAwQZRhqwHOHyaOmvieH8lc0JUf1fxBiEYQRXsOg7izv4Obp1inLJF6898liuvc", "token_type": "Bearer", "expires_in": 3600, "expires_at": 1775587275} \ No newline at end of file diff --git a/media/spotify-rss.py b/media/spotify-rss.py index 110e20f..94df77a 100644 --- a/media/spotify-rss.py +++ b/media/spotify-rss.py @@ -11,51 +11,37 @@ SPOTIPY_CLIENT_SECRET = '6c8ea8c409d944cc895571f3f49985df' # The ID from your link: https://open.spotify.com/show/13Gs651PIKKI7zRF0p3PcJ SHOW_ID = '13Gs651PIKKI7zRF0p3PcJ' -def find_real_rss_feed(): - # Step 1: Authenticate with Spotify - auth_manager = SpotifyClientCredentials( - client_id=SPOTIPY_CLIENT_ID, - client_secret=SPOTIPY_CLIENT_SECRET - ) - sp = spotipy.Spotify(auth_manager=auth_manager) +# The show name you found on Spotify +show_name = 'Diario Sport' # Replace this with the actual show name - # Step 2: Get the Show Name from Spotify - print(f"Fetching details for Spotify Show ID: {SHOW_ID}...") - try: - show = sp.show(SHOW_ID) - show_name = show['name'] - publisher = show['publisher'] - print(f"Found Show: '{show_name}' by {publisher}") - except Exception as e: - print(f"Error fetching from Spotify: {e}") - return - - # Step 3: Search the iTunes API for that Show Name - print("\nSearching public directories (iTunes) for the real RSS feed...") - # We encode the name so it can be safely used in a URL (e.g., spaces become %20) +def find_rss_feed(show_name): + # Encode the show name for the URL encoded_name = urllib.parse.quote(show_name) - itunes_api_url = f"https://itunes.apple.com/search?term={encoded_name}&entity=podcast&limit=3" - + itunes_api_url = f"https://itunes.apple.com/search?term={encoded_name}&entity=podcast&limit=10" + try: response = requests.get(itunes_api_url) data = response.json() - + if data['resultCount'] > 0: - # Grab the first result's RSS feed URL - # We check the first few results to ensure the author matches, but usually the first is correct - real_rss_url = data['results'][0].get('feedUrl') - - print("\n✅ SUCCESS! Found the public RSS feed:") - print("-" * 50) - print(real_rss_url) - print("-" * 50) - print("You can copy and paste this URL directly into Apple Podcasts, Pocket Casts, or any standard RSS reader. It contains all the real .mp3 files!") + found_feed = None + for result in data['results']: + # Check if the show name matches + if show_name.lower() in result['collectionName'].lower(): + found_feed = result.get('feedUrl') + print("\n✅ SUCCESS! Found a matching public RSS feed:") + print("-" * 50) + print(found_feed) + break + + if not found_feed: + print("\n❌ No exact match found in public directories.") + print("You may want to check the show name manually.") else: print("\n❌ Could not find this show in public directories.") - print("This usually means the podcast is a 'Spotify Exclusive' and does not have a public RSS feed.") - + except Exception as e: print(f"Error searching iTunes: {e}") if __name__ == '__main__': - find_real_rss_feed() \ No newline at end of file + find_rss_feed(show_name) \ No newline at end of file