def downloads(parameters): refreshToken() headers = { "Authorization": "Bearer " + str(xbmcaddon.Addon('script.realdebrid').getSetting('rd_access')) } extras = ast.literal_eval(parameters['extras']) data = {"offset": extras['offset'], "limit": extras['limit']} r = requests.get("https://api.real-debrid.com/rest/1.0/downloads", data=data, headers=headers, verify=False) links = json.loads(r.text) menu = [] for item in links: menu.append({ "title": item['filename'], "url": item['download'], "mode": 10, "poster": os.path.join(home, '', 'icon.png'), "icon": os.path.join(home, '', 'icon.png'), "fanart": os.path.join(home, '', 'fanart.jpg'), "type": "video", "plot": item['host'], "isFolder": False, "playable": False, "method": "downloads", "id": item['id'] }) util.addMenuItems(menu)
def torrents(parameters): refreshToken() headers = { "Authorization": "Bearer " + str(xbmcaddon.Addon('script.realdebrid').getSetting('rd_access')) } extras = ast.literal_eval(parameters['extras']) data = { "offset": extras['offset'], "limit": extras['limit'], "filter": "active" } r = requests.get("https://api.real-debrid.com/rest/1.0/torrents", data=data, headers=headers, verify=False) links = json.loads(r.text) #util.logError(str(links)) menu = [] for item in links: if item['status'] == "downloaded": #util.logError(str(torrentsInfo(item['id']))) name = item['filename'] url = item['links'][0] mode = 5 elif item['status'] == "downloading": name = "[Downloading " + str( item['progress']) + "%] " + item['filename'] url = "" mode = "" else: name = "[" + item['status'] + "] " + item['filename'] url = "" mode = "" #util.logError("..>"+name) menu.append({ "title": name, "url": url, "mode": mode, "poster": os.path.join(home, '', 'icon.png'), "icon": os.path.join(home, '', 'icon.png'), "fanart": os.path.join(home, '', 'fanart.jpg'), "type": "video", "plot": item['host'], "method": "torrent", "id": item['id'], "isFolder": False, "playable": False, "download": True }) util.addMenuItems(menu)
"isFolder": False }) else: up.append({ "title": "[COLOR green]" + host[0] + "[/COLOR]", "url": "", "mode": "", "poster": host[1]['image_big'], "icon": host[1]['image_big'], "fanart": os.path.join(home, '', 'fanart.jpg'), "type": "video", "plot": "", "isFolder": False }) util.addMenuItems(down + up) elif mode == 10: util.playMedia(parameters['name'], parameters['icon'], parameters['url'], force=True) elif mode == 12: rd.download(parameters) elif mode == 13: rd.delID(parameters) elif mode == 14: rd.addMagent1(parameters) elif mode == 15: rd.addMagent2(parameters) elif mode == 16: rd.addMagent3(parameters)