Új hozzászólás Aktív témák
-
Hege1234
addikt
köszi pár órával ezelőtt kezdtem bele hogyan is lehetne megoldani még keverem minek mi a pontos neve és jelentősége
>>> import json
>>> import base64
>>> import requests
>>>
>>> credentials = b'kodi:kodi'
>>> encoded_credentials = base64.b64encode(credentials)
>>> authorization = b'Basic ' + encoded_credentials
>>> headers = { 'Content-Type': 'application/json', 'Authorization': authorization }
>>> url = 'http://192.168.1.10:8080/jsonrpc?Base'
>>> data = [
... {"jsonrpc":"2.0","method":"Player.GetProperties","params":[1,["time"]],"id":17},
... {"jsonrpc":"2.0","method":"Player.GetItem","params":[1,["file"]],"id":18}]
>>> response = requests.post(url, headers=headers, data=json.dumps(data))
>>> result = response.json()
>>>
>>>
>>>
>>> print(result[0])
{'id': 17, 'jsonrpc': '2.0', 'result': {'time': {'hours': 0, 'milliseconds': 416, 'minutes': 52, 'seconds': 59}}}
>>>
>>>
>>>
>>> print(result[1])
{'id': 18, 'jsonrpc': '2.0', 'result': {'item': {'file': 'smb://192.168.1.10/n filmek 720p/@.mkv', 'id': 340, 'label': 'The Expendables 3', 'type': 'movie'}}}
>>>
>>>ez alapján akkor kiderült, hogy a [0]-ban van a time és [1]-esben pedig az item
amit példának írtál szerintem azt valahogy rosszul használom
>>> import json
>>> import base64
>>> import requests
>>>
>>> credentials = b'kodi:kodi'
>>> encoded_credentials = base64.b64encode(credentials)
>>> authorization = b'Basic ' + encoded_credentials
>>> headers = { 'Content-Type': 'application/json', 'Authorization': authorization }
>>> url = 'http://192.168.1.10:8080/jsonrpc?Base'
>>> data = [
... {"jsonrpc":"2.0","method":"Player.GetProperties","params":[1,["time"]],"id":17},
... {"jsonrpc":"2.0","method":"Player.GetItem","params":[1,["file"]],"id":18}]
>>> response = requests.post(url, headers=headers, data=json.dumps(data))
>>> result = response.json()
>>> print(result)
[{'id': 17, 'jsonrpc': '2.0', 'result': {'time': {'hours': 0, 'milliseconds': 416, 'minutes': 52, 'seconds': 59}}}, {'id': 18, 'jsonrpc': '2.0', 'result': {'item': {'file': 'smb://192.168.1.10/n filmek 720p/@.mkv', 'id': 340, 'label': 'The Expendables 3', 'type': 'movie'}}}]
>>> for i in result:
... if i['result'].get('time'):
... mytime = i['result']['time']
... if i['result'].get('item'):
... myfile = i['result']['item']['file']
... print(mytime)
File "<stdin>", line 6
print(mytime)
^
SyntaxError: invalid syntax
>>> print(myfile)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'myfile' is not defined
Új hozzászólás Aktív témák
- Nagyon szép,megkímélt Asus 15,6",Intel(2,58Ghz)Hibátlan Működésű,nagyon jó akku,NO SSD,NO TÖLTŐ
- Thinkpad X13 Gen4 13.3" FHD+ IPS i7-1365U 16GB 256GB NVMe ujjlolv gar
- SAPPHIRE RX 9070 XT 16GB GDDR6 PULSE GAMING - Új, 2 év gari - Eladó!
- ThinkPad X13 Gen5 13.3" FHD+ IPS Ultra 5 135U 16GB 256GB NVMe magyar vbill ujjolv IR kam gar
- MSI MAG 321UPX QD-OLED Gamer Monitor!32"/4k/240hz/0,03MS/G-sync -Freesync/Konzolhoz is!Beszámítok!
- Lenovo LEGION 5 PRO Ultra 9 275HX 32GB RAM 1TB SSD RTX 5070 Ti 12GB 16" QHD+ OLED 3év Prémium GAR
- HIBÁTLAN iPhone 12 Pro 128GB Gold-1 ÉV GARANCIA - Kártyafüggetlen, MS4441, 100% Akksi
- HP ProBook 650 G5 - i5 8265U, 8-16GB RAM, SSD, jó akku, számla, 6 hó gar
- ÚJ 15" Microsoft Surface Laptop 7 X Elite 16GB 512GB
- AKCIÓ! LENOVO ThinkPad P15 Gen 1 munkaállomás - i7 10750H 16GB DDR4 256GB SSD Quadro T1000 W11
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
