Skip to content

Instantly share code, notes, and snippets.

@PhilippIRL
Last active November 9, 2023 02:14
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save PhilippIRL/97908aba3a78cc0c8d0ab4e9439bf445 to your computer and use it in GitHub Desktop.
Save PhilippIRL/97908aba3a78cc0c8d0ab4e9439bf445 to your computer and use it in GitHub Desktop.
# 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()
@amd64fox
Copy link

Thanks for the method, but this script doesn't work for me on windows.
It replaces 0 with 2 in the wrong place.
I try to do it manually by replacing this <app-developer>0</app-developer> with this <app-developer>2</app-developer> then everything works.

@PhilippIRL
Copy link
Author

PhilippIRL commented Apr 28, 2022

Thanks for the method, but this script doesn't work for me on windows. It replaces 0 with 2 in the wrong place. I try to do it manually by replacing this <app-developer>0</app-developer> with this <app-developer>2</app-developer> then everything works.

weird, every time I tested the method (also on Windows) it was exacly opposite for me

@amd64fox
Copy link

It looks like it works differently depending on the region of the account. My account has a Ukrainian region, my friend has a German account and your method works for him, but it doesn't work for me.

@chrismessina
Copy link

Spotify seems to overwrite my offline.bnk file every time I restart the app. Furthermore, when I run this script, I get the error ('Unexpected value', '0') — but wouldn't the expected value be 0?

Any tips would be appreciated!

@jetfir3
Copy link

jetfir3 commented Jul 7, 2023

Spotify seems to overwrite my offline.bnk file every time I restart the app.

This is expected behavior and mentioned on line #3.

Furthermore, when I run this script, I get the error ('Unexpected value', '0') — but wouldn't the expected value be 0?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment