Last active
January 4, 2025 01:06
-
-
Save PhilippIRL/97908aba3a78cc0c8d0ab4e9439bf445 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by @PhilippIRL | |
# This script patches Spotify's offline.bnk file (this file caches the remote config) to trick Spotify into thinking that your account is enabled for dev tools. | |
# Spotify will automatically revert this local change after some time when it next fetches the remote config. | |
# Of course you will have to completely close Spotify before running this script. | |
import os, sys, platform | |
systemPlatform = platform.system() | |
if systemPlatform == 'Windows': | |
filePath = os.environ['LOCALAPPDATA'] + '\\Spotify\\offline.bnk' | |
elif systemPlatform == 'Darwin': | |
filePath = os.environ['HOME'] + '/Library/Application Support/Spotify/PersistentCache/offline.bnk' | |
elif systemPlatform == 'Linux': | |
homePath = os.environ['HOME'] | |
snapSpotifyHome = os.environ['HOME'] + '/snap/spotify/common' | |
if os.path.exists(snapSpotifyHome): | |
homePath = snapSpotifyHome | |
filePath = homePath + '/.cache/spotify/offline.bnk' | |
else: | |
print('Sorry, your platform is not yet supported.') | |
sys.exit(1) | |
# check if spotify is installed | |
if not os.path.exists(filePath): | |
print('It seems like you don\'t have Spotify installed.') | |
sys.exit(1) | |
file = open(filePath, 'r+b') | |
content = file.read() | |
# find last occurence of string 'app-developer' | |
loc = content.rindex(b'app-developer') | |
# 15 bytes after this string is the location we want to patch | |
patchLoc = loc + 15 | |
# only patch if the value is what we expect | |
if not (content[patchLoc] == 48 or content[patchLoc] == 50): | |
print('Unexpected value', content[patchLoc]) | |
sys.exit(1) | |
file.seek(patchLoc) | |
# change one byte to 50 (ascii '2') | |
file.write(bytes([50])) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is expected behavior and mentioned on line #3.
This may be due to using python 2.x instead of python3. If you have both on your system, try specifying python3 when running the script,
python3 enable-spotify-devtools.py
.Just posted a bash version of this script for Linux/macOS users - jetfir3/tmpdevmodify.sh
Script is a bit more "forgiving" on the Linux side as some distros or install methods (such as flatpak) have paths which may differ. Also includes an option to wipe app cache if mistakes are made using dev tools.