All Projects → tombulled → python-youtube-music

tombulled / python-youtube-music

Licence: GPL-3.0 license
Python 3 YouTube Music Web API Client

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-youtube-music

Beatbump
Alternative YouTube Music frontend built with Svelte/SvelteKit 🎧
Stars: ✭ 77 (+97.44%)
Mutual labels:  youtube-music, youtube-music-api
YouTube-Music-API
An open-source Python library which Quickly gather the metadata of a Song, Playlist existing on YouTube or YouTube Music.
Stars: ✭ 18 (-53.85%)
Mutual labels:  youtube-music, youtube-music-api
YoutubeLiveChannelRecorder
Records YouTube live streams and Semi-Working TWITCH live streams for given channels automatically.
Stars: ✭ 15 (-61.54%)
Mutual labels:  youtube-api
youtube-json-server
Your personal Youtube API server to get Youtube API responses without needing credentials.
Stars: ✭ 32 (-17.95%)
Mutual labels:  youtube-api
react-youtube-search
⚛️ React with YouTube API
Stars: ✭ 18 (-53.85%)
Mutual labels:  youtube-api
yt-dislikes-viewer
A browser extension that allows you to see dislikes on a youtube video after the youtube update
Stars: ✭ 291 (+646.15%)
Mutual labels:  youtube-api
youtube-livestream-android-app
Livestream to your youtube channel by using this android app. Made using Youtube's live streaming API
Stars: ✭ 18 (-53.85%)
Mutual labels:  youtube-api
Laravel-Youtube-API
A way to add an API to your Laravel app that converts youtube video's to mp3/mp4 and returns a download/stream link and information.
Stars: ✭ 19 (-51.28%)
Mutual labels:  youtube-api
TruHealth
A website, which is wholly focused on Mental Health issues.
Stars: ✭ 16 (-58.97%)
Mutual labels:  youtube-api
MyVideoManager
A Laravel and Vuejs application for managing Youtube videos
Stars: ✭ 15 (-61.54%)
Mutual labels:  youtube-api
mulukhiya-toot-proxy
各種ActivityPub対応インスタンスへの投稿に対して、内容の更新等を行うプロキシ。通称「モロヘイヤ」。
Stars: ✭ 24 (-38.46%)
Mutual labels:  youtube-music
angular-youtube-api-factory
AngularJS Factory for Youtube JSON REST API requests
Stars: ✭ 21 (-46.15%)
Mutual labels:  youtube-api
ytpy
Python asynchronous wrapper for searching for youtube videos.
Stars: ✭ 19 (-51.28%)
Mutual labels:  youtube-music
search-youtube
An Android App used for searching and playing videos from YouTube. Used: Youtube Data API v3, YouTube Player API
Stars: ✭ 24 (-38.46%)
Mutual labels:  youtube-api
youtubly-android
An android app to download 📹 videos and 🎶 songs from youtube to phone internal storage. In a nutshell NewPipe for just audio.
Stars: ✭ 24 (-38.46%)
Mutual labels:  youtube-api
youtube-python
YouTube Api wrapper in python
Stars: ✭ 65 (+66.67%)
Mutual labels:  youtube-api
yt-restore-dislikes
👎 A browser extension for restoring the dislike count on YouTube videos.
Stars: ✭ 24 (-38.46%)
Mutual labels:  youtube-api
statamic-video-embed
A field type for embedding YouTube and Vimeo Videos
Stars: ✭ 16 (-58.97%)
Mutual labels:  youtube-api
youtube-chat-for-minecraft
A plugin for Minecraft Forge that provides an API for YouTube live chat services
Stars: ✭ 53 (+35.9%)
Mutual labels:  youtube-api
youtube-playlist
❄️ Extract links, ids, and names from a youtube playlist
Stars: ✭ 73 (+87.18%)
Mutual labels:  youtube-api

python-youtube-music

Made With Python Built By Neckbeards Gluten Free
Forks Stars Issues License

Python YouTube Music Web API Client - No longer under active development, instead checkout innertube

YouTube Music

Contents:

Dependencies

Libraries ytm depends on

Required Dependencies

Library Install Import Functionality
Requests pip install requests import requests Send HTTP/HTTPS requests

Optional Dependencies

Library Install Import Functionality
YoutubeDL pip install youtube-dl import youtube_dl Download YouTube videos
Mutagen pip install mutagen import mutagen Read and write audio metadata
Pillow (PIL) pip install Pillow import PIL Python imaging library

