Skip to content

Commit 01d2dcc

Browse files
committed
Added the ability for a user to use their own client ID for spotify
1 parent 7e34790 commit 01d2dcc

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

osc-chat-tools.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
run = True
4646
playMsg = True
47-
version = "1.5.10"
47+
version = "1.5.11"
4848

4949
#conf variables
5050

@@ -123,6 +123,7 @@
123123

124124
spotifyAccessToken = ''
125125
spotifyRefreshToken = ''
126+
spotify_client_id = '915e1de141b3408eb430d25d0d39b380'
126127

127128
pulsoidToken = ''
128129
usePulsoid = True
@@ -189,7 +190,6 @@
189190

190191
spotifyAuthCode = None #<- only needed for the spotify linking process (temp var)
191192

192-
spotify_client_id = '915e1de141b3408eb430d25d0d39b380'
193193
spotify_redirect_uri = 'http://localhost:8000/callback'
194194
spotifyLinkStatus = 'Unlinked'
195195
cancelLink = False
@@ -412,7 +412,8 @@ def mediaIs(state):
412412
"1.5.8.2" : ['confVersion', 'message_delay', 'messageString', 'FileToRead', 'scrollText', 'hideSong', 'hideOutside', 'showPaused', 'songDisplay', 'showOnChange', 'songChangeTicks', 'minimizeOnStart', 'keybind_run', 'keybind_afk','topBar', 'middleBar', 'bottomBar', 'pulsoidToken', 'avatarHR', 'blinkOverride', 'blinkSpeed', 'useAfkKeybind', 'toggleBeat', 'updatePrompt', 'oscListenAddress', 'oscListenPort', 'oscSendAddress', 'oscSendPort', 'oscForewordAddress', 'oscForeword', 'oscListen', 'oscForeword', 'logOutput', 'layoutString', 'verticalDivider','cpuDisplay', 'ramDisplay', 'gpuDisplay', 'hrDisplay', 'playTimeDisplay', 'mutedDisplay', 'unmutedDisplay', 'darkMode', 'sendBlank', 'suppressDuplicates', 'sendASAP', 'useMediaManager', 'useSpotifyApi', 'spotifySongDisplay', 'spotifyAccessToken', 'spotifyRefreshToken', 'usePulsoid', 'useHypeRate', 'hypeRateKey', 'hypeRateSessionId','timeDisplayPM', 'timeDisplayAM'],
413413
"1.5.9" : ['confVersion', 'message_delay', 'messageString', 'FileToRead', 'scrollText', 'hideSong', 'hideOutside', 'showPaused', 'songDisplay', 'showOnChange', 'songChangeTicks', 'minimizeOnStart', 'keybind_run', 'keybind_afk','topBar', 'middleBar', 'bottomBar', 'pulsoidToken', 'avatarHR', 'blinkOverride', 'blinkSpeed', 'useAfkKeybind', 'toggleBeat', 'updatePrompt', 'oscListenAddress', 'oscListenPort', 'oscSendAddress', 'oscSendPort', 'oscForewordAddress', 'oscForeword', 'oscListen', 'oscForeword', 'logOutput', 'layoutString', 'verticalDivider','cpuDisplay', 'ramDisplay', 'gpuDisplay', 'hrDisplay', 'playTimeDisplay', 'mutedDisplay', 'unmutedDisplay', 'darkMode', 'sendBlank', 'suppressDuplicates', 'sendASAP', 'useMediaManager', 'useSpotifyApi', 'spotifySongDisplay', 'spotifyAccessToken', 'spotifyRefreshToken', 'usePulsoid', 'useHypeRate', 'hypeRateKey', 'hypeRateSessionId','timeDisplayPM', 'timeDisplayAM', 'showSongInfo'],
414414
"1.5.9.1" : ['confVersion', 'message_delay', 'messageString', 'FileToRead', 'scrollText', 'hideSong', 'hideOutside', 'showPaused', 'songDisplay', 'showOnChange', 'songChangeTicks', 'minimizeOnStart', 'keybind_run', 'keybind_afk','topBar', 'middleBar', 'bottomBar', 'pulsoidToken', 'avatarHR', 'blinkOverride', 'blinkSpeed', 'useAfkKeybind', 'toggleBeat', 'updatePrompt', 'oscListenAddress', 'oscListenPort', 'oscSendAddress', 'oscSendPort', 'oscForewordAddress', 'oscForeword', 'oscListen', 'oscForeword', 'logOutput', 'layoutString', 'verticalDivider','cpuDisplay', 'ramDisplay', 'gpuDisplay', 'hrDisplay', 'playTimeDisplay', 'mutedDisplay', 'unmutedDisplay', 'darkMode', 'sendBlank', 'suppressDuplicates', 'sendASAP', 'useMediaManager', 'useSpotifyApi', 'spotifySongDisplay', 'spotifyAccessToken', 'spotifyRefreshToken', 'usePulsoid', 'useHypeRate', 'hypeRateKey', 'hypeRateSessionId','timeDisplayPM', 'timeDisplayAM', 'showSongInfo'],
415-
"1.5.10" : ['confVersion', 'message_delay', 'messageString', 'FileToRead', 'scrollText', 'hideSong', 'hideOutside', 'showPaused', 'songDisplay', 'showOnChange', 'songChangeTicks', 'minimizeOnStart', 'keybind_run', 'keybind_afk','topBar', 'middleBar', 'bottomBar', 'pulsoidToken', 'avatarHR', 'blinkOverride', 'blinkSpeed', 'useAfkKeybind', 'toggleBeat', 'updatePrompt', 'oscListenAddress', 'oscListenPort', 'oscSendAddress', 'oscSendPort', 'oscForewordAddress', 'oscForeword', 'oscListen', 'oscForeword', 'logOutput', 'layoutString', 'verticalDivider','cpuDisplay', 'ramDisplay', 'gpuDisplay', 'hrDisplay', 'playTimeDisplay', 'mutedDisplay', 'unmutedDisplay', 'darkMode', 'sendBlank', 'suppressDuplicates', 'sendASAP', 'useMediaManager', 'useSpotifyApi', 'spotifySongDisplay', 'spotifyAccessToken', 'spotifyRefreshToken', 'usePulsoid', 'useHypeRate', 'hypeRateKey', 'hypeRateSessionId','timeDisplayPM', 'timeDisplayAM', 'showSongInfo']
415+
"1.5.10" : ['confVersion', 'message_delay', 'messageString', 'FileToRead', 'scrollText', 'hideSong', 'hideOutside', 'showPaused', 'songDisplay', 'showOnChange', 'songChangeTicks', 'minimizeOnStart', 'keybind_run', 'keybind_afk','topBar', 'middleBar', 'bottomBar', 'pulsoidToken', 'avatarHR', 'blinkOverride', 'blinkSpeed', 'useAfkKeybind', 'toggleBeat', 'updatePrompt', 'oscListenAddress', 'oscListenPort', 'oscSendAddress', 'oscSendPort', 'oscForewordAddress', 'oscForeword', 'oscListen', 'oscForeword', 'logOutput', 'layoutString', 'verticalDivider','cpuDisplay', 'ramDisplay', 'gpuDisplay', 'hrDisplay', 'playTimeDisplay', 'mutedDisplay', 'unmutedDisplay', 'darkMode', 'sendBlank', 'suppressDuplicates', 'sendASAP', 'useMediaManager', 'useSpotifyApi', 'spotifySongDisplay', 'spotifyAccessToken', 'spotifyRefreshToken', 'usePulsoid', 'useHypeRate', 'hypeRateKey', 'hypeRateSessionId','timeDisplayPM', 'timeDisplayAM', 'showSongInfo'],
416+
"1.5.11" : ['confVersion', 'message_delay', 'messageString', 'FileToRead', 'scrollText', 'hideSong', 'hideOutside', 'showPaused', 'songDisplay', 'showOnChange', 'songChangeTicks', 'minimizeOnStart', 'keybind_run', 'keybind_afk','topBar', 'middleBar', 'bottomBar', 'pulsoidToken', 'avatarHR', 'blinkOverride', 'blinkSpeed', 'useAfkKeybind', 'toggleBeat', 'updatePrompt', 'oscListenAddress', 'oscListenPort', 'oscSendAddress', 'oscSendPort', 'oscForewordAddress', 'oscForeword', 'oscListen', 'oscForeword', 'logOutput', 'layoutString', 'verticalDivider','cpuDisplay', 'ramDisplay', 'gpuDisplay', 'hrDisplay', 'playTimeDisplay', 'mutedDisplay', 'unmutedDisplay', 'darkMode', 'sendBlank', 'suppressDuplicates', 'sendASAP', 'useMediaManager', 'useSpotifyApi', 'spotifySongDisplay', 'spotifyAccessToken', 'spotifyRefreshToken', 'usePulsoid', 'useHypeRate', 'hypeRateKey', 'hypeRateSessionId','timeDisplayPM', 'timeDisplayAM', 'showSongInfo', 'spotify_client_id']
416417

417418
}
418419

@@ -424,7 +425,7 @@ def mediaIs(state):
424425
confVersion = fixed_list[0]
425426
confLoaderIterator = 1
426427
if len(fixed_list) != len(confDataDict[confVersion]):
427-
raise Exception
428+
raise Exception('Data list length mismatch')
428429
for i, x in enumerate(confDataDict[confVersion]):
429430
globals()[x] = fixed_list[i]
430431
#print(f"{x} = {fixed_list[i]}")
@@ -435,7 +436,7 @@ def mediaIs(state):
435436
outputLog('Config file is Too Old! Not Updating Values...')
436437
except Exception as e:
437438
#print('Config File Load Error! Not Updating Values...')
438-
outputLog('Config File Load Error! Not Updating Values...')
439+
outputLog('Config File Load Error! Not Updating Values...\n'+str(e))
439440
if confVersion == "1.4.1" or confVersion == "1.4.20":
440441
outputLog("Converting old layout system, please update your config by pressing apply!")
441442
if topTextToggle:
@@ -688,7 +689,8 @@ def uiThread():
688689
global spotifyRefreshToken
689690
global cancelLink
690691
global spotifyLinkStatus
691-
692+
global spotify_client_id
693+
692694
global usePulsoid
693695
global useHypeRate
694696
global hypeRateKey
@@ -820,8 +822,10 @@ def uiThread():
820822
[sg.Text("Spotify settings:")],
821823
[sg.Text('Template to use for song display.\nVariables: {artist}, {title}, {album_title}, {album_artist}, \n{song_progress}, {song_length}, {volume}, {song_id}')],
822824
[sg.Input(key='spotifySongDisplay', size=(50, 1))],
825+
[sg.Text('Spotify Client ID'), sg.Button("?", key='client_id_help', font='bold'), sg.Text('<- If linking fails, click here!', font="bold")],
826+
[sg.Input(key='spotify_client_id', size=(50, 1))],
823827
[sg.Button("Link Spotify 🔗", key="linkSpotify", button_color="#00a828", font="System"), sg.Text('Unlinked', key='spotifyLinkStatus', font="System", text_color='orange')],
824-
], size=(379, 140))],
828+
], size=(379, 195))],
825829
[sg.Column([
826830
[sg.Text('Music Settings:')],
827831
[sg.Checkbox('Show \"⏸️\" after song when song is paused', default=True, key='showPaused', enable_events= True)],
@@ -1136,6 +1140,7 @@ def updateUI():
11361140
global timeDisplayAM
11371141
global timeDisplayPM
11381142
global showSongInfo
1143+
global spotify_client_id
11391144

11401145
global layoutUpdate
11411146

@@ -1193,6 +1198,8 @@ def updateUI():
11931198
window['timeDisplayAM'].update(value=timeDisplayAM)
11941199
window['timeDisplayPM'].update(value=timeDisplayPM)
11951200
window['showSongInfo'].update(value=showSongInfo)
1201+
window['spotify_client_id'].update(value=spotify_client_id)
1202+
11961203
if spotifyLinkStatus != 'Unlinked':
11971204
window['spotifyLinkStatus'].update(value=spotifyLinkStatus)
11981205
if 'Error' in spotifyLinkStatus and not 'Linked' in spotifyLinkStatus:
@@ -1310,9 +1317,10 @@ def updateUI():
13101317
timeDisplayAM = values['timeDisplayAM']
13111318
timeDisplayPM = values['timeDisplayPM']
13121319
showSongInfo = values['showSongInfo']
1320+
spotify_client_id = values['spotify_client_id']
13131321
with open('please-do-not-delete.txt', 'w', encoding="utf-8") as f:
13141322
try:
1315-
f.write(str([confVersion, message_delay, messageString, FileToRead, scrollText, hideSong, hideOutside, showPaused, songDisplay, showOnChange, songChangeTicks, minimizeOnStart, keybind_run, keybind_afk,topBar, middleBar, bottomBar, pulsoidToken, avatarHR, blinkOverride, blinkSpeed, useAfkKeybind, toggleBeat, updatePrompt, oscListenAddress, oscListenPort, oscSendAddress, oscSendPort, oscForewordAddress, oscForeword, oscListen, oscForeword, logOutput, layoutString, verticalDivider,cpuDisplay, ramDisplay, gpuDisplay, hrDisplay, playTimeDisplay, mutedDisplay, unmutedDisplay, darkMode, sendBlank, suppressDuplicates, sendASAP,useMediaManager, useSpotifyApi, spotifySongDisplay, spotifyAccessToken, spotifyRefreshToken, usePulsoid, useHypeRate, hypeRateKey, hypeRateSessionId, timeDisplayPM, timeDisplayAM, showSongInfo]))
1323+
f.write(str([confVersion, message_delay, messageString, FileToRead, scrollText, hideSong, hideOutside, showPaused, songDisplay, showOnChange, songChangeTicks, minimizeOnStart, keybind_run, keybind_afk,topBar, middleBar, bottomBar, pulsoidToken, avatarHR, blinkOverride, blinkSpeed, useAfkKeybind, toggleBeat, updatePrompt, oscListenAddress, oscListenPort, oscSendAddress, oscSendPort, oscForewordAddress, oscForeword, oscListen, oscForeword, logOutput, layoutString, verticalDivider,cpuDisplay, ramDisplay, gpuDisplay, hrDisplay, playTimeDisplay, mutedDisplay, unmutedDisplay, darkMode, sendBlank, suppressDuplicates, sendASAP,useMediaManager, useSpotifyApi, spotifySongDisplay, spotifyAccessToken, spotifyRefreshToken, usePulsoid, useHypeRate, hypeRateKey, hypeRateSessionId, timeDisplayPM, timeDisplayAM, showSongInfo, spotify_client_id]))
13161324
except Exception as e:
13171325
sg.popup('Error saving config to file:\n'+str(e))
13181326

@@ -1635,6 +1643,8 @@ def spotifyLinkManager():
16351643
webbrowser.open(spotifySongUrl)
16361644
except Exception as e:
16371645
pass
1646+
if event == 'client_id_help':
1647+
webbrowser.open('https://github.com/Lioncat6/OSC-Chat-Tools/wiki/Spotify-Client-ID')
16381648
window.close()
16391649
playMsg = False
16401650
run = False

0 commit comments

Comments
 (0)