### Search Software and Get Name (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Searches for a software application on iTunes and prints its name. This function utilizes the 'itunespy' library. It returns the name of the first matching software result. ```python import itunespy telegram = itunespy.search_software('Telegram') print(telegram[0].track_name) # Prints 'Telegram Messenger' ``` -------------------------------- ### Search Track and Get Info (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Searches for a specific track on iTunes and displays the artist's name, track name, and its length in minutes. This function requires the 'itunespy' library and returns information about the first matching track. ```python import itunespy track = itunespy.search_track('Iter Impius') # Returns a list print(track[0].artist_name + ': ' + track[0].track_name + ' | Length: ' + str(track[0].get_track_time_minutes())) # Get info from the first result ``` -------------------------------- ### Search Ebook Author and Get Books (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Searches for an ebook author on iTunes and retrieves a list of their published books. The function then prints the name of each book. This requires the 'itunespy' library. ```python import itunespy author = itunespy.search_book_author('Fyodor Dostoevsky') # Search for Dostoevsky books = author[0].get_books() # Get books from the firs result for book in books: print(book.track_name) # Show each book's name ``` -------------------------------- ### Search Artist and Get Album Names (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Searches for a specified artist on iTunes and retrieves a list of all their album names. This function requires the 'itunespy' library and returns a list of album names. ```python import itunespy artist = itunespy.search_artist('Steven Wilson') # Returns a list albums = artist[0].get_albums() # Get albums from the first result for album in albums: print(album.collection_name) ``` -------------------------------- ### Search Album and Get Track Info (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Searches for a specified album on iTunes and retrieves a list of all its songs, including their names and lengths. It also calculates and prints the total playing time of the album. This function requires the 'itunespy' library. ```python import itunespy album = itunespy.search_album('One Hour By The Concrete Lake') # Returns a list tracks = album[0].get_tracks() # Get tracks from the first result for track in tracks: print(track.artist_name + ': ' + track.track_name + str(track.get_track_time_minutes())) print('Total playing time: ' + str(album[0].get_album_time())) ``` -------------------------------- ### Get Albums from Artist using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Retrieves all albums published by a specific artist using an artist object obtained from a search. It iterates through the albums and prints their names and release years. Dependencies: itunespy. ```python import itunespy # Search for an artist and get their albums artists = itunespy.search_artist('Pink Floyd') artist = artists[0] # Get all albums albums = artist.get_albums() print(f"Albums by {artist.artist_name}:") for album in albums: print(f" - {album.collection_name} ({album.release_date[:4]})") print(f" Tracks: {album.track_count}, Price: {album.collection_price}") ``` -------------------------------- ### Get Tracks from Album using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Retrieves all tracks from a specific album using an album object obtained from a search. It iterates through the tracks, prints their names and durations, and calculates the total album time. Dependencies: itunespy. ```python import itunespy # Search for an album and get its tracks albums = itunespy.search_album('Abbey Road') album = albums[0] # Get all tracks tracks = album.get_tracks() print(f"Tracks in '{album.collection_name}':") total_time = 0 for track in tracks: duration = track.get_track_time_minutes() total_time += duration print(f" {track.track_number}. {track.track_name} - {duration} min") # Get total album time album_time = album.get_album_time() print(f"\nTotal Album Time: {album_time} minutes") ``` -------------------------------- ### Perform Advanced iTunes Searches with Custom Parameters (Python) Source: https://context7.com/sleepyfran/itunespy/llms.txt Illustrates how to conduct flexible searches using the itunespy library by specifying a wide range of API parameters such as term, country, media type, entity, attribute, and limit. Also demonstrates searching across all media types and filtering results. ```python import itunespy # Search with all parameters results = itunespy.search( term='Jazz', country='FR', media='music', entity='album', attribute='genreIndex', limit=25 ) print(f"Found {len(results)} results") for result in results: if hasattr(result, 'collection_name'): print(f"Album: {result.collection_name}") print(f"Artist: {result.artist_name}") print(f"Genre: {result.primary_genre_name}") print() # Search across all media types all_results = itunespy.search( term='Star Wars', media='all', limit=50 ) # Filter by type movies = [r for r in all_results if r.type == 'track' and hasattr(r, 'track_type') and 'movie' in r.track_type] music = [r for r in all_results if r.type == 'track' and hasattr(r, 'track_type') and 'song' in r.track_type] print(f"Movies: {len(movies)}, Music: {len(music)}") ``` -------------------------------- ### Search Ebooks and Authors using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for ebooks and authors in the iTunes Store. It demonstrates looking up an author by name, retrieving their books, and searching for specific book titles. Details like book name, author, description, and price are printed. ```python import itunespy # Search for an author authors = itunespy.search_book_author('Fyodor Dostoevsky') author = authors[0] print(f"Author: {author.artist_name}") # Get books by the author books = author.get_books() print(f"\nBooks by {author.artist_name}:") for book in books: print(f" - {book.track_name}") if hasattr(book, 'description'): print(f" Description: {book.description[:100]}...") if hasattr(book, 'price'): print(f" Price: {book.price}") # Search for specific books book_results = itunespy.search_book('Crime and Punishment') for book in book_results: print(f"Book: {book.track_name}") print(f"Author: {book.artist_name}") ``` -------------------------------- ### Handle Track Time Conversions with itunespy (Python) Source: https://context7.com/sleepyfran/itunespy/llms.txt Demonstrates how to retrieve track information and convert the track duration into different units (milliseconds, minutes, hours) using methods provided by the itunespy library. Supports custom rounding for time values. ```python import itunespy # Search for a track tracks = itunespy.search_track('Stairway to Heaven') track = tracks[0] # Get time in different formats print(f"Track: {track.track_name}") print(f"Time (milliseconds): {track.track_time}") print(f"Time (minutes): {track.get_track_time_minutes()} min") print(f"Time (hours): {track.get_track_time_hours()} hrs") # Custom rounding print(f"Time (3 decimals): {track.get_track_time_minutes(round_number=3)} min") ``` -------------------------------- ### Implement Error Handling for iTunes API Requests (Python) Source: https://context7.com/sleepyfran/itunespy/llms.txt Provides robust error handling for operations performed using the itunespy library. It includes specific `try-except` blocks to catch potential `LookupError`, `ConnectionError`, and `RuntimeError` during searches, as well as `ValueError` for missing required parameters in lookup requests. ```python import itunespy try: # Search that might fail results = itunespy.search_artist('NonExistentArtistXYZ123') for artist in results: print(f"Found: {artist.artist_name}") except LookupError as e: print(f"Search Error: {e}") print("No results found for the search term") except ConnectionError as e: print(f"Connection Error: {e}") print("Cannot connect to iTunes API") except RuntimeError as e: print(f"Runtime Error: {e}") print("Cannot fetch JSON data from the API") # Lookup error handling try: results = itunespy.lookup(id=99999999999) except LookupError: print("No results found for the given ID") # Missing parameters try: results = itunespy.lookup() except ValueError as e: print(f"Value Error: {e}") print("At least one ID parameter (id, artist_amg_id, or upc) is required") ``` -------------------------------- ### Search Software Applications using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for software applications in the iTunes/App Store by name. It displays the app name, developer, price, average user rating, number of reviews, and version number. ```python import itunespy # Search for software apps = itunespy.search_software('Telegram') app = apps[0] print(f"App Name: {app.track_name}") print(f"Developer: {app.artist_name}") print(f"Price: {app.price if hasattr(app, 'price') else 'N/A'}") print(f"Rating: {app.average_user_rating if hasattr(app, 'average_user_rating') else 'N/A'}") print(f"Reviews: {app.user_rating_count if hasattr(app, 'user_rating_count') else 'N/A'}") print(f"Version: {app.version if hasattr(app, 'version') else 'N/A'}") # Search iPad-specific software ipad_apps = itunespy.search_ipad_software('GarageBand') # Search Mac software mac_apps = itunespy.search_mac_software('Final Cut Pro') ``` -------------------------------- ### Search TV Shows using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for TV episodes and seasons in the iTunes Store. It prints details for TV episodes like name, series, duration, and price. For TV seasons, it prints the collection name and price. ```python import itunespy # Search for TV episodes episodes = itunespy.search_tv_episodes('Breaking Bad') for episode in episodes: print(f"Episode: {episode.track_name}") if hasattr(episode, 'collection_name'): print(f"Series: {episode.collection_name}") print(f"Duration: {episode.get_track_time_minutes()} min") print(f"Price: {episode.track_price}") print() # Search for TV seasons seasons = itunespy.search_tv_season('Game of Thrones', limit=10) for season in seasons: print(f"Season: {season.collection_name}") if hasattr(season, 'collection_price'): print(f"Price: {season.collection_price}") ``` -------------------------------- ### Process Mixed Result Types from General iTunes Search (Python) Source: https://context7.com/sleepyfran/itunespy/llms.txt Demonstrates how to perform a general search using itunespy and then categorize the results into different types such as `MusicArtist`, `MusicAlbum`, and `Track` using `isinstance`. This allows for type-specific processing of the returned data. ```python import itunespy from itunespy.music_artist import MusicArtist from itunespy.music_album import MusicAlbum from itunespy.track import Track # Perform a general search results = itunespy.search('Radiohead', media='music', limit=50) # Separate results by type artists = [r for r in results if isinstance(r, MusicArtist)] albums = [r for r in results if isinstance(r, MusicAlbum)] tracks = [r for r in results if isinstance(r, Track)] print(f"Artists: {len(artists)}") for artist in artists: print(f" - {artist.artist_name} (ID: {artist.artist_id})") print(f"\nAlbums: {len(albums)}") for album in albums: print(f" - {album.collection_name} ({album.release_date[:4]})") print(f"\nTracks: {len(tracks)}") for track in tracks: print(f" - {track.track_name} from {track.collection_name}") ``` -------------------------------- ### Perform iTunes Lookup by UPC (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Performs a lookup on the iTunes Store using a Universal Product Code (UPC). It returns a list of items matching the UPC, and prints the artist name and collection name for each item. Requires the 'itunespy' library. ```python import itunespy lookup = itunespy.lookup(upc=720642462928) # Lookup for the Weezer's album 'Weezer' for item in lookup: print(item.artist_name + ': ' + item.collection_name) ``` -------------------------------- ### Lookup Album with Tracks using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Fetches a specific album by its ID and retrieves all associated tracks along with timing information. It prints the album title, artist name, and details for each track including its duration in minutes. ```python import itunespy # Lookup album by ID album_results = itunespy.lookup_album(id=1440873481) album = album_results[0] print(f"Album: {album.collection_name}") print(f"Artist: {album.artist_name}") # Get all tracks tracks = album.get_tracks() for i, track in enumerate(tracks, 1): print(f"{i}. {track.track_name} - {track.get_track_time_minutes()} min") print(f"\nTotal Duration: {album.get_album_time()} minutes") ``` -------------------------------- ### Access Common Metadata using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Demonstrates accessing common metadata properties from result objects returned by itunespy functions. It highlights that all result items inherit from ResultItem, ensuring consistent property access. ```python import itunespy # Example usage would follow here, accessing properties like: # result_item.type # result_item.track_name # result_item.artist_name # etc. ``` -------------------------------- ### Search iTunes Content and Display Properties (Python) Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for content on iTunes using specified terms and country, then iterates through results to display common properties like type, artist, track name, collection name, country codes, and artwork URLs. Includes checks for attribute existence. ```python import itunespy # Search for any content results = itunespy.search('Beatles', country='US', limit=5) for item in results: # Type checking print(f"Type: {item.type}") # Common properties (if available) if hasattr(item, 'artist_name'): print(f"Artist: {item.artist_name}") if hasattr(item, 'track_name'): print(f"Track: {item.track_name}") if hasattr(item, 'collection_name'): print(f"Collection: {item.collection_name}") # Country information print(f"Country (ISO2): {item.get_country('alpha_2')}") print(f"Country (ISO3): {item.get_country('alpha_3')}") print(f"Country Name: {item.get_country('name')}") # Artwork if hasattr(item, 'artwork_url_100'): print(f"Artwork (100px): {item.artwork_url_100}") print(f"Artwork (1500px): {item.get_artwork_url(1500)}") print("-" * 50) ``` -------------------------------- ### Lookup Artist with Albums using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Retrieves an artist's information and their entire discography by artist ID. It prints the artist's name and primary genre, then lists all their albums with their release year. ```python import itunespy # Lookup artist by ID artist_results = itunespy.lookup_artist(id=136975) artist = artist_results[0] print(f"Artist: {artist.artist_name}") print(f"Genre: {artist.primary_genre_name}") # Get all albums albums = artist.get_albums() print(f"\nTotal Albums: {len(albums)}") for album in albums: print(f" - {album.collection_name} ({album.release_date[:4]})") ``` -------------------------------- ### Parse Release Dates into Datetime Objects (Python 3.7+) Source: https://context7.com/sleepyfran/itunespy/llms.txt Shows how to fetch album data and access its release date. It specifically highlights parsing the raw release date string into a Python datetime object, enabling access to year, month, and day. This feature requires Python 3.7 or later. ```python import itunespy from datetime import datetime # Search for an album albums = itunespy.search_album('The Dark Side of the Moon') album = albums[0] # Raw release date print(f"Release Date (raw): {album.release_date}") # Parsed datetime (Python 3.7+) try: release_datetime = album.parsed_release_date print(f"Release Year: {release_datetime.year}") print(f"Release Month: {release_datetime.month}") print(f"Release Day: {release_datetime.day}") except AttributeError: print("parsed_release_date requires Python 3.7+") ``` -------------------------------- ### Lookup Album by UPC with Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Fetches album details using its UPC (Universal Product Code). It iterates through the results, printing the type, collection name, artist name, and release date if available. ```python import itunespy # Lookup album by UPC results = itunespy.lookup(upc=720642462928) for item in results: print(f"Type: {item.type}") if hasattr(item, 'collection_name'): print(f"Album: {item.collection_name}") print(f"Artist: {item.artist_name}") print(f"Release Date: {item.release_date}") ``` -------------------------------- ### Perform iTunes Lookup by ID and Check Type (Python) Source: https://github.com/sleepyfran/itunespy/blob/master/README.md Performs a lookup on the iTunes Store using an ID (e.g., for an artist). It iterates through the results, checking the 'type' property of each item to identify if it's an 'artist' and then prints additional artist-specific information. Requires the 'itunespy' library. ```python import itunespy lookup = itunespy.lookup(id=428011728) # Steven Wilson's ID for l in lookup: if l.type == 'artist': print('Artist!') print(l.artist_type) # Since it's an artist, you can also check its artist type ``` -------------------------------- ### Search Artists by Name using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for music artists by their name and returns a list of matching artists with their metadata. It supports specifying the country and limiting the number of results. Dependencies: itunespy. ```python import itunespy # Search for an artist artists = itunespy.search_artist('Steven Wilson') # Access artist information first_artist = artists[0] print(f"Artist: {first_artist.artist_name}") print(f"Artist ID: {first_artist.artist_id}") print(f"Type: {first_artist.type}") print(f"Primary Genre: {first_artist.primary_genre_name}") # Search with country and limit artists_uk = itunespy.search_artist('The Beatles', country='GB', limit=10) for artist in artists_uk: print(f"{artist.artist_name} - {artist.artist_view_url}") ``` -------------------------------- ### Search Movies using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches the iTunes Store for movies based on a title and country. It iterates through the results, printing details such as movie name, director, release date, pricing, genre, and content rating. ```python import itunespy # Search for movies movies = itunespy.search_movie('Inception', country='US', limit=10) for movie in movies: print(f"Movie: {movie.track_name}") print(f"Director: {movie.artist_name}") print(f"Release: {movie.release_date}") print(f"Price: {movie.track_price}") print(f"HD Price: {movie.track_hd_price}") print(f"Genre: {movie.primary_genre_name}") print(f"Rating: {movie.content_advisory_rating}") print() ``` -------------------------------- ### Search Movie Directors using Python Source: https://context7.com/sleepyfran/itunespy/llms.txt Finds movie directors by name in the iTunes Store. For each director found, it prints their name, artist type, and a URL to their profile. ```python import itunespy # Search for a director directors = itunespy.search_director('Christopher Nolan') for director in directors: print(f"Director: {director.artist_name}") print(f"Type: {director.artist_type}") print(f"View URL: {director.artist_view_url}") ``` -------------------------------- ### Lookup Items by UPC/EAN using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Looks up albums and tracks using Universal Product Codes (UPC) or European Article Numbers (EAN). This function facilitates direct lookup of media items via their product identifiers. Dependencies: itunespy. ```python import itunespy ``` -------------------------------- ### Lookup Items by iTunes ID using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Looks up items directly using their iTunes ID for precise retrieval. It handles different item types (artist, track, collection) and accesses their specific attributes. Dependencies: itunespy. ```python import itunespy # Lookup by iTunes ID results = itunespy.lookup(id=428011728) # Check result type and access accordingly for item in results: if item.type == 'artist': print(f"Artist: {item.artist_name}") print(f"Artist Type: {item.artist_type}") print(f"View URL: {item.artist_view_url}") elif item.type == 'track': print(f"Track: {item.track_name}") print(f"Album: {item.collection_name}") elif item.type == 'collection': print(f"Collection: {item.collection_name}") ``` -------------------------------- ### Search Albums by Title using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for music albums by their title and returns album objects containing collection metadata. This function allows for country-specific searches and limiting results. Dependencies: itunespy. ```python import itunespy # Search for an album albums = itunespy.search_album('Dark Side of the Moon') # Access album information album = albums[0] print(f"Album: {album.collection_name}") print(f"Artist: {album.artist_name}") print(f"Release Date: {album.release_date}") print(f"Track Count: {album.track_count}") print(f"Price: {album.collection_price} {album.currency}") print(f"Genre: {album.primary_genre_name}") # Search in specific country albums_de = itunespy.search_album('Metropolis', country='DE', limit=5) ``` -------------------------------- ### Search Tracks by Song Name using itunespy Source: https://context7.com/sleepyfran/itunespy/llms.txt Searches for individual music tracks by song name and returns track objects with detailed metadata. It supports attribute filtering (e.g., 'songTerm') and result limiting. Dependencies: itunespy. ```python import itunespy # Search for a track tracks = itunespy.search_track('Bohemian Rhapsody') # Access track information track = tracks[0] print(f"Track: {track.track_name}") print(f"Artist: {track.artist_name}") print(f"Album: {track.collection_name}") print(f"Duration: {track.get_track_time_minutes()} minutes") print(f"Preview URL: {track.preview_url}") print(f"Price: {track.track_price} {track.currency}") # Search with attribute filter tracks_filtered = itunespy.search_track('Love', attribute='songTerm', limit=20) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.