Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DaveLak/61666ce2936d9c4a96d78fbac76a974a to your computer and use it in GitHub Desktop.
Save DaveLak/61666ce2936d9c4a96d78fbac76a974a to your computer and use it in GitHub Desktop.

Revisions

  1. @PhilippIRL PhilippIRL revised this gist Apr 22, 2022. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion enable-spotify-devtools.py
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,15 @@
    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)
    @@ -41,4 +50,4 @@
    # change one byte to 50 (ascii '2')
    file.write(bytes([50]))

    file.close()
    file.close()
  2. @PhilippIRL PhilippIRL revised this gist Apr 22, 2022. 1 changed file with 18 additions and 7 deletions.
    25 changes: 18 additions & 7 deletions enable-spotify-devtools.py
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,26 @@
    #
    # Created by @PhilippIRL
    # Windows, non MS-Store version only (but if you change the file path it might work on other operating systems too)
    #
    # 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
    import os, sys, platform

    # path of offline.bnk on windows (non ms-store)
    filePath = os.environ['LOCALAPPDATA'] + '\\Spotify\\offline.bnk'
    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'

    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()
  3. @PhilippIRL PhilippIRL revised this gist Apr 22, 2022. 1 changed file with 19 additions and 10 deletions.
    29 changes: 19 additions & 10 deletions enable-spotify-devtools.py
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,33 @@
    #
    # Created by @PhilippIRL
    # Windows, non MS-Store version only (but if you change the file path it might work on other operating systems too)
    #
    # 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.
    #

    import os, sys

    file = open(os.environ['LOCALAPPDATA'] + "\\Spotify\\offline.bnk", "r+b")
    # path of offline.bnk on windows (non ms-store)
    filePath = os.environ['LOCALAPPDATA'] + '\\Spotify\\offline.bnk'

    file = open(filePath, 'r+b')
    content = file.read()

    loc = -1
    while 1:
    try:
    loc = content.index(b"app-developer", loc + 1)
    except ValueError:
    break

    # 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])
    print('Unexpected value', content[patchLoc])
    sys.exit(1)

    file.seek(patchLoc)
    file.write((50).to_bytes(1, sys.byteorder))

    # change one byte to 50 (ascii '2')
    file.write(bytes([50]))

    file.close()
  4. @PhilippIRL PhilippIRL revised this gist Apr 21, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions enable-spotify-devtools.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # Created by @PhilippIRL
    # Windows, non MS-Store version only (but if you change the file path it might work on other operating systems too)

    import os, sys

    file = open(os.environ['LOCALAPPDATA'] + "\\Spotify\\offline.bnk", "r+b")
  5. @PhilippIRL PhilippIRL created this gist Apr 21, 2022.
    21 changes: 21 additions & 0 deletions enable-spotify-devtools.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import os, sys

    file = open(os.environ['LOCALAPPDATA'] + "\\Spotify\\offline.bnk", "r+b")
    content = file.read()

    loc = -1
    while 1:
    try:
    loc = content.index(b"app-developer", loc + 1)
    except ValueError:
    break

    patchLoc = loc + 15

    if not (content[patchLoc] == 48 or content[patchLoc] == 50):
    print("Unexpected value", content[patchLoc])
    sys.exit(1)

    file.seek(patchLoc)
    file.write((50).to_bytes(1, sys.byteorder))
    file.close()