pytuber

- pytuber is a cli tool to manage your music playlists on youtube.
Generate playlists from Last.fm or
Import from file formats: XSPF, JSPF, M3U
Create with a simple copy paste in a text editor
Search and match tracks to Youtube videos
Sync pytuber playlists (fetch/push)
Update youtube playlist items (add/remove)
Keep track of youtube api quota usage
Check Documentation | Changelog
Install & Setup
$ pip install pytuber
$ pytuber setup autocomplete # Enable autocomplete
Read how to setup youtube authentication
Start creating youtube playlists ✨✨
Youtube API Quota
Youtube api has a daily api quota limit which resets at midnight Pacific Time (PT).
pytuber includes a quota calculator
$ pytuber quota
Additionally to the api quota limit Youtube limits the amount of how many playlists you can create per day to only 10.
- In case you reach that number, you can push a new playlist manually.
Create a playlist with pytuber add command
View the playlist by using this command pytuber show xxxx –mime
This mime string is base64 signature used by pytuber internally to link local to youtube playlists
Add a youtube playlists manually from the web site and add the mime signature at the bottom of the playlist description
Fetch the new playlist info pytuber fetch youtube –playlists
Afterwards you will be aple to push tracks like normally.
How to Use
Reference
Overview
This information was generated by running pytuber --help
from the
command line.
Usage: pytuber [OPTIONS] COMMAND [ARGS]...
Create and upload music playlists to youtube.
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
add Add playlist.
clean Cleanup orphan tracks and empty playlists.
fetch Retrieve playlist or track info.
list List playlists.
push Update playlists and tracks.
quota Show current youtube calculated quota usage.
remove Delete one or more playlists by id.
setup Configure api keys and credentials.
show Show a playlist track list.
setup
This information was generated by running pytuber setup --help
from the command line.
Usage: pytuber setup [OPTIONS] COMMAND [ARGS]...
Configure api keys and credentials.
Options:
--help Show this message and exit.
Commands:
autocomplete Enable the command auto completion.
lastfm Configure your last.fm api account.
youtube Configure your youtube api credentials.
add editor
This information was generated by running pytuber add editor --help
from the command line.
Usage: pytuber add editor [OPTIONS]
Create playlist in a text editor.
Options:
--title TEXT title
--help Show this message and exit.
Notes
Add one line per track, make sure it doesn’t start with a number sign #
Separate the track artist and title with a single dash -
add file
This information was generated by running pytuber add file --help
from the command line.
Usage: pytuber add file [OPTIONS] FILE
Import a playlist from a text file.
Options:
--format [txt|m3u|xspf|jspf]
--title TEXT title
--help Show this message and exit.
Format: txt
Add one line per track, make sure it doesn’t start with a number sign #
Separate the track artist and title with a single dash -
Queen - Bohemian rhapsody
Queen - I want to break free
Format: m3u
The parser looks for #EXTINF directives with track information of the extended m3u.
#EXTINF:123, Queen - Bohemian Rhapsody
#EXTINF:123,Queen - I want to break free
Format: xspf
XML Shareable Playlist supported track tag structure
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<creator>Queen</creator>
<title>Bohemian Rhapsody</title>
</track>
<track>
<creator>Queen</creator>
<title>I want to break free</title>
</track>
</trackList>
</playlist>
Format: jspf
JSON Shareable Playlist supported track tag structure
{
"playlist": {
"track": [
{
"title": "Bohemian Rhapsody",
"creator": "Queen"
},
{
"title": "I want to break free",
"creator": "Queen"
}
]
}
}
add lastfm
This information was generated by running pytuber add lastfm --help
from the command line.
Usage: pytuber add lastfm [OPTIONS] COMMAND [ARGS]...
Create playlists from Last.fm api.
Options:
--help Show this message and exit.
Commands:
artist-playlist Add a top tracks playlist by artist.
chart-playlist Add a top tracks playlist.
country-playlist Add a top tracks playlist by country.
tag-playlist Add a top tracks playlist by tag.
user-playlist Add a user type playlist.
fetch youtube
This information was generated by running pytuber fetch youtube --help
from the command line.
Usage: pytuber fetch youtube [OPTIONS]
Fetch youtube online playlist and tracks data.
Options:
--all Perform all tasks
--playlists Create new playlists
--tracks Update playlist items
--help Show this message and exit.
fetch lastfm
This information was generated by running pytuber fetch lastfm --help
from the command line.
Usage: pytuber fetch lastfm [OPTIONS]
Fetch tracks and tags information from last.fm.
Options:
--tracks Update the playlist tracks
--tags Show the most popular tags
--help Show this message and exit.
push youtube
This information was generated by running pytuber push youtube --help
from the command line.
Usage: pytuber push youtube [OPTIONS]
Update youtube playlists and tracks.
Options:
--all Perform all tasks
--playlists Create new playlists
--tracks Update playlist items
--help Show this message and exit.
list
This information was generated by running pytuber list --help
from the
command line.
Usage: pytuber list [OPTIONS]
List playlists.
Options:
--provider PROVIDER
--help Show this message and exit.
ID Title Provider Youtube Tracks
------- --------------- ---------- --------- --------
34a94a5 My loved tracks last.fm ✔ 116
396b617 Japan Top10 last.fm ✔ 10
2e58dd7 ff user - 1
357ec36 foo user - 62
show
This information was generated by running pytuber show --help
from the command line.
Usage: pytuber show [OPTIONS] ID
Show a playlist track list.
Options:
--mime How to push the playlist manually
--help Show this message and exit.
ID: 34a94a5
Provider: last.fm
Title: My loved tracks
Type: user_loved_tracks
Arguments: username: Zaratoustre, limit: 200
Synced: -
Uploaded: -
Youtube: https://www.youtube.com/playlist?list=PLpxCdqvY6hBHW0FUzUbKm4X89U6LSrXID
Tracks:
No Artist Track Name Youtube
---- ----------------------------------------------- ------------------------------------------------------------ ---------
0 Nathaniel Rateliff & The Night Sweats I Need Never Get Old (Official Music Video) ✔
1 Lordi Hard Rock Hallelujah ✔
2 Placebo The Bitter End ✔
3 KALEO Way Down We Go (Official Video) ✔
4 Βασίλης Παπακωνσταντίνου Οι ψυχές και οι αγάπες ✔
5 Iron Maiden The Trooper ✔
6 Kansas Carry On Wayward Son (Audio) ✔
7 Beatles Let It Be [1970] ✔
8 Chris Stapleton Tennessee Whiskey (Audio) ✔
9 Jefferson Airplane Somebody to love ✔
10 Dream On Aerosmith ✔
remove
This information was generated by running pytuber remove --help
from the command line.
Usage: pytuber remove [OPTIONS] IDS...
Delete one or more playlists by id.
Options:
--help Show this message and exit.
clean
This information was generated by running pytuber clean --help
from
the command line.
Usage: pytuber clean [OPTIONS]
Cleanup orphan tracks and empty playlists.
Options:
--help Show this message and exit.
quota
This information was generated by running pytuber quota --help
from the command line.
Usage: pytuber quota [OPTIONS]
Show current youtube calculated quota usage.
Options:
--help Show this message and exit.
Provider: youtube
Limit: 1000000
Usage: 6203
Next reset: 1:38:26
Credentials
Youtube:
Enable APIs for your project
Any application that calls Google APIs needs to enable those APIs in the API Console. To enable the appropriate APIs for your project:
- Open the Library page
in the API Console.
- Select the project associated with your application. Create a project if you
do not have one already.
- Use the Library page to find each API that your application will use.
Click on each API and enable it for your project.
Create authorization credentials
Any application that uses OAuth 2.0 to access Google APIs must have authorization credentials that identify the application to Google’s OAuth 2.0 server. The following steps explain how to create credentials for your project. Your applications can then use the credentials to access APIs that you have enabled for that project.
- Open the Credentials page.
in the API Console.
Click Create credentials > OAuth client ID.
Complete the form. Set the application type to Desktop APP.

Download your client_secret.json
and assuming the file is on your user
downloads directory run and follow the on screen instructions
$ pytuber setup youtube ~/Downloads/client_secret_foobar.json
Last.fm
Apply for a last.fm api key write down your key key and run from terminal
$ pytuber setup lastfm --api-key abcdefghijklmnop
Changelog
22.5 (May 8, 2022)
Fixed google auth flow #32.
20.1 (Jan 13, 2019)
Create application directory before use #25.
19.2 (Feb 17, 2019)
Add clean command to remove orphan tracks and playlists.
Import playlists from files: m3u, xspf, jspf text.
Create playlist with a text editor.
Update demo.gif.
Add youtube api quota calculator.
Add version option in cli and storage.
19.1 (Jan 27, 2019)
First Release