#!/usr/bin/env python3 """ Download specific songs that aren't working through the app """ import yt_dlp import os import sys # Songs to download SONGS = [ { "query": "Solange something never seems to", "artist": "Solange", "expected_title": "Something Never Seems To" }, { "query": "know u miss me chasinbens travis scott sdp", "artist": "ChasinBens / Travis Scott", "expected_title": "Know U Miss Me" } ] # Download directory - adjust this to your Jellyfin music folder DOWNLOAD_DIR = "/Volumes/SamMgmt/Containers/SamCloud Music App/downloads" def search_and_download(query, artist, expected_title): """Search for a song and download it""" print(f"\nšŸ” Searching for: {query}") print(f" Artist: {artist}") print(f" Expected: {expected_title}") # Create download directory os.makedirs(DOWNLOAD_DIR, exist_ok=True) # yt-dlp options ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': f'{DOWNLOAD_DIR}/%(artist)s - %(title)s.%(ext)s', 'extractaudio': True, 'audioformat': 'mp3', 'audioquality': '320k', 'embed_thumbnail': True, 'writeinfojson': False, 'no_warnings': False, } try: with yt_dlp.YoutubeDL(ydl_opts) as ydl: # Search for the song search_results = ydl.extract_info( f"ytsearch5:{query}", download=False ) if not search_results or 'entries' not in search_results: print(f"āŒ No results found for: {query}") return False # Show search results print(f"\nšŸ“‹ Found {len(search_results['entries'])} results:") for i, entry in enumerate(search_results['entries'][:5]): duration = entry.get('duration', 0) duration_str = f"{duration//60}:{duration%60:02d}" if duration else "Unknown" print(f" {i+1}. {entry.get('title', 'Unknown')} - {duration_str}") # Ask user to select while True: try: choice = input(f"\nSelect result (1-{len(search_results['entries'])}), or 's' to skip: ") if choice.lower() == 's': print("ā­ļø Skipping...") return False choice = int(choice) - 1 if 0 <= choice < len(search_results['entries']): break else: print("Invalid choice, try again.") except ValueError: print("Invalid input, try again.") # Download selected song selected = search_results['entries'][choice] print(f"\nā¬‡ļø Downloading: {selected.get('title', 'Unknown')}") ydl.download([selected['webpage_url']]) print(f"āœ… Download completed!") return True except Exception as e: print(f"āŒ Error downloading {query}: {str(e)}") return False def main(): print("šŸŽµ SamCloud Music - Manual Song Downloader") print("=" * 50) for song in SONGS: success = search_and_download( song["query"], song["artist"], song["expected_title"] ) if success: print(f"āœ… Successfully downloaded: {song['expected_title']}") else: print(f"āŒ Failed to download: {song['expected_title']}") print("-" * 50) print(f"\nšŸ“ Downloads saved to: {DOWNLOAD_DIR}") print("šŸ’” Move these files to your Jellyfin music library folder") print("šŸ”„ Then trigger a library scan in Jellyfin to add them") if __name__ == "__main__": main()