GithubHelp home page GithubHelp logo

apastel / ytmusic-deleter Goto Github PK

View Code? Open in Web Editor NEW
85.0 3.0 7.0 19.43 MB

Easily delete your YouTube Music library.

License: GNU General Public License v3.0

Python 95.55% Shell 4.45%
youtubemusic youtube python click music delete library

ytmusic-deleter's Introduction

ytmusic-deleter: Delete your YouTube Music library

GitHub Downloads (all assets, all releases) PyPI - Downloads GitHub Release Release test Release test Pytest Codecov Discord

YTMusic Deleter is an installable program for performing batch delete operations on your YouTube Music library, since currently there is no built-in option to do this. This tool is faster than browser-based / Javscript-based tools because it uses the YouTube Music API to make rapid requests against your library instead of doing the deletion manually in your browser.

If this project helped you and you want to thank me, you can get me a beer!

Get help on Discord!

Features

  • Remove all songs and podcasts from your Library
  • Delete all of your Uploads
    • Option to automatically add the corresponding album to your library from within YT Music
  • Delete all of your playlists
  • Reset all of your "Liked" ratings
  • Delete your play history
  • Sort your playlists
  • Remove duplicates from your playlists

YTMusic Deleter screenshot

Installation

Easy Install (Windows or Debian Linux Only)

Windows or Debian Linux users (including Ubuntu) can download an .exe (or .deb, for Linux) to install the YTMusic Deleter GUI (Graphical User Interface).

Find the .exe (or .deb) file in the Releases area. Just click the latest release and look at the Assets section.

Please note you may get a browser warning when downloading the file, and a Windows warning for installing files from an unknown publisher. Click the "More Info" button, then the "Run Anyway" button to finish installing. This warning appears whenever you install something from an unsigned publisher.

(Advanced) Command-line interface for non-Windows users

See CLI README

Setup

Once installed and running, simply click the "Log In" button to authenticate to your YouTube Music account. You will see your Google account name and profile photo to ensure you are logged into the correct account.

This login process uses the Google API flow for TV devices and is handled by the ytmusicapi, which handles all of the API interaction in this app.

Video Tutorial on using YT Music Deleter

This video shows an older version of the UI. The authentication process has been simplified. New video coming soon!

Troubleshooting

Various exceptions may occur while running ytmusic-deleter because there is a wide swath of possible metadata on your library, and the YouTube Music backend is changing rapidly. Most errors deleting albums have been accounted for and you may just have to delete a couple albums manually that got left behind. If there are any errors that halt the entire program in the middle of deletion, please create an Issue and post the full error.

ytmusic-deleter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ytmusic-deleter's Issues

JSON decode error deleting uploads

I get the following error when running ytmusic-deleter delete-uploads on macOS with Python 3.9:

[2023-03-11 14:31:34] Looking for ./ytdelete/headers_auth.json"
[2023-03-11 14:31:34] Found ./ytdelete/headers_auth.json"
[2023-03-11 14:31:34] Retrieving all uploaded albums...
Traceback (most recent call last):
  File "./ytdelete/.venv/bin/ytmusic-deleter", line 8, in <module>
    sys.exit(cli())
  File "./ytdelete/.venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "./ytdelete/.venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "./ytdelete/.venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "./ytdelete/.venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "./ytdelete/.venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "./ytdelete/.venv/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "./ytdelete/.venv/lib/python3.9/site-packages/ytmusic_deleter/cli.py", line 82, in delete_uploads
    (albums_deleted, albums_total) = delete_uploaded_albums(ctx, add_to_library)
  File "./ytdelete/.venv/lib/python3.9/site-packages/ytmusic_deleter/cli.py", line 96, in delete_uploaded_albums
    uploaded_albums = youtube_auth.get_library_upload_albums(sys.maxsize)
  File "./ytdelete/.venv/lib/python3.9/site-packages/ytmusicapi/mixins/uploads.py", line 75, in get_library_upload_albums
    response = self._send_request(endpoint, body)
  File "./ytdelete/.venv/lib/python3.9/site-packages/ytmusicapi/ytmusic.py", line 139, in _send_request
    response_text = json.loads(response.text)
  File "$HOME/.pyenv/versions/3.9.13/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "$HOME/.pyenv/versions/3.9.13/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "$HOME/.pyenv/versions/3.9.13/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is the ytmusicapi package out of date?

IndexError: List Index out of Range

Hi All,
I am attempting to switch back to Android from iOS. As a result, I am trying to delete and re-sync my YouTube Music library (there are tons of metadata issues, duplicates and etc). When I attempt to run the script, this is the error I get (I have changed my username of course for OpSec Reasons):

Traceback (most recent call last):
File "C:\Users\xxxxxx\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\xxxxxx\anaconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\xxxxxx\anaconda3\Scripts\ytmusic-deleter.exe_main
.py", line 7, in
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\click\core.py", line 1128, in call
return self.main(*args, **kwargs)
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\ytmusic_deleter\cli.py", line 82, in delete_uploads
(albums_deleted, albums_total) = delete_uploaded_albums(ctx, add_to_library)
File "C:\Users\xxxxxx\anaconda3\lib\site-packages\ytmusic_deleter\cli.py", line 109, in delete_uploaded_albums
album["artists"][0]["name"]
IndexError: list index out of range

what am I doing wrong? I will gladly buy a beer to help me fix this.
Thanks

Unable to remove singles

[2021-07-17 15:10:53] Retrieving all library albums...
[2021-07-17 15:10:53] Retrieved 0 albums from your library.
[2021-07-17 15:10:53] Retrieving all singles...
[2021-07-17 15:11:03] Retrieved 1477 singles from your library.
Traceback (most recent call last):
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Kyle Gold\AppData\Local\Programs\Python\Python39\Scripts\ytmusic-deleter.exe_main
.py", line 7, in
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1137, in call
return self.main(*args, **kwargs)
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\ytmusic_deleter\cli.py", line 183, in remove_library
filtered_songs = list({v["album"]["id"]: v for v in library_songs}.values())
File "c:\users\kyle gold\appdata\local\programs\python\python39\lib\site-packages\ytmusic_deleter\cli.py", line 183, in
filtered_songs = list({v["album"]["id"]: v for v in library_songs}.values())
TypeError: 'NoneType' object is not subscriptable

KeyError: 'playlistId' when trying to remove albums or songs

C:\WINDOWS\system32>ytmusic-deleter remove-library
[2021-09-23 12:37:49] Retrieving all library albums...
[2021-09-23 12:37:50] Retrieved 0 albums from your library.
[2021-09-23 12:37:50] Retrieving all singles...
[2021-09-23 12:38:03] Retrieved 1408 singles from your library.
[2021-09-23 12:38:03] Processing album: Unknown Artist - Christmas in Tahoe (Deluxe Edition)
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Program Files\Python39\Scripts\ytmusic-deleter.exe_main
.py", line 7, in
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1137, in call
return self.main(*args, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\ytmusic_deleter\cli.py", line 189, in remove_library
albums_removed += remove_library_albums_by_song(album_unique_songs, progress_bar)
File "C:\Program Files\Python39\lib\site-packages\ytmusic_deleter\cli.py", line 206, in remove_library_albums_by_song
if remove_album(song["album"]["id"]):
File "C:\Program Files\Python39\lib\site-packages\ytmusic_deleter\cli.py", line 222, in remove_album
response = youtube_auth.rate_playlist(album["playlistId"], const.INDIFFERENT)
KeyError: 'playlistId'

Thanks for this awesome tool and any help you can provide.

unlike-all error logged

It looks like the code choked on an unexpected character in a song title that is using a right single quotation mark, instead of the usual apostrophe character. Here's error log:

--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\logging\__init__.py", line 1103, in emit
    stream.write(msg + self.terminator)
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\x92' in position 63: character maps to <undefined>
Call stack:
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\Scripts\ytmusic-deleter.exe\__main__.py", line 7, in <module>
    sys.exit(cli())
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\XXXX\AppData\Local\Programs\Python\Python310\lib\site-packages\ytmusic_deleter\cli.py", line 282, in unlike_all
    logging.info(f"Processing track: {artist} - {title}")
Message: "Processing track: Propagandhi - Fedallah'\x92s Hearse"
Arguments: ()
[2022-04-09 09:16:16] Processing track: Propagandhi - Fedallah's Hearse
[2022-04-09 09:16:16]   Removed track from Likes.

HTTP 400: Bad Request retrieving all uploaded albums

Running "ytmusic-deleter delete-uploads" ends in HTTP 400: Bad Request

Windows 10
ytmusic-deleter, version 1.2.1

PS C:\WINDOWS\system32> ytmusic-deleter delete-uploads [2021-01-23 11:56:40] Retrieving all uploaded albums... Traceback (most recent call last): File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Python39\Scripts\ytmusic-deleter.exe\__main__.py", line 7, in <module> File "c:\python39\lib\site-packages\click\core.py", line 829, in __call__ return self.main(*args, **kwargs) File "c:\python39\lib\site-packages\click\core.py", line 782, in main rv = self.invoke(ctx) File "c:\python39\lib\site-packages\click\core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "c:\python39\lib\site-packages\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "c:\python39\lib\site-packages\click\core.py", line 610, in invoke return callback(*args, **kwargs) File "c:\python39\lib\site-packages\ytmusic_deleter\cli.py", line 46, in delete_uploads (albums_deleted, albums_total) = delete_uploaded_albums(add_to_library) File "c:\python39\lib\site-packages\ytmusic_deleter\cli.py", line 60, in delete_uploaded_albums uploaded_albums = youtube_auth.get_library_upload_albums(sys.maxsize) File "c:\python39\lib\site-packages\ytmusicapi\mixins\uploads.py", line 88, in get_library_upload_albums get_continuations(results, 'gridContinuation', limit - len(albums), request_func, File "c:\python39\lib\site-packages\ytmusicapi\parsers\utils.py", line 107, in get_continuations response = request_func(additionalParams) File "c:\python39\lib\site-packages\ytmusicapi\mixins\uploads.py", line 84, in <lambda> request_func = lambda additionalParams: self._send_request( File "c:\python39\lib\site-packages\ytmusicapi\ytmusic.py", line 116, in _send_request raise Exception(message + error) Exception: Server returned HTTP 400: Bad Request. Request contains an invalid argument. PS C:\WINDOWS\system32> ytmusic-deleter --version ytmusic-deleter, version 1.2.1 PS C:\WINDOWS\system32>

Improve fuzzy matching when using `--add-to-library`

The --add-to-library feature of delete-uploads now has an experimental fuzzy matching implementation that improves the likelihood of finding a matching album in the YTM online catalog when deleting uploads from your library. However it is too eager in its current state with partial matches (e.g. it thinks the album "The Beatles" is a match for "The Beatles Second Album" because the first two words are an exact match). Tweak the algorithm and improve its correct matches against a large dataset, ideally using a repeatable unit test.

Error during "Delete uploads" when a song does not have a duration

It's been observed that using the Delete Uploads function can cause this KeyError to occur. This is stemming from the ytmusicapi library's get_library_upload_songs() function, likely due to A/B testing that Google is currently experimenting with on some user's accounts. I may have to open an issue in that project in order to get it resolved. In the meantime, I may be able to implement a workaround using a retry-loop if the function works on subsequent retries.

Delete Uploads clicked.
Showing confirmation dialog
Executing process: C:\Program Files (x86)\YTMusic_Deleter\_internal/ytmusic-deleter -l C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter -c C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter -p delete-uploads
State changed: Starting
State changed: Running
[2024-05-05 13:26:27] Attempting authentication with: C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter\oauth.json
[2024-05-05 13:26:27] Authenticated with: C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter\oauth.json"
[2024-05-05 13:26:28] Logged in as 'XXXXXXX'
[2024-05-05 13:26:28] Retrieving all uploaded songs...
Traceback (most recent call last):
File "cli.py", line 433, in
File "click\core.py", line 1157, in __call__
File "click\core.py", line 1078, in main
File "click\core.py", line 1688, in invoke
File "click\core.py", line 1434, in invoke
File "click\core.py", line 783, in invoke
File "click\decorators.py", line 33, in new_func
File "cli.py", line 87, in delete_uploads
File "ytmusic_deleter\uploads.py", line 30, in maybe_delete_uploaded_albums
File "ytmusicapi\mixins\uploads.py", line 65, in get_library_upload_songs
File "ytmusicapi\continuations.py", line 19, in get_continuations
File "ytmusicapi\continuations.py", line 69, in get_continuation_contents
File "ytmusicapi\parsers\uploads.py", line 33, in parse_uploaded_items
File "ytmusicapi\parsers\_utils.py", line 46, in get_fixed_column_item
KeyError: 'fixedColumns'
[16872] Failed to execute script 'cli' due to unhandled exception!
State changed: Not running
Process finished.

unhandled exception in sort_playlist

I've tried renaming the playlist to remove spaces and special characters. Will play around with the code to see if I can get a fix. I'm not a Python guy so my PR may need fixing up.

Traceback (most recent call last):
File "ytmusic_deleter\cli.py", line 484, in
File "click\core.py", line 1130, in call
File "click\core.py", line 1055, in main
File "click\core.py", line 1657, in invoke
File "click\core.py", line 1404, in invoke
File "click\core.py", line 760, in invoke
File "click\decorators.py", line 26, in new_func
File "ytmusic_deleter\cli.py", line 428, in sort_playlist
File "ytmusic_deleter\cli.py", line 432, in
TypeError: 'NoneType' object is not subscriptable
[26072] Failed to execute script 'cli' due to unhandled exception!

JSONDecodeError on Windows

Microsoft Windows [Version 10.0.19043.1023]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Phill>ytmusic-deleter
Usage: ytmusic-deleter [OPTIONS] COMMAND [ARGS]...

Perform batch delete operations on your YouTube Music library.

Options:
--version Show the version and exit.
--help Show this message and exit.

Commands:
delete-all Executes delete-uploads, remove-library, unlike-all,...
delete-playlists Delete all playlists
delete-uploads Delete all tracks that you have uploaded to your YT...
remove-library Remove all tracks that you have added to your library...
unlike-all Reset all Thumbs Up ratings back to neutral

C:\Users\Phill>ytmusic-deleter delete-all
[2021-06-05 17:37:15] Retrieving all uploaded albums...
Traceback (most recent call last):
File "c:\users\phill\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\phill\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Phill\AppData\Local\Programs\Python\Python39\Scripts\ytmusic-deleter.exe_main
.py", line 7, in
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1137, in call
return self.main(*args, **kwargs)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\ytmusic_deleter\cli.py", line 282, in delete_all
ctx.invoke(delete_uploads)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\ytmusic_deleter\cli.py", line 46, in delete_uploads
(albums_deleted, albums_total) = delete_uploaded_albums(add_to_library)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\ytmusic_deleter\cli.py", line 60, in delete_uploaded_albums
uploaded_albums = youtube_auth.get_library_upload_albums(sys.maxsize)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\ytmusicapi\mixins\uploads.py", line 74, in get_library_upload_albums
response = self._send_request(endpoint, body)
File "c:\users\phill\appdata\local\programs\python\python39\lib\site-packages\ytmusicapi\ytmusic.py", line 128, in send_request
response_text = json.loads(response.text)
File "c:\users\phill\appdata\local\programs\python\python39\lib\json_init
.py", line 346, in loads
return _default_decoder.decode(s)
File "c:\users\phill\appdata\local\programs\python\python39\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\users\phill\appdata\local\programs\python\python39\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Missing Metadata Error

Seems it's not finding any of my music's metadata. Getting the below error when trying to run ytmusic-deleter delete-uploads -a

Album is missing artist metadata. Skipping match search and will not delete.

Remove podcasts

Remove podcasts that were saved to the library.

This could be its own command, but more likely it should just be included in "Remove Library"

Permission denied on Mac

After installing and adding the install location to my path, I receive

zsh: permission denied: ytmusic_deleter

I ran chmod 777 on the directory where the file is located but to no avail.

FileNotFoundError: ANSI64.dll

"ytmusic-deleter-1.4.0.exe"
NotADirectoryError: [WinError 267] The directory name is invalid
Traceback (most recent call last):
File "PyInstaller\loader\pyimod04_ctypes.py", line 77, in init
File "ctypes_init_.py", line 374, in init
FileNotFoundError: Could not find module 'C:\Users\ADMINI~1\AppData\Local\Temp_MEI1653082\ansicon\ANSI64.dll' (or one of its dependencies). Try using the full path with constructor syntax.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "ytmusic_deleter\cli.py", line 15, in
File "enlighten\manager.py", line 55, in get_manager
File "enlighten_manager.py", line 70, in init
File "enlighten_basemanager.py", line 74, in init
File "blessed\terminal.py", line 170, in init
File "jinxed\win32.py", line 337, in get_term
File "ansicon_init_.py", line 52, in load
File "PyInstaller\loader\pyimod04_ctypes.py", line 79, in init
pyimod04_ctypes.install..PyInstallerImportError: Failed to load dynlib/dll 'C:\Users\ADMINI~1\AppData\Local\Temp\_MEI1653082\ansicon\ANSI64.dll'. Most likely this dynlib/dll was not found when the application was frozen.
[166384] Failed to execute script 'cli' due to unhandled exception!

Delete duplicate songs in a playlist

Had a number of requests for this feature.

The meat of the work will be:

Determining what constitutes a duplicate

Two songs are considered a duplicate if any of the following are true:

  • They are the exact same track (same ID)
  • They have very similar titles, and are by the same artist (e.g. "Battery (Remastered)" vs. "Battery")
    • This gets tricky. What if one is "Battery" and the other is "Battery (Live)"
    • Might have to strip away all parentheses and then compare, rather than using fuzzy matching

What to do when duplicate(s) are found

  • There's no one-size-fits-all answer.
  • Could be multiple modes:
    • --keep-latest Keep the track most recently added to the playlist
    • --keep-oldest Keep the track that was first added to the playlist
    • --prompt
      • This prompts the user to select which track to keep for each finding. CLI uses a numerical selection. App will use a radio button.

Other considerations

  • Keep in mind that there could be more than 1 duplicate for each track.
  • Probably would be a good idea to present a list of all the tracks that will be deleted, and then delete them after user confirms.
    • Could get real fancy with this by allowing them to make modifications. Or just either accept or reject them wholesale.

Not removing YouTube Music songs added to library

First off, thanks for creating this! It works swimmingly for removing your uploaded songs, but unfortunately, it's erroring out when trying to remove YouTube Music songs. Here's the full error note:
Retrieving all library albums...
Traceback (most recent call last):
File "/Users/nick/Library/Python/3.7/bin//ytmusic-deleter", line 10, in
sys.exit(cli())
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/ytmusic_deleter/cli.py", line 137, in remove_library
library_albums = youtube_auth.get_library_albums(sys.maxsize)
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/ytmusicapi/mixins/library.py", line 92, in get_library_albums
albums = parse_albums(results['items'], False)
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/ytmusicapi/parsers/library.py", line 55, in parse_albums
album['trackCount'] = nav(data, SUBTITLE3).split(' ')[0]
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/ytmusicapi/parsers/utils.py", line 75, in nav
raise err
File "/Users/nick/Library/Python/3.7/lib/python/site-packages/ytmusicapi/parsers/utils.py", line 69, in nav
root = root[k]
IndexError: list index out of range

Process immediately finishes without removing anything

After installing the app and granting access to my youtube account i tried to get rid of all my liked music/my whole library.
When i click on "Delete All", or any other button for that matter, the process immediately finishes and nothing gets removed. I attached a screenshot.
Screenshot 2024-03-28 095424
Screenshot 2024-03-28 095649

Last Album/Singles will not delete

I read the little troubleshooting part and don't understand what you mean by "delete the remaining albums manually". I really want these albums down. Help?

Only first 100 tracks are being sorted

Something changed on the YTMusic side and now only the first 100 tracks are being sorted:

[2024-01-23 08:23:57] Processing playlist: Snowboarding
[2024-01-23 08:23:57] 	Playlist: Snowboarding will be shuffled

'Snowboarding' Tracks Shuffled 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 100/100 [00:58<00:00, 1.74 tracks/s]

A possible cause could be that the tracks in a playlist are now being paginated in the API, so you have to retrieve each page of 100 tracks.

KeyError: 'fixedColumns' when using delete-uploads

It's been observed that using the Delete Uploads function can cause this KeyError to occur. This is stemming from the ytmusicapi library's get_library_upload_songs() function, likely due to A/B testing that Google is currently experimenting with on some user's accounts. I may have to open an issue in that project in order to get it resolved. In the meantime, I may be able to implement a workaround using a retry-loop if the function works on subsequent retries.

Delete Uploads clicked.
Showing confirmation dialog
Executing process: C:\Program Files (x86)\YTMusic_Deleter\_internal/ytmusic-deleter -l C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter -c C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter -p delete-uploads
State changed: Starting
State changed: Running
[2024-05-05 13:26:27] Attempting authentication with: C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter\oauth.json
[2024-05-05 13:26:27] Authenticated with: C:\Users\XXXX\AppData\Roaming\YTMusic_Deleter\oauth.json"
[2024-05-05 13:26:28] Logged in as 'XXXXXXX'
[2024-05-05 13:26:28] Retrieving all uploaded songs...
Traceback (most recent call last):
File "cli.py", line 433, in
File "click\core.py", line 1157, in __call__
File "click\core.py", line 1078, in main
File "click\core.py", line 1688, in invoke
File "click\core.py", line 1434, in invoke
File "click\core.py", line 783, in invoke
File "click\decorators.py", line 33, in new_func
File "cli.py", line 87, in delete_uploads
File "ytmusic_deleter\uploads.py", line 30, in maybe_delete_uploaded_albums
File "ytmusicapi\mixins\uploads.py", line 65, in get_library_upload_songs
File "ytmusicapi\continuations.py", line 19, in get_continuations
File "ytmusicapi\continuations.py", line 69, in get_continuation_contents
File "ytmusicapi\parsers\uploads.py", line 33, in parse_uploaded_items
File "ytmusicapi\parsers\_utils.py", line 46, in get_fixed_column_item
KeyError: 'fixedColumns'
[16872] Failed to execute script 'cli' due to unhandled exception!
State changed: Not running
Process finished.

`--add-to-library` or `-a` fails to find matching albums even without missing metadata

When using the -a feature that adds an album to your library when deleting uploads, the part of the code that checks for a match is now unable to find any matches:

2024-03-15 15:31:49] Processing album: The Offspring - Americana
[2024-03-15 15:31:49] Searching for album in online catalog...
[2024-03-15 15:31:49] No match for uploaded album found in online catalog. Will not delete.

This is happening because of changes in Google's API. A data object that used to contain a string ('Americana') now contains a JSON object that looks like { name: 'Americana', id: <some_id> } so the parser fails to find a match.

For some reason *nothing* gets deleted.

UPDATE: This appears to have a been a problem with how I was constructing the auth_headers.json file. I didn't get any permission errors, but I also couldn't actually delete anything. All fixed now, though! :)

I have this installed and it does run.
I'm seeing what appears to be the most recent change (pull master on 15 Sep at 0830EST) of showing progress bar for the operations to delete -- all of the operations to delete; however, it seems to operate on zero items, and I cannot figure out why.
Any tips/tricks for something that I might be missing?

Final few logs of installation to show dep vesrions:

Installing collected packages: ytmusicapi, ytmusic-deleter
  Running setup.py install for ytmusic-deleter ... done
Successfully installed ytmusic-deleter-0.1 ytmusicapi-0.9.2
WARNING: You are using pip version 19.2.2, however version 20.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Sample output:

~\Downloads\ytmusic-deleter [master โ‰ก +0 ~1 -0 !]> ytmusic-deleter remove-library
[2020-09-15 08:28:37] Retrieving all library albums...
[2020-09-15 08:28:38] Retrieving all singles...
[2020-09-15 08:28:38] Removed 0 out of 0 albums from your library.

Albums Processed 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 0/0 [00:00<00:00, 0.00 albums/s]~\Downloads\ytmusic-deleter [master โ‰ก +0 ~1 -0 !]>            

Security

I am new to the github sorry if here is not the place for me to post this:( Can someone explain me how secure is it to share(when i input the .json file) a cookie of mine? Also is there a command to clear artists from library too?

TypeError during remove-library

A user who is not me reported the following error on Reddit when using remove-library:

[2020-11-02 00:23:35] Retrieving all library albums...
[2020-11-02 00:23:35] Retrieved 0 albums from your library.
[2020-11-02 00:23:35] Retrieving all singles...
[2020-11-02 00:25:21] Retrieved 7037 singles from your library.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/ytmusic-deleter", line 8, in <module>
sys.exit(cli())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ytmusic_deleter/cli.py", line 182, in remove_library
filtered_songs = list({v["album"]["id"]: v for v in library_songs}.values())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ytmusic_deleter/cli.py", line 182, in <dictcomp>
filtered_songs = list({v["album"]["id"]: v for v in library_songs}.values())
TypeError: 'NoneType' object is not subscriptable

So far I'm unable to replicate the issue whether my library has songs/singles in it or not.

Did not find request headers from Firefox

Sorry for a dumb question... but when I started ytmusic-deleter, I did not see my Firefox popped up and gave me any header. I have updated my Firefox to the newest version and also tried having it opened. Could you give any directions? I've tried both on MacOS and Ubuntu 20.04.

Thanks!

Error executing the .exe and the script as well

Hi, I get the following errors, albums i deleted manually but have like 10k uploaded singles i want to delete.. If you can fix this I will be very happy.

Showing confirmation dialog
Executing process: C:\Windows\System32\ytmusic-deleter-1.5.4.exe ['-l', 'C:\Users\Admin\AppData\Roaming\YTMusic Deleter', '-c', 'C:\Users\Admin\AppData\Roaming\YTMusic Deleter', '-p', 'delete-uploads']
State changed: Starting
State changed: Running
FileNotFoundError: [WinError 2] Het systeem kan het opgegeven bestand niet vinden
[2023-02-28 19:45:15] Looking for C:\Users\Admin\AppData\Roaming\YTMusic Deleter\headers_auth.json"
[2023-02-28 19:45:15] Found C:\Users\Admin\AppData\Roaming\YTMusic Deleter\headers_auth.json"
[2023-02-28 19:45:15] Retrieving all uploaded albums...
[2023-02-28 19:45:15] Deleted 0 out of 0 uploaded albums.
[2023-02-28 19:45:15] Retrieving all uploaded singles...
Traceback (most recent call last):
File "ytmusic_deleter\cli.py", line 495, in
File "click\core.py", line 1130, in call
File "click\core.py", line 1055, in main
File "click\core.py", line 1657, in invoke
File "click\core.py", line 1404, in invoke
File "click\core.py", line 760, in invoke
File "click\decorators.py", line 26, in new_func
File "ytmusic_deleter\cli.py", line 89, in delete_uploads
File "ytmusic_deleter\cli.py", line 163, in delete_uploaded_singles
KeyError: 'artist'
[33496] Failed to execute script 'cli' due to unhandled exception!
State changed: Not running
Process finished.

--add-to-library option for delete-uploads does not actually add album to library

Using the --add-to-library option (or -a) when running delete-uploads is supposed to search for a matching album in YouTube Music and add that album to your library before deleting it from your uploads. But upon inspecting the library afterwards, the album (nor the songs nor the artist) cannot be found in my library.

I'm not sure if/when this stopped working, or if it used to even work.....I'm pretty sure it did when I first implemented it. But I can't be sure now.

Can't sort playlist if it contains a video

An issue was reported by user "Sam" through a message on my Buy Me a Beer donation page:

The only thing it seemed to struggle with is when there's an object in a playlist that is actualy a video it doesn't allow you to sort the playlist.

Broken list of artists as a result of delete

Hi Alex, let me say thank you in the very first place for a grate job. Good tool, really. However there is one minor issue which doesn't make me feel 100% good and satisfied of using it.

My original intention was to cleanup my library completely, so I used all options to insure I'm fine and everything is gone, but not everything has gone eventually.

  • I go a list of artists with broken links on deleted album's songs

image

If I try to delete the artist I receive

image

and if I try to go to album, of course it does not exists, so I'm getting just a dark screen

image

I opened a support request to Goggle, but for multiple weeks they were talking complete crap, like their engineers were not able to reproduce the issue, despite I didn't ask to reproduce, I asked to fix my account ))

If I go ahead and add The Metallica Blacklist again into my library, I see that each artist has 2 songs, but eventually only one I can see.

image

image

I hope a lot that you know their API and could help fix this case using any force method or so, maybe anything else? These broken links are really annoying for me ((

--add-to-library fails to find matches for albums that exist

When using --add-to-library or -a, some albums will not find a match if there are slightly different characters used in the album title.

Examples:
The Unquestionable Truth (Part 1) vs The Unquestionable Truth (Pt. 1)
"V" is for Viagra, the Vagina Remixes vs V is for Viagra, the Vagina Remixes
Yours Truly [Deluxe Edition] vs Yours Truly (Deluxe Edition)

It should still consider these a match despite the slight differences in their names.

I keep having SyntaxError in the setup step

I am logged in youtube music, did the shift+ctrl+I step, filtered "/browse" and clicked on library in the webpage.
Using you code

from ytmusicapi import YTMusic YTMusic.setup(filepath="headers_auth.json", headers_raw="<headers copied above>")

from [https://ytmusicapi.readthedocs.io/en/latest/setup.html](your doc), whatever I replaced <headers copied above> with, I keep having errors like :

C:\Users\boreduser\Downloads\test>python test.py File "C:\Users\boreduser\Downloads\test\test.py", line 2 "},{""key"":""ca_type"",""value"":""image""}],""bid"":""ANyPxKopeuyS5v6ZDSDFhjlo7JbB7Wc3as5UrpSvQT-PJik3u3xyEdj7b_1ttfzPZKSkpryaOsW1HL90izQgJmT4VdG_2vW3nQ""}}}""") ^ SyntaxError: invalid syntax

Could you please give and exemple of correctly filled code so that I could see what to do ?Thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.