Skip to content

Commit

Permalink
updated dumbtools to latest
Browse files Browse the repository at this point in the history
v1.0.4 prep
  • Loading branch information
Twoure committed Jan 24, 2016
1 parent e6ffeb5 commit 2adca8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# ChangeLog

##### 1.0.4
- _01/20/16_
- _01/23/16_
- Fixed Plex Web Search
- Updated DumbTools to latest
- Added Client Platform and Product checks in logs

##### 1.0.3
Expand Down
32 changes: 19 additions & 13 deletions Contents/Code/DumbTools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# DumbTools for Plex v1.1 by Cory <[email protected]>
import urllib2


class DumbKeyboard:
#clients = ['Plex for iOS', 'Plex Media Player', 'Plex Web']
clients = ['Plex for iOS', 'Plex Media Player']
KEYS = list('abcdefghijklmnopqrstuvwxyz1234567890-=;[]\\\',./')
SHIFT_KEYS = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+:{}|\"<>?')
Expand Down Expand Up @@ -85,11 +86,19 @@ def Submit(self, query):
kwargs.update(self.callback_args)
return self.Callback(**kwargs)


class DumbPrefs:
clients = ['Plex for iOS', 'Plex Media Player', 'Plex Home Theater',
'OpenPHT', 'Plex for Roku']

def __init__(self, prefix, oc, title=None, thumb=None):
self.host = 'http://127.0.0.1:32400'
try:
self.CheckAuth()
except Exception as e:
Log.Error('DumbPrefs: this user cant access prefs: %s' % str(e))
return

Route.Connect(prefix+'/dumbprefs/list', self.ListPrefs)
Route.Connect(prefix+'/dumbprefs/listenum', self.ListEnum)
Route.Connect(prefix+'/dumbprefs/set', self.Set)
Expand All @@ -98,26 +107,23 @@ def __init__(self, prefix, oc, title=None, thumb=None):
title=title if title else L('Preferences'),
thumb=thumb))
self.prefix = prefix
self.host = 'http://127.0.0.1:32400'
self.GetPrefs()

def GetHeaders(self):
headers = Request.Headers
headers['Connection'] = 'close'
return headers

def CheckAuth(self):
""" Only the main users token is accepted at /myplex/account """
headers = {'X-Plex-Token': Request.Headers.get('X-Plex-Token', '')}
req = urllib2.Request("%s/myplex/account" % self.host, headers=headers)
res = urllib2.urlopen(req)

def GetPrefs(self):
try:
data = HTTP.Request("%s/:/plugins/%s/prefs" % (self.host,
Plugin.Identifier),
headers=self.GetHeaders(),
immediate=True,
cacheTime=0).content
except Exception as e:
Log(str(e))
prefs = []
else:
prefs = XML.ElementFromString(data).xpath('/MediaContainer/Setting')
data = HTTP.Request("%s/:/plugins/%s/prefs" % (self.host, Plugin.Identifier),
headers=self.GetHeaders())
prefs = XML.ElementFromString(data).xpath('/MediaContainer/Setting')

self.prefs = [{'id': pref.xpath("@id")[0],
'type': pref.xpath("@type")[0],
Expand Down

0 comments on commit 2adca8b

Please sign in to comment.