Methode "Kodiitem" modifiziert 2.0
This commit is contained in:
parent
288916c1d2
commit
69704d4daf
1 changed files with 10 additions and 12 deletions
|
|
@ -3,7 +3,6 @@ import urllib.request
|
||||||
class kodi():
|
class kodi():
|
||||||
def __init__(self,url="10.0.1.102"):
|
def __init__(self,url="10.0.1.102"):
|
||||||
self.kodiurl="http://"+url+"/jsonrpc?request=%7B%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Player.GetItem%22,%20%22params%22:%20%7B%20%22properties%22:%20%5B%22title%22,%20%22album%22,%20%22artist%22,%20%22season%22,%20%22episode%22,%20%22duration%22,%20%22showtitle%22,%20%22tvshowid%22,%20%22thumbnail%22,%20%22file%22,%20%22fanart%22,%20%22streamdetails%22%5D,%20%22playerid%22:%201%20%7D,%20%22id%22:%20%22VideoGetItem%22%7D"
|
self.kodiurl="http://"+url+"/jsonrpc?request=%7B%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Player.GetItem%22,%20%22params%22:%20%7B%20%22properties%22:%20%5B%22title%22,%20%22album%22,%20%22artist%22,%20%22season%22,%20%22episode%22,%20%22duration%22,%20%22showtitle%22,%20%22tvshowid%22,%20%22thumbnail%22,%20%22file%22,%20%22fanart%22,%20%22streamdetails%22%5D,%20%22playerid%22:%201%20%7D,%20%22id%22:%20%22VideoGetItem%22%7D"
|
||||||
print(self.kodiurl)
|
|
||||||
self.jsonString = self.JSON_holen
|
self.jsonString = self.JSON_holen
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -21,14 +20,12 @@ class kodi():
|
||||||
self.jsonString=self.JSON_holen
|
self.jsonString=self.JSON_holen
|
||||||
else:
|
else:
|
||||||
self.jsonString=json
|
self.jsonString=json
|
||||||
start = len(suchstring) + 3 # berechnet die Anfangsposition des Wertes
|
start = len(suchstring) + 3
|
||||||
ende = len(self.jsonString) # gibt die Gesamtlänge der URL Antwort an
|
ende = len(self.jsonString)
|
||||||
position = self.jsonString.find("\"" + suchstring, 46,
|
position = self.jsonString.find("\"" + suchstring, 46,ende)
|
||||||
ende) # sucht in der gesamten URL Antwort nach dem Suchbegriff und ermittelt dessen Position im String (Anfang)
|
|
||||||
if position > 0:
|
if position > 0:
|
||||||
position2 = self.jsonString.find(",\"", position,
|
position2 = self.jsonString.find(",\"", position,ende)
|
||||||
ende) # sucht anhand der Anfangspos. des Suchstrings nach dem Ende des dazugehörigen Wertes (endet mit ,")
|
wert = (self.jsonString[position + start:position2])
|
||||||
wert = (self.jsonString[position + start:position2]) # gibt den Wert des Suchbegriffes aus
|
|
||||||
x = 0
|
x = 0
|
||||||
while wert.isalnum() is False and x < 2:
|
while wert.isalnum() is False and x < 2:
|
||||||
wert = wert.strip("\"}][{")
|
wert = wert.strip("\"}][{")
|
||||||
|
|
@ -58,13 +55,14 @@ class kodi():
|
||||||
koditems["episode"] = "E0" + koditems["episode"]
|
koditems["episode"] = "E0" + koditems["episode"]
|
||||||
else:
|
else:
|
||||||
koditems["episode"] = "E" + koditems["episode"]
|
koditems["episode"] = "E" + koditems["episode"]
|
||||||
if "type" in koditems and "label" in koditems:
|
if "type" in koditems:
|
||||||
if koditems["type"] =="unknown" and koditems["label"] !="":
|
test = self.Suchen_nach("label", a)
|
||||||
|
if koditems["type"] =="unknown" and test !="":
|
||||||
koditems["type"]="Stream"
|
koditems["type"]="Stream"
|
||||||
return koditems
|
return koditems
|
||||||
|
|
||||||
items = {"episode": "","width": "","duration":""}
|
items = {"episode": "","width": "","duration":"","type":""}
|
||||||
wz = kodi()
|
wz = kodi()
|
||||||
|
|
||||||
print(wz.kodiitem(items))
|
print(wz.kodiitem())
|
||||||
print(wz.JSON_holen)
|
print(wz.JSON_holen)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue