From 690df6e9d7d87143046a51870ac67b242dc1a8f3 Mon Sep 17 00:00:00 2001 From: Rafael Moraes <50295204+glomatico@users.noreply.github.com> Date: Wed, 10 Dec 2025 01:12:52 -0300 Subject: [PATCH] Update README example for AppleMusicApi usage --- README.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 0287ea4..5996a17 100644 --- a/README.md +++ b/README.md @@ -292,29 +292,27 @@ from gamdl.interface import ( AppleMusicUploadedVideoInterface, ) - async def main(): - # Initialize APIs - apple_music_api = AppleMusicApi.from_netscape_cookies(cookies_path="cookies.txt") - await apple_music_api.setup() - + # Create AppleMusicApi instance (from cookies or wrapper) + apple_music_api = await AppleMusicApi.create_from_netscape_cookies( + cookies_path="cookies.txt", + ) itunes_api = ItunesApi( apple_music_api.storefront, apple_music_api.language, ) - itunes_api.setup() - # Initialize interfaces + # Check subscription + assert apple_music_api.active_subscription + + # Set up interfaces interface = AppleMusicInterface(apple_music_api, itunes_api) song_interface = AppleMusicSongInterface(interface) music_video_interface = AppleMusicMusicVideoInterface(interface) uploaded_video_interface = AppleMusicUploadedVideoInterface(interface) - # Initialize base downloader + # Set up base downloader and specialized downloaders base_downloader = AppleMusicBaseDownloader() - base_downloader.setup() - - # Initialize specialized downloaders song_downloader = AppleMusicSongDownloader( base_downloader=base_downloader, interface=song_interface, @@ -328,7 +326,7 @@ async def main(): interface=uploaded_video_interface, ) - # Create main downloader + # Main downloader downloader = AppleMusicDownloader( interface=interface, base_downloader=base_downloader, @@ -338,10 +336,8 @@ async def main(): ) # Download a song - url_info = downloader.get_url_info( - "https://music.apple.com/us/album/never-gonna-give-you-up-2022-remaster/1624945511?i=1624945512" - ) - + url = "https://music.apple.com/us/album/never-gonna-give-you-up-2022-remaster/1624945511?i=1624945512" + url_info = downloader.get_url_info(url) if url_info: download_queue = await downloader.get_download_queue(url_info) if download_queue: @@ -360,4 +356,3 @@ MIT License - see [LICENSE](LICENSE) file for details ## 🤝 Contributing Currently, I'm not interested in reviewing pull requests that change or add features. Only critical bug fixes will be considered. However, feel free to open issues for bugs or feature requests. -