After much deliberation I have decided to archive this project and will no longer be actively maintaining it.
The main reason is time, which, I ever increasingly have less of - #theburdenofresponsiblityincreaseseswithage
It was a great little project to work on and I really appreciate everyone's interest and support. Thank you!
The spark to my decision was made when google decided to block sign in using an embedded browser (specifically WebView2) - Needed to retrieve your YTM authentication cookie... An alternative means of Google Sign in will be required or a new type of Browser control entirely may be needed.
Workaround
A work around to this is to get the cookie values yourself and enter them directly into the database in: C:\users\[username]\AppData\local\YTMusicUploader.
You can follow this guide to get your authentication cookie: https://ytmusicapi.readthedocs.io/en/latest/setup.html And you can edit the database using SQLite Browser: https://sqlitebrowser.org/
The project itself was born out of mere curiosity; I wanted something that would just upload my music automatically and later decided to share it. I was hoping others would be interested in forking it, and then developing on and extending it however there has been no takers.
If I discover someone has indeed made a fork and continued development or I come accross alternative software that basically does the same thing I will note it here.
Download Version 1.7.9 Installer
This is a .Net application written in C# that uploads your personal music library to YouTube. It has a minimalistic UI for basic settings such as:
- Choosing library folders.
- Option to start the application with Windows (will start hidden, accessible via the System Tray):
- Option to throttle the upload speed so it doesn't use all your bandwidth.
- Connect and authenticate with YouTube Music.
- Upload music to YouTube Music.
- Automatic creation of YouTube Music playlists from local .m3u, .m3u8, .wpl, .pls, ,zpl playlist files.
- Delete uploaded music from YouTube Music.
- Delete playlists from YouTube Music.
- Checks YouTube Music to see if the music file has already been uploaded. It will perform this check once per month on all watched library files and is quite dependant on music file meta data being present and accurate.
- Add and remove library watch folders.
- File system watcher to monitor for changes in watched folders.
- Throttle upload bandwidth.
- Start with Windows, minimized to the system tray area.
- Reads music file tags, including cover art thumbnail.
- If not all data is found in the tags of the music file, it will use the MusicBrainz API to look it up (including the cover art thumbail) (Fetching the details is purely for UI purposes. It has now impact of uploading to YouTube and doesn't write the results to the music file).
- Show an upload log dialogue.
- Show an issues log dialogue.
- This application does not send any telemetry data of any kind to its source if the 'Send Diagnostic Data' checkbox is not set'
- Valid music file formats are the same as YouTube Music: .flac, .m4a, .mp3, .oga, .wma
- Valid music playlist file formats are: .m3u, .m3u8, .wpl, .pls, .zpl
- Maximum number of files you can upload to YouTube Music is 100, 000
- Maximum number of playlist items YouTube Music will allow is 5,000
- Maximum file size YouTube Music will allow is 300 MB
- Although you have the ability to delete from YouTube Music within the app, this application is strictly a one way synchronisation app.
I used to have Google Play music and liked uploading my own content via its automatic library uploader application; I have a large library of music and you could stream your own uploaded songs from Google Play music without paying for a subscription...
Google Play music is on its way out in December and its replacement, YouTube Music doesn't currently have a library watcher application. You can only drag and drop manually into the browser for a limited number of songs... So, I decided to create one.
I got a subscription in the end, so some might consider this pointless in the world of streaming anything you want these days... So I suppose the only real benefit is the ability to:
- Upload songs that aren't on YouTube music.
- Backup your songs (you can't download them again from YouTube music, but you can use Google Takeout to get them).
Since, as far as I'm aware, YouTube Music doesn't have an official API to utilise. Therefore this application mimics the HTTP request and responses from the YouTube music site uses (F12 in Firefox is your friend).
YouTube Music uses an authentication cookie, and an authentication header consisting of a SAPISID hash from the cookie itself. Therefore, this application needs a browser so you can sign into YouTube in order to retrieve said cookie:
- .Net 4.7.2
- WinForms
- SQLite
- Microsoft Visual Studio 2019
- Microsoft Visual Studio Installer Project
- Brotli.Net (Decompress Google HTTP resonse body)
- xxHash - Fast file hash generator
- Dapper
- Metro Framework (UI Styling)
- Ookii Dialogues
- MusicBrainz API - Zastai
- MusicBrainz CoverArt - Zastai
- MusicBrainz API implementation
- TagLibSharp - Read music file tags
WebView2 is a new web control plugin for WPF and WinForms that uses Microsoft Edge. At the time of writing it's still in its infancy and has been very prone to error. The reason it's used here is because it seems to be the only web control that's able to view YouTube Music.
Using the native WPF or WinForms web control or GeckoFX you just get a web page asking to update the browser. Using CefSharp you get a page telling you the browser isn't secure enough.
I believe I've managed to get it stable, technically you need the latest Edge or maybe even still the version of Microsoft Edge from the Canary Channel:). The YT Music Uploader Application self-contains the files needed for this dependency for convenience so you shouldn't need to install anything else other than this app.
Despite some of the issues found using this control, it is actually a very good browser control. It's fast, uses little system resources and renders everything very nicely.
GOTCHAS
One thing to bear in mind, is that it requires a writable location for cache files (and other random files), and you need to set this up before navigating to any URL:
private async void InitializeBrowser()
{
var env = await CoreWebView2Environment.CreateAsync(Global.EdgeFolder, Global.AppDataLocation);
await browser.EnsureCoreWebView2Async(env);
browser.Source = new Uri("https://music.youtube.com/", UriKind.Absolute);
}
Thank you DjSt3rios for working that out: MicrosoftEdge/WebView2Feedback#297
Also, you need to wait for the ready state of the CoreWebView2WebResource context before trying to read any properties from it (like the request headers). This is easily achievable with events:
private void Browser_CoreWebView2Ready(object sender, EventArgs e)
{
browser.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);
browser.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested;
}
- sigma67 - Who created a Python YouTube Music API that I could reference. sigma67: Github.
- wilsone8 - Who created a very fast Windows directory enumerator.
- Dave Thomas - Who worked out how to get the SAPISID hash from the the YouTube Music authentication cookie on a post on StackOverflow.
- 0xDEADBEEF - Who made a simple class to bandwidth throttle a byte stream on a post on StackOverflow.
- avatar29A - For the MusicBrainz .Net API implementation.
- DjSt3rios - For some WebView2 insight.
- tmk907 - Who created a very good, easy to use, multi-type playlist reader. tmk907: Github.
- EdgeGuy13
- Mew
- CowtownChina
- Someone
- Someone
- Stephen M
- Brian A
- @NourishedAIO
- nishantranacrm
- Oak