Skip to content

Instantly share code, notes, and snippets.

@cvzi
Last active March 30, 2020 10:40
Show Gist options
  • Save cvzi/e5ce7414eb47ef51cbf76d02bda29c79 to your computer and use it in GitHub Desktop.
Save cvzi/e5ce7414eb47ef51cbf76d02bda29c79 to your computer and use it in GitHub Desktop.
Reads all failed uploads from Google Music Manager and creates a m3u playlist of the failed files. Optionally resets the failed songs in the MusicManager database, so they can be uploaded again
# Reads all failed uploads from Google Music Manager and creates a m3u playlist of the failed files.
# You should stop Music Manager program before executing this script!
# You may use this m3u playlist to transcode the files to another file format.
# MusicManager usually fails because it cannot transcode the file format, either because
# it does not recognize the format or because the file is corrupted.
# If the filenames stay the same after transcoding, you can activate the second part of the
# script. This will delete the failures from the MusicManager database and after a restart
# MusicManager will try to upload them again.
# Transcoding files with iTunes on Windows:
# Stop Music Manager program, in this script replace `deleteFailuresFromDatabase = False` with
# `deleteFailuresFromDatabase = True`, run the script, open iTunes:
# `File` -> `Library` -> `Import playlist` and select the newly created
# `MusicManagerFailures.m3u` from your Desktop.
# Open the new playlist in iTunes, select all songs and do `File` -> `Convert` -> `Create AAC version`
# Wait until all songs are converted, then select all songs in the playlist again and
# right click on one of them and select `Delete from Library`
# Python 3.8
import sqlite3
import os
playlist = os.path.expanduser(r'~\Desktop\MusicManagerFailures.m3u')
dbFilePath = os.path.expanduser(r'~\AppData\Local\Google\MusicManager\ServerDatabase.db')
deleteFailuresFromDatabase = False
if __name__ == '__main__':
if os.path.isfile(playlist):
print(f'Playlist file already exists: {playlist}')
exit(64)
conn = sqlite3.connect(dbFilePath)
c = conn.cursor()
with open(playlist, 'wb') as f:
print(f'Writing "transconding failed" songs to {playlist} ...')
f.writelines(f'{row[0]}\r\n'.encode('utf8') for row in c.execute('SELECT "AbsolutePath" FROM "PROCESSINGATTEMPTS"'))
print(f'Writing other failed songs" to {playlist} ...')
f.writelines(f'{row[0]}\r\n'.encode('utf8') for row in c.execute('SELECT "FileHandle" FROM "XFILES" WHERE "ServerId" IS NULL'))
print('Done!')
if deleteFailuresFromDatabase:
print('Deleting failed songs from database...')
c.execute('DELETE FROM "PROCESSINGATTEMPTS"')
conn.commit()
print('Done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment