Skip to content

Commit

Permalink
Better handling of PlexToken, removed pref for port
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony B committed Aug 31, 2016
1 parent 2a3004b commit 63955c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
21 changes: 14 additions & 7 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ def Start():
DirectoryObject.thumb = R(ICON)

Dict['server_ip'] = 'localhost'
Dict['plextoken'] = os.environ['PLEXTOKEN']

Dict['server_port'] = os.environ['PLEXSERVERPORT']

if 'PLEXTOKEN' in os.environ:
Dict['plextoken'] = os.environ['PLEXTOKEN']
else:
Dict['plextoken'] = None

Log("Plex Token: {}".format(Dict['token']))

HTTP.CacheTime = 0

####################################################################################################
def MainMenu():

Dict['music_sections'] = get_music_sections(Dict['server_ip'], Prefs['server_port'], Dict['plextoken'])
clients = get_clients(Dict['server_ip'], Prefs['server_port'], Dict['plextoken'])
Dict['music_sections'] = get_music_sections(Dict['server_ip'], Dict['server_port'], Dict['plextoken'])
clients = get_clients(Dict['server_ip'], Dict['server_port'], Dict['plextoken'])

# Plex web clients don't seem to work
clients2 = []
Expand Down Expand Up @@ -56,7 +63,7 @@ def GeneratePlaylist():
return section_selection_menu()
else:
Dict['playlist'] = generate_playlist(Dict['server_ip'],
Prefs['server_port'],
Dict['server_port'],
Dict['plextoken'],
Dict['music_sections'][0],
Prefs['playlist_name'],
Expand Down Expand Up @@ -96,7 +103,7 @@ def SectionSelection(idx):
idx=int(idx)

Dict['playlist'] = generate_playlist(Dict['server_ip'],
Prefs['server_port'],
Dict['server_port'],
Dict['plextoken'],
Dict['music_sections'][idx],
Prefs['playlist_name'],
Expand All @@ -109,7 +116,7 @@ def ClientSelection(idx):
#TODO: figure out server IP??
Log.Debug("ShuffleByAlbum: Going to play on client #{} {})".format(idx, Dict['clients'][idx]['address']))
play_on_client(Dict['server_ip'],
Prefs['server_port'],
Dict['server_port'],
Dict['plextoken'],
Dict['clients'][idx],
Dict['playlist'])
Expand Down
3 changes: 2 additions & 1 deletion Contents/Code/plexshufflebyalbum.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def query(self, path, method):
headers = dict()
headers['Accept'] = 'application/json'
headers['X-Plex-Client-Identifier'] = '77777777-abab-4bc3-86a6-809c4901fb87'
headers['X-Plex-Token'] = self.token
if self.token:
headers['X-Plex-Token'] = self.token


r = http_comm(url, method, headers)
Expand Down
6 changes: 0 additions & 6 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@
"type": "text",
"label": "Playlist Name",
"default": "ShuffleByAlbum",
},
{
"id": "server_port",
"type": "text",
"label": "Server Port",
"default": "32400"
}
]

0 comments on commit 63955c8

Please sign in to comment.