Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuk committed Apr 29, 2018
2 parents 5c78fa3 + 1506ffe commit 0659011
Show file tree
Hide file tree
Showing 62 changed files with 2,770 additions and 1,673 deletions.
31 changes: 28 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.plex"
name="Plex"
version="0.1.3"
version="0.1.4"
provider-name="Plex">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.requests" version="2.3.0"/>
</requires>
<extension point="xbmc.python.script" library="default.py">
Expand All @@ -13,19 +13,44 @@
<extension point="xbmc.python.pluginsource" library="plugin.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.service" library="service.py" start="startup"></extension>
<extension point="xbmc.service" library="service.py" start="login"></extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Plex for Kodi</summary>
<summary lang="de">Plex für Kodi</summary>
<summary lang="hu">Plex for Kodi</summary>
<summary lang="ru">Plex for Kodi</summary>
<description lang="en">Official Plex for Kodi add-on</description>
<description lang="de">Offizielles Plex für Kodi Addon</description>
<description lang="hu">Hivatalos Plex for Kodi add-on</description>
<description lang="fr">Add-on Officiel Plex pour Kodi</description>
<description lang="ru">Официальный аддон Plex for Kodi</description>
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
<forum>https://forums.plex.tv/categories/plex-for-kodi</forum>
<website>https://www.plex.tv</website>
<source>https://github.com/plexinc/plex-for-kodi</source>
<platform>all</platform>
<news>
Kodi v18: Fix skin compatability issues
Kodi v18: Fix incompatibility with requests module update
Kodi v18: Fix issue with playback not resuming properly when direct playing
Kodi v18: Fix issue with progress bar not moving on music player/music playlist screens
Fix album display on artist screen
Fix bug causing failure to show audio player when clicking the mini player from some screens
Show original artist when available (Issue #143)
Improve centering over label backgrounds on pre-play screens
Fix some spots where tokens could still be logged
Play correct track when playing a multi-disc album (Issue #148)
Improve headers for better identification in 'Now Playing' and future server profile
Updated German language strings (thanks to coffinbearer)
Fix French translations file (thanks to coffinbearer)
Fix some Hungarian translations (thanks to vampywiz17)
Add Russion translations (thanks to shady2k)
Fix autostart to work with profiles (thanks to pannal)
Fix focus loss on home screen due to error (Issue #169)
Fix "No Servers Found" when preferred server is unavailable (Issue #159)
Fix system keyboard not working for search (Kodi 17+)(Issue #165)
Fix issue causing hubs to scroll up when settings were opened
Fix failure to sign in when signed off externally (Issue #110, #117)
</news>
</extension>
</addon>
28 changes: 26 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
[- 0.1.4 -]

Kodi v18: Fix skin compatability issues
Kodi v18: Fix incompatibility with requests module update
Kodi v18: Fix issue with playback not resuming properly when direct playing
Kodi v18: Fix issue with progress bar not moving on music player/music playlist screens
Fix album display on artist screen
Fix bug causing failure to show audio player when clicking the mini player from some screens
Show original artist when available (Issue #143)
Improve centering over label backgrounds on pre-play screens
Fix some spots where tokens could still be logged
Play correct track when playing a multi-disc album (Issue #148)
Improve headers for better identification in 'Now Playing' and future server profile
Updated German language strings (thanks to coffinbearer)
Fix French translations file (thanks to coffinbearer)
Fix some Hungarian translations (thanks to vampywiz17)
Add Russion translations (thanks to shady2k)
Fix autostart to work with profiles (thanks to pannal)
Fix focus loss on home screen due to error (Issue #169)
Fix "No Servers Found" when preferred server is unavailable (Issue #159)
Fix system keyboard not working for search (Kodi 17+)(Issue #165)
Fix issue causing hubs to scroll up when settings were opened
Fix failure to sign in when signed off externally (Issue #110 & #117)

[- 0.1.3 -]

Fix incompatibility with requests module update
Expand All @@ -13,7 +37,7 @@ Remove PlexPass disclaimer from add-on info
[- 0.1.0 -]

Improved hub vertical scrolling animation
Fix (#87): Switching between managed users causes Kodi to crashing
Fix (#87): Switching between managed users causes Kodi to crash
Fix (#119): Occasional crashes when exiting the add-on
Remove PlexPass requirement

Expand All @@ -26,7 +50,7 @@ Add ability to view episodes/albums in library view
Add German translation (thanks to coffinbearer)
Add Czech translation (thanks to Pavuucek)
Add Hungarian translation (thanks to vampywiz17)
Add Frensh translation (thanks to raffoul/rlimbach)
Add French translation (thanks to raffoul/rlimbach)
Fix issue #64 (multi part movies won't playback)
Improve timeline reporting
Friendly name now includes hostname to differentiate Kodi devices
Expand Down
14 changes: 7 additions & 7 deletions lib/_included_packages/plexnet/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _startAsync(self, body=None, contentType=None, context=None):
self.removeAsPending()
return
except Exception, e:
util.ERROR('Request failed {0}'.format(self.url), e)
util.ERROR('Request failed {0}'.format(util.cleanToken(self.url)), e)
if not hasattr(e, 'response'):
return
res = e.response
Expand Down Expand Up @@ -256,7 +256,7 @@ def logRequest(self, body, timeout=None, async=True):
class HttpResponse(object):
def __init__(self, event):
self.event = event
if self.event:
if not self.event is None:
self.event.content # force data to be read
self.event.close()

Expand All @@ -269,28 +269,28 @@ def isError(self):
return not self.isSuccess()

def getStatus(self):
if not self.event:
if self.event is None:
return 0
return self.event.status_code

def getBodyString(self):
if not self.event:
if self.event is None:
return ''
return self.event.text.encode('utf-8')

def getErrorString(self):
if not self.event:
if self.event is None:
return ''
return self.event.reason

def getBodyXml(self):
if self.event:
if not self.event is None:
return ElementTree.fromstring(self.getBodyString())

return None

def getResponseHeader(self, name):
if not self.event:
if self.event is None:
return None
return self.event.headers.get(name)

Expand Down
31 changes: 16 additions & 15 deletions lib/_included_packages/plexnet/myplexmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,25 @@ def onResourcesResponse(self, request, response, context):
response.parseFakeXMLResponse(data)
util.DEBUG_LOG("Using cached resources")

for resource in response.container:
util.DEBUG_LOG(
"Parsed resource from plex.tv: type:{0} clientIdentifier:{1} name:{2} product:{3} provides:{4}".format(
resource.type,
resource.clientIdentifier,
resource.name.encode('utf-8'),
resource.product.encode('utf-8'),
resource.provides.encode('utf-8')
if response.container:
for resource in response.container:
util.DEBUG_LOG(
"Parsed resource from plex.tv: type:{0} clientIdentifier:{1} name:{2} product:{3} provides:{4}".format(
resource.type,
resource.clientIdentifier,
resource.name.encode('utf-8'),
resource.product.encode('utf-8'),
resource.provides.encode('utf-8')
)
)
)

for conn in resource.connections:
util.DEBUG_LOG(' {0}'.format(conn))
for conn in resource.connections:
util.DEBUG_LOG(' {0}'.format(conn))

if 'server' in resource.provides:
server = plexserver.createPlexServerForResource(resource)
util.DEBUG_LOG(' {0}'.format(server))
servers.append(server)
if 'server' in resource.provides:
server = plexserver.createPlexServerForResource(resource)
util.DEBUG_LOG(' {0}'.format(server))
servers.append(server)

plexapp.SERVERMANAGER.updateFromConnectionType(servers, plexconnection.PlexConnection.SOURCE_MYPLEX)

Expand Down
10 changes: 1 addition & 9 deletions lib/_included_packages/plexnet/plexapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SERVERMANAGER = None
ACCOUNT = None

PLATFORM = util.X_PLEX_DEVICE

def init():
global MANAGER, SERVERMANAGER, ACCOUNT
Expand Down Expand Up @@ -126,15 +127,6 @@ def shutdown(self):
util.DEBUG_LOG('Waiting for App() timers: Finished')


try:
_platform = platform.platform()
except:
try:
_platform = platform.platform(terse=True)
except:
_platform = sys.platform


class DeviceInfo(object):
def getCaptionsOption(self, key):
return None
Expand Down
5 changes: 4 additions & 1 deletion lib/_included_packages/plexnet/plexplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def getDecisionPath(self, directPlay=False):
server = self.metadata.transcodeServer or self.item.getServer()
decisionPath = self.buildTranscode(server, util.AttributeDict(), self.metadata.partIndex, True, False).decisionPath

util.TEST(decisionPath)

# Modify the decision params based on the transcode url
if decisionPath:
if directPlay:
Expand All @@ -249,7 +251,7 @@ def getDecisionPath(self, directPlay=False):
decisionPath = http.addUrlParam(decisionPath, "subtitles=" + subType)

# Global variables for all decisions
decisionPath = http.addUrlParam(decisionPath, "mediaBufferSize=50000")
decisionPath = http.addUrlParam(decisionPath, "mediaBufferSize=20971") # Kodi default is 20971520 (20MB)
decisionPath = http.addUrlParam(decisionPath, "hasMDE=1")
decisionPath = http.addUrlParam(decisionPath, 'X-Plex-Platform=Chrome')

Expand Down Expand Up @@ -504,6 +506,7 @@ def buildTranscode(self, server, obj, partIndex, directStream, isCurrentPart):

# Build the decision path now that we have build our stream url, and only if the server supports it.
if server.supportsFeature("streamingBrain"):
util.TEST("TEST==========================")
decisionPath = builder.getRelativeUrl().replace(obj.transcodeEndpoint, self.DECISION_ENDPOINT)
if decisionPath.startswith(self.DECISION_ENDPOINT):
obj.decisionPath = decisionPath
Expand Down
6 changes: 3 additions & 3 deletions lib/_included_packages/plexnet/plexresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def URL(self):
return self.http_url

def connect(self):
util.LOG('Connecting: {0}'.format(self.URL))
util.LOG('Connecting: {0}'.format(util.cleanToken(self.URL)))
try:
self.data = self.query('/')
self.reachable = True
return True
except Exception as err:
util.ERROR(self.URL, err)
util.ERROR(util.cleanToken(self.URL), err)

util.LOG('Connecting: Secure failed, trying insecure...')
self.secure = False
Expand All @@ -121,7 +121,7 @@ def connect(self):
self.reachable = True
return True
except Exception as err:
util.ERROR(self.URL, err)
util.ERROR(util.cleanToken(self.URL), err)

return False

Expand Down
4 changes: 2 additions & 2 deletions lib/_included_packages/plexnet/plexserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ def collectDataFromRoot(self, data):
}

for f, v in features.items():
if verlib.suggest_normalized_version(v) <= self.versionNorm:
if util.normalizedVersion(v) <= self.versionNorm:
self.features[f] = True

appMinVer = plexapp.INTERFACE.getGlobal('minServerVersionArr', '0.0.0.0')
self.isSupported = self.isSecondary() or verlib.suggest_normalized_version(appMinVer) <= self.versionNorm
self.isSupported = self.isSecondary() or util.normalizedVersion(appMinVer) <= self.versionNorm

util.DEBUG_LOG("Server information updated from reachability check: {0}".format(self))

Expand Down
48 changes: 29 additions & 19 deletions lib/_included_packages/plexnet/plexservermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,10 @@ def updateReachabilityResult(self, server, reachable=False):
# See if we should settle for the best we've found so far.
self.checkSelectedServerSearch()

def checkSelectedServerSearch(self):
if not self.selectedServer and self.searchContext:
def checkSelectedServerSearch(self, skip_preferred=False, skip_owned=False):
if self.selectedServer:
return self.selectedServer
elif self.searchContext:
# If we're still waiting on the resources response then there's no
# reason to settle, so don't even iterate over our servers.

Expand All @@ -252,34 +254,42 @@ def checkSelectedServerSearch(self):
waitingForAnything = False
waitingToTestAll = bool(self.deferReachabilityTimer)

# Iterate over all our servers and see if we're waiting on any results
servers = self.getServers()
pendingCount = 0
for server in servers:
if server.pendingReachabilityRequests > 0:
pendingCount = pendingCount + server.pendingReachabilityRequests
if server.uuid == self.searchContext.preferredServer:
waitingForPreferred = True
elif server.owned:
waitingForOwned = True
else:
waitingForAnything = True

pendingString = "{0} pending reachability tests".format(pendingCount)
if skip_preferred:
self.searchContext.preferredServer = None
if self.deferReachabilityTimer:
self.deferReachabilityTimer.cancel()
self.deferReachabilityTimer = None

if not skip_owned:
# Iterate over all our servers and see if we're waiting on any results
servers = self.getServers()
pendingCount = 0
for server in servers:
if server.pendingReachabilityRequests > 0:
pendingCount += server.pendingReachabilityRequests
if server.uuid == self.searchContext.preferredServer:
waitingForPreferred = True
elif server.owned:
waitingForOwned = True
else:
waitingForAnything = True

pendingString = "{0} pending reachability tests".format(pendingCount)

if waitingForPreferred:
util.LOG("Still waiting for preferred server: " + pendingString)
elif waitingToTestAll:
util.LOG("Preferred server not reachable, testing all servers now")
self.updateReachability(True, False, False)
elif waitingForOwned and (not self.searchContext.bestServer or not self.searchContext.bestServer.owned):
util.LOG("Still waiting for an owned server: " + pendingString)
elif waitingForAnything and not self.searchContext.bestServer:
util.LOG("Still waiting for any server: {0}".format(pendingString))
elif waitingToTestAll:
util.LOG("Preferred server not reachable, testing all servers now")
self.updateReachability(True, False, False)
else:
# No hope for anything better, let's select what we found
util.LOG("Settling for the best server we found")
self.setSelectedServer(self.searchContext.bestServer or self.searchContext.fallbackServer, True)
return self.selectedServer

def compareServers(self, first, second):
if not first or not first.isSupported:
Expand Down
8 changes: 4 additions & 4 deletions lib/_included_packages/plexnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def resetBaseHeaders():
USER_AGENT = '{0}/{1}'.format(PROJECT, VERSION)

try:
_platform = platform.platform()
_platform = platform.system()
except:
try:
_platform = platform.platform(terse=True)
Expand Down Expand Up @@ -173,9 +173,9 @@ def bitrateToString(bits):

def normalizedVersion(ver):
try:
modv = '.'.join(ver.split('.')[:4]).rsplit('-', 1)[0] # Clean the version i.e. Turn 1.2.3.4-asdf8 into 1.2.3.4
return verlib.suggest_normalized_version(modv)
modv = '.'.join(ver.split('.')[:4]).split('-', 1)[0] # Clean the version i.e. Turn 1.2.3.4-asdf8-ads7f into 1.2.3.4
return verlib.NormalizedVersion(verlib.suggest_normalized_version(modv))
except:
if ver:
ERROR()
return verlib.suggest_normalized_version('0.0.0')
return verlib.NormalizedVersion(verlib.suggest_normalized_version('0.0.0'))
Loading

0 comments on commit 0659011

Please sign in to comment.