Installation

Install ytm onto your system.

Install From Source

Firstly, clone or download this repository.

Basic Installation:

No YouTubeMusicDL support

user@host:~$ pip install . # You may need to use: python3 -m pip install .
Successfully installed ytm

Full Installation:

YouTubeMusicDL support

user@host:~$ pip install .[dl] # You may need to use: python3 -m pip install .[dl]
Successfully installed ytm

Getting Started

Create an API instance

>>> import ytm
>>>
>>> api = ytm.YouTubeMusic()
>>> api
<YouTubeMusic()>
>>>

View available methods

>>> from pprint import pprint
>>>
>>> pprint(list(api._methods))
['album',
 'artist',
 'artist_albums',
 'artist_singles',
 'guide',
 'home',
 'hotlist',
 'playlist',
 'queue',
 'search',
 'search_albums',
 'search_artists',
 'search_playlists',
 'search_songs',
 'search_suggestions',
 'search_videos',
 'song',
 'watch',
 'watch_radio',
 'watch_shuffle']
>>>

Methods

API methods available to retrieve data from YouTube Music:

Method - Album

Retrieve information about an album.

View Example

>>> album = api.album('MPREb_ctJ5HEJw8pg') # Band Of Horses - Everything All The Time
>>>
>>> list(album)
['name', 'id', 'total_tracks', 'radio', 'shuffle', 'explicit', 'duration', 'date', 'type', 'thumbnail', 'description', 'artists', 'tracks', 'variants']
>>>
>>> album['name']
'Everything All The Time'
>>> album['total_tracks']
10
>>> album['explicit']
False
>>> album['duration']
2169367
>>> album['date']
{'year': 2006, 'month': 3, 'day': 21}

Method - Artist

Retrieve information about an artist.

View Example

>>> artist = api.artist('UC8Yu1_yfN5qPh601Y4btsYw') # Arctic Monkeys
>>>
>>> list(artist)
['name', 'id', 'subscribers', 'views', 'description', 'albums', 'singles', 'videos', 'songs', 'playlists', 'similar_artists']
>>>
>>> artist['name']
'Arctic Monkeys'
>>> artist['subscribers']
'4.34M'
>>> artist['views']
2082236489
>>> artist['description']
'For tour dates, visit the website www.arcticmonkeys.com'
>>>

Method - Artist Albums

Retrieve information about an artist's albums.

View Example

>>> artist = api.artist('UC8Yu1_yfN5qPh601Y4btsYw') # Arctic Monkeys
>>>
>>> artist_id = artist['id']
>>> params = artist['albums']['params']
>>>
>>> albums = api.artist_albums(artist_id, params)
>>>
>>> for album in albums:
	print(album['name'])

Tranquility Base Hotel & Casino
AM
Suck It and See
My Propeller
Cornerstone
Humbug
Teddy Picker
Fluorescent Adolescent
Favourite Worst Nightmare
Brianstorm
Who The Fuck Are Arctic Monkeys?
Whatever People Say I Am, That's What I Am Not
>>>

Method - Artist Singles

Retrieve information about an artist's singles.

View Example

>>> artist = api.artist('UC8Yu1_yfN5qPh601Y4btsYw') # Arctic Monkeys
>>>
>>> artist_id = artist['id']
>>> params = artist['singles']['params']
>>>
>>> singles = api.artist_singles(artist_id, params)
>>>
>>> for single in singles:
	print(single['name'])

Tranquility Base Hotel & Casino
Why'd You Only Call Me When You're High?
Do I Wanna Know?
One For The Road
R U Mine? / Electricity
Black Treacle
Suck It And See
The Hellcat Spangled Shalalala
Don't Sit Down 'Cause I've Moved Your Chair
Crying Lightning
Da Frame 2R / Matador
Leave Before The Lights Come On
When The Sun Goes Down
I Bet You Look Good On The Dancefloor
>>>

Method - Guide

Retrieve information about available tabs.

View Example

>>> guide = api.guide()
>>>
>>> guide
{'Home': 'FEmusic_home', 'Hotlist': 'FEmusic_trending', 'Library': 'FEmusic_liked'}
>>>

Method - Home

Retrieve information about shelves displayed on the home page.

View Example

>>> home = api.home()
>>>
>>> list(home)
['continuation', 'shelves']
>>>
>>> for shelf in home['shelves']:
	print(shelf['name'])

Top charts
Relaxing to Country
>>>
>>> # Continue Data
>>> home2 = api.home(home['continuation'])
>>>
>>> for shelf in home2['shelves']:
	print(shelf['name'])

Office radio
Today's hits
Cool vibes
>>>

Method - Hotlist

Retrieve information about songs in the hotlist.

View Example

>>> hotlist = api.hotlist()
>>>
>>> for song in hotlist:
	print(' & '.join(song['artist']['names']), '-', song['name'])

Ariana Grande & Justin Bieber - Stuck with U
Migos - Racks 2 Skinny
ManBetterKnow - Nang
Dua Lipa - Break My Heart
Little Mix - Break Up Song (Acoustic Version)
Grm Daily - S1mba - Rover (Remix) (ft. Poundz, ZieZie & Ivorian Doll) [Music Video] | GRM Daily
Lil Durk - Doin Too Much
Black Pepper - Black Pepper - Dublue
Hayley Williams - Dead Horse
slowthai - slowthai - ENEMY
GRM Daily - Offica - Face Reveal [Music Video] | GRM Daily
Example - Example - 'Erin' (Official Video) (OUT NOW)
Mumford & Sons - Forever
Headie One - HEADIE ONE - ROSE GOLD
Jaykae - Jaykae - Novocaine [feat. Remtrex] (Official Video)
NAV - No Debate
The 1975 - Me & You Together Song
SBK - SBK - Numbers (Official Video)
Sean Paul - Back It up Deh
Baauer - AETHER
>>>
>>>

Method - Playlist

Retrieve information about a playlist.

View Example

>>> playlist = api.playlist('RDCLAK5uy_lXWhlJsihey6xq1b50d7Uv93NLqle8TSc')
>>>
>>> list(playlist)
['name', 'type', 'year', 'thumbnail', 'duration', 'id', 'total_tracks', 'artist', 'radio', 'shuffle', 'tracks', 'continuation']
>>>
>>> playlist['name']
'Take It Easy Indie'
>>> playlist['year']
2020
>>> playlist['duration']
'6+ hours'
>>> playlist['total_tracks']
163
>>>
>>> for track in playlist['tracks'][:5]: # First 5 Tracks
	print(track['artist']['name'], '-', track['name'])


Lord Huron - The Night We Met (feat. Phoebe Bridgers)
The Lumineers - Cleopatra
The xx - I Dare You
Hozier - Work Song
girl in red - we fell in love in october
>>>
>>> # Continue Data
>>> playlist2 = api.playlist(continuation = playlist['continuation'])
>>>
>>> for track in playlist2['tracks'][:5]: # First 5 Tracks
	print(track['artist']['name'], '-', track['name'])


Maddie Jay - Mood Swings
Cloud Control - Dojo Rising
Broken Bells - The Angel and the Fool
George Glew - Bittersweet
Cold War Kids - First
>>>

Method - Queue

Retrieve information about queued songs.

View Example

>>> queue = api.queue('Gz3-4UuMWjQ', 'Ye8Er8MtiLk')
>>>
>>> for song in queue:
	print(song['artist']['name'], '-', song['name'])

Amber Run - Amen
Amber Run - Kites
>>>
>>> queue2 = api.queue(playlist_id = 'RDCLAK5uy_k5DxhF_vXgbHHoaQ_d2hRBlY11Qgr3xpY')
>>>
>>> for song in queue2[:5]: # First 5 Songs
	print(song['artist']['name'], '-', song['name'])

Justin Bieber & N- Sorry
Mark Ronson - Uptown Funk (feat. Bruno Mars)
Calvin Harris - This Is What You Came For (feat. Rihanna)
Fifth Harmony - Work from Home (feat. Ty Dolla $ign)
Katy Perry - Roar
>>>

Method - Search

Retrieve information about a specific search.

View Example

>>> results = api.search('alt-j')
>>>
>>> list(results)
['albums', 'playlists', 'videos', 'artists', 'songs', 'top_results']
>>>
>>> results['top_results']
'artists'
>>>
>>> results['artists'][0]['name']
'alt-J'
>>>
>>> results['albums'][0]['name']
'An Awesome Wave'
>>>
>>> results[results['top_results']][0]['name']
'alt-J'
>>>

Method - Search Albums

Retrieve information about albums related to a specific search query.

View Example

>>> albums = api.search_albums('nevermind')
>>>
>>> for album in albums['items'][:5]: # First 5 Albums
	print(album['artist']['name'], '-', album['name'])

Nirvana - Nevermind
Alexander Jean - Nevermind
Sex Pistols - Never Mind The Bollocks, Here's The Sex Pistols (40th Anniversary Deluxe Edition)
Poyo Spirit - Nevermind
Distruction Boyz, Zhao - Nevermind (Radio Edit)
>>>
>>> # Continue Data
>>> albums2 = api.search_albums(continuation = albums['continuation'])
>>>
>>> for album in albums2['items'][:5]: # First 5 Albums
	print(album['artist']['name'], '-', album['name'])

Soriya - Nevermind
Wisp X - Nevermind
P_frmdatribe - Nevermind
Renel - Nevermind
Jacob Lee - Nevermind
>>>

Method - Search Artists

Retrieve information about artists related to a specific search query.

View Example

>>> artists = api.search_artists('john')
>>>
>>> for artist in artists['items'][:5]: # First 5 Artists
	print(artist['name'])

John Legend
John Mayer
John Newman
Elton John
John Lennon
>>>
>>> # Continue Data
>>> artists2 = api.search_artists(continuation = artists['continuation'])
>>>
>>> for artist in artists2['items'][:5]: # First 5 Artists
	print(artist['name'])

John Mellencamp
John Carpenter
John Williams
John Coltrane
John Barry
>>>

Method - Search Playlists

Retrieve information about playlists related to a specific search query.

View Example

>>> playlists = api.search_playlists('indie')
>>>
>>> for playlist in playlists['items'][:5]: # First 5 Playlists
	print(playlist['name'])

Coffee Shop Indie
Upbeat Indie Pop
Indie Folk Favorites
Indie Rock Chasers
Take It Easy Indie
>>>
>>> # Continue Data
>>> playlists2 = api.search_playlists(continuation = playlists['continuation'])
>>>
>>> for playlist in playlists2['items'][:5]: # First 5 Playlists
	print(playlist['name'])

A Decade of Easy Indie
Indie Disco Overload
Sunshine Indie
Pop & Indie Easy Listening
00s Indie Guitar Anthems
>>>

Method - Search Songs

Retrieve information about songs related to a specific search query.

View Example

>>> songs = api.search_songs('cry')
>>>
>>> for song in songs['items'][:5]: # First 5 Songs
	print(song['artists'][0]['name'], '-', song['name'])

Rihanna - Cry
KAZKA - CRY (English Version)
James Blunt - Cry
Carly Rae Jepsen - Cry
System F - Cry (Original Extended)
>>>
>>> # Continue Data
>>> songs2 = api.search_songs(continuation = songs['continuation'])
>>>
>>> for song in songs2['items'][:5]: # First 5 Songs
	print(song['artists'][0]['name'], '-', song['name'])

Marilyn Manson - Cry Little Sister
Jorja Smith - Don't Watch Me Cry
Oasis - Stop Crying Your Heart Out
Volbeat - I'm So Lonesome I Could Cry
Coldplay - Cry Cry Cry
>>>

Method - Search Videos

Retrieve information about videos related to a specific search query.

View Example

>>> videos = api.search_videos('time')
>>>
>>> for video in videos['items'][:5]: # First 5 Videos
	print(video['artist']['name'], '-', video['name'])

Lizzy Capri - Lizzy Capri - TIME (Official Lyric Video)
NF - Time
Pink Floyd Remasted Songs - Pink Floyd - Time (2011 Remastered)
Chase & Status - Time
Lil Baby - Time
>>>
>>> # Continue Data
>>> videos2 = api.search_videos(continuation = videos['continuation'])
>>>
>>> for video in videos2['items'][:5]: # First 5 Videos
	print(video['artist']['name'], '-', video['name'])

Anjunadeep - Simon Doty feat. Forrest - This Time
Alesso - TIME
Imagine Dragons - It's Time
Culture Club - Time (Clock of the Heart)
Freddie Mercury - Time Waits For No One
>>>

Method - Search Suggestions

Retrieve a list of search suggestions.

View Example

>>> suggestions = api.search_suggestions('foo fight')
>>>
>>> from pprint import pprint
>>>
>>> pprint(suggestions)
['foo fighters',
 'foo fighters everlong',
 'foo fighters times like these',
 'foo fighters learn to fly',
 'foo fighters best of you',
 'foo fighters live',
 'foo fighters pretender']
>>>

Method - Song

Retrieve information about a song/video.

View Example

>>> song = api.song('pPt_FZ9m2bM')
>>>
>>> list(song)
['rating', 'duration', 'description', 'thumbnail', 'name', 'id', 'views', 'dislikes', 'likes', 'explicit', 'recommended', 'date', 'artist']
>>>
>>> song['name']
'The Key to Life on Earth'
>>> song['artist']['name']
'Declan McKenna'
>>> song['views']
53130
>>> song['rating']
4.9008608
>>> song['duration']
247
>>> song['explicit']
False
>>> song['date']
{'year': 2020, 'month': 4, 'day': 14}
>>>
>>> for track in song['recommended'][:5]: # First 5 Tracks
	print(track['artist']['name'], '-', track['name'])

Declan McKenna - British Bombs
None - Mix - The Key to Life on Earth
Declan McKenna - Beautiful Faces
Declan McKenna - Declan McKenna - The Key to Life on Earth (Official Video)
Will Joseph Cook - Will Joseph Cook - Girls Like Me
>>>

Method - Watch

Retrieve information about a song/playlist being watched.

View Example

>>> watch = api.watch('dIwwjy4slI8', 'RDCLAK5uy_mgonaF5RiN90kqT-edkFB53N81dZ9XHp8')
>>>
>>> list(watch)
['id', 'name', 'continuation', 'total', 'tracks', 'radio', 'current']
>>>
>>> watch['name']
'Celestial Instrumentals'
>>> watch['total']
52
>>> watch['radio']
False
>>>
>>> for track in watch['tracks'][:5]: # First 5 tracks
	print(track['name'])

Says
The Light
Sun Drugs
Dark Lights
Together Alone
>>>
>>> # Continue data
>>> watch2 = api.watch(continuation = watch['continuation'])
>>>
>>> for track in watch2['tracks'][:5]: # First 5 tracks
	print(track['name'])

Goodnight
Indoor Swimming At The Space Station
Hoppípolla
Sleeping on the Roof
Zero Gravity

Method - Watch Radio

Retrieve information about a song/playlist being watched in radio mode.

View Example

>>> song_radio = api.watch_radio(song_id = '8A9_1hGmtj0')
>>>
>>> list(song_radio)
['id', 'name', 'continuation', 'total', 'tracks', 'radio', 'current']
>>>
>>> song_radio['id']
'RDAMVM8A9_1hGmtj0'
>>>
>>> for track in song_radio['tracks'][:5]: # First 5 Tracks
	print(track['name'])

Travel Is Dangerous
A Gallant Gentleman
Motion Picture Soundtrack
Don't Stay Here
Everything In Its Right Place
>>>
>>> playlist_radio = api.watch_radio(playlist_id = 'RDCLAK5uy_kNj0whsN9sFy3dqiTCfu34HoOdeZIjfyw')
>>>
>>> list(playlist_radio)
['id', 'name', 'continuation', 'total', 'tracks', 'radio', 'current']
>>>
>>> playlist_radio['id']
'RDAMPLRDCLAK5uy_kNj0whsN9sFy3dqiTCfu34HoOdeZIjfyw'
>>> playlist_radio['name']
'Ambient Post Rock'
>>>
>>> for track in playlist_radio['tracks'][:5]: # First 5 Tracks
	print(track['name'])

Only The Winds
The Winter
The Kindness In Letting Go
Aldgate Patterns
I'm Not
>>>

Method - Watch Shuffle

Retrieve information about a playlist being watched in shuffle mode.

View Example

>>> watch = api.watch_shuffle('RDCLAK5uy_l6Wg_lE2_Wx7GdOE21bKJvYPIif8n1fAQ')
>>>
>>> list(watch)
['id', 'name', 'continuation', 'total', 'tracks', 'radio', 'current']
>>>
>>> watch['name']
'Peaceful Indie Dreams'
>>>
>>> for track in watch['tracks'][:5]: # First 5 Tracks
	print(track['name'])

Make It Holy
Bible Belt (Acoustic)
Take Care
Atlas Hands
Sweetheart, What Have You Done to Us
>>>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].