def updateToken(self): http = mc.Http() http.SetHttpHeader("X-Plex-Platform", "Boxee") http.SetHttpHeader("X-Plex-Platform-Version", mc.GetInfoString("System.BuildVersion")) http.SetHttpHeader("X-Plex-Provides", "player") http.SetHttpHeader("X-Plex-Product", "Plexee") http.SetHttpHeader("X-Plex-Version", "1.0") try: http.SetHttpHeader("X-Plex-Device", mc.GetPlatform()) except: http.SetHttpHeader("X-Plex-Device", "Boxee") try: http.SetHttpHeader("X-Plex-Client-Identifier", mc.GetDeviceId()) except: http.SetHttpHeader("X-Plex-Client-Identifier", str(uuid.getnode())) base64String = base64.encodestring( "%s:%s" % (self.username, self.password)).replace('\n', '') http.SetHttpHeader("Authorization", "Basic %s" % base64String) postData = "username=%s&password=%s" % (self.username, self.password) data = http.Post(MyPlexService.AUTH_URL, postData) http.Reset() if data: tree = ElementTree.fromstring(data) self.authenticationToken = tree.findtext("authentication-token", None)
def set_watched(command): list = mc.GetWindow(10483).GetList(52) item = list.GetItem(1) series = mc.GetInfoString("Container(52).ListItem.TVShowTitle") db_path = xbmc.translatePath('special://profile/Database/') itemList = list.GetItems() seasons = [] episodes_count = 0 for item in itemList: season = item.GetSeason() if(season != -1): seasons.append(season) episodes_count = episodes_count + 1 seasons = dict.fromkeys(seasons) seasons = seasons.keys() use_season = -1 display_name = series season_string = "" if(len(seasons) == 1): display_name = "Season %s" % (seasons[0]) season_string = " %s" % display_name use_season = seasons[0] dialog = xbmcgui.Dialog() if dialog.yesno("Watched", "Do you want to mark all episodes of %s%s as %s?" % (series, season_string, command)): progress = xbmcgui.DialogProgress() progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) current_count = 0 info_count = 0 sql = ".timeout 100000;\n" for item in itemList: episode = item.GetEpisode() boxeeid = mc.GetInfoString("Container(52).ListItem("+str(info_count)+").Property(boxeeid)") info_count = info_count + 1 print boxeeid if(episode != -1): current_count = current_count+1 percent = int( ( episodes_count / current_count ) * 100) message = "Episode " + str(current_count) + " out of " + str(episodes_count) progress.update( percent, "", message, "" ) path = item.GetPath() # First make sure we don't get double values in the DB, so remove any old ones sql = sql + "DELETE FROM watched WHERE strPath = \""+path+"\" or (strBoxeeId != \"\" AND strBoxeeId = \""+boxeeid+"\");\n" if command == "watched": sql = sql + "INSERT INTO watched VALUES(null, \""+path+"\", \""+boxeeid+"\", 1, 0, -1.0);\n" file_put_contents("/tmp/sqlinject", sql) os.system('cat /tmp/sqlinject | /data/hack/bin/sqlite3 ' + db_path + 'boxee_user_catalog.db') xbmc.executebuiltin("Container.Update") xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin("Window.Refresh") progress.close() xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") # progress = xbmcgui.DialogProgress() # progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) # # for x in range(0, 10): # time.sleep(1); # xbmc.executebuiltin("Container.Update") # xbmc.executebuiltin("Container.Refresh") # xbmc.executebuiltin("Window.Refresh") # # progress.close() # # xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") xbmc.executebuiltin("Notification(,%s marked as %s...,2000)" % (display_name, command))
def set_watched(command): lst = get_list(52, False) count = 10 while lst == "" and count > 0: time.sleep(0.1) lst = get_list(52, False) count = count - 1 if lst == "": pass else: item = lst.GetItem(1) series = mc.GetInfoString("Container(52).ListItem.TVShowTitle") itemList = lst.GetItems() seasons = [] episodes_count = 0 for item in itemList: season = item.GetSeason() if(season != -1): seasons.append(season) episodes_count = episodes_count + 1 seasons = dict.fromkeys(seasons) seasons = seasons.keys() use_season = -1 display_name = series season_string = "" if(len(seasons) == 1): season_string = " Season %s" % (seasons[0]) use_season = seasons[0] dialog = xbmcgui.Dialog() if dialog.yesno("Watched", "Do you want to mark all episodes of %s%s as %s?" % (series, season_string, command)): progress = xbmcgui.DialogProgress() progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) current_count = 0 info_count = 0 db_path = xbmc.translatePath('special://profile/Database/') + "./boxee_user_catalog.db" conn = sqlite.connect(db_path, 100000) c = conn.cursor() for item in itemList: episode = item.GetEpisode() boxeeid = mc.GetInfoString("Container(52).ListItem("+str(info_count)+").Property(boxeeid)") info_count = info_count + 1 print boxeeid if(episode != -1): current_count = current_count+1 percent = int( ( episodes_count / current_count ) * 100) message = "Episode " + str(current_count) + " out of " + str(episodes_count) progress.update( percent, "", message, "" ) path = item.GetPath() # First make sure we don't get double values in the DB, so remove any old ones sql = "DELETE FROM watched WHERE strPath = \""+str(path).strip()+"\" or (strBoxeeId != \"\" AND strBoxeeId = \""+str(boxeeid).strip()+"\");" c.execute(sql) if command == "watched": sql = "INSERT INTO watched VALUES(null, \""+path+"\", \""+boxeeid+"\", 1, 0, -1.0);" c.execute(sql) c.execute("REINDEX;") conn.commit() c.close() conn.close() lst = get_list(52, False) if lst != "": lst.Refresh() xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") progress.close() mc.ShowDialogNotification("%s marked as %s..." % (display_name, command))
def grab_fanart_list(listNum, special): global fanart_changed get_fanart_list(False) # sometimes the list control isn't available yet onload # so add some checking to make sure lst = common.get_list(listNum, special) count = 10 while lst == "" and count > 0: time.sleep(0.25) lst = common.get_list(listNum, special) count = count - 1 window = common.get_window_id(special) if lst == "": pass else: # as long as the list exists (while the window exists) # the list gets updated at regular intervals. otherwise # the fanart disappears when you change sort-orders or # select a genre # should have very little overhead because all the values # get cached in memory focusedItem = "" while 1: # don't spend any time doing stuff if a dialog is open # 9999 is the dialog number when no dialogs are open # if special == True then the scanning is happening in # a dialog so we DO continue processing if xbmcgui.getCurrentWindowDialogId() == 9999 or special: theItem = mc.GetInfoString("Container(%s).ListItem.Label" % listNum) theItem = str(theItem) if theItem != "": newFocusedItem = theItem else: newFocusedItem = focusedItem if (newFocusedItem != focusedItem and newFocusedItem != "") or (newFocusedItem == "" and special): lst = common.get_list(listNum, special) if lst != "": items = lst.GetItems() if len(items) > 0: if newFocusedItem == "": newFocusedItem = items[0].GetLabel() for item in items: grab_fanart_for_item(item) focusedItem = newFocusedItem del items if window != common.get_window_id(special): return time.sleep(2) # store the fanart list for next time if the list # was modified if fanart_changed == 1: store_fanart_list()
def focus_last_unwatched(listNum): global fanart_changed jumpenabled = get_jump_to_last_unwatched_value() if jumpenabled == "0": return # sometimes the list control isn't available yet onload # so add some checking to make sure lst = get_list(listNum, False) prevLen = 0 count = 10 while count > 0: time.sleep(0.1) lst = get_list(listNum, False) count = count - 1 if lst != "": newLen = len(lst.GetItems()) if newLen != prevLen: count = 5 prevLen = newLen if lst == "" or len(lst.GetItems()) <= 2: pass else: item = lst.GetItem(1) items = lst.GetItems() lastItem = items[-1] more = 1 reverse = 0 if item.GetSeason() < lastItem.GetSeason(): reverse = 1 if item.GetSeason() == lastItem.GetSeason() and item.GetEpisode() < lastItem.GetEpisode(): reverse = 1 if item.GetSeason() == 1 and item.GetEpisode() == 1: reverse = 1 if reverse == 0: info_count = 0 focus = info_count for item in items: watched = "%s" % mc.GetInfoString("Container(52).ListItem("+str(info_count)+").Property(watched)") info_count = info_count + 1 if watched == "0" and info_count > focus and more == 1: focus = info_count if watched == "1": more = 0 else: info_count = len(items) - 1 focus = info_count for item in items: watched = "%s" % mc.GetInfoString("Container(52).ListItem("+str(info_count)+").Property(watched)") if watched == "0" and info_count < focus and more == 1: focus = info_count + 1 info_count = info_count - 1 if watched == "1": more = 0 # make sure the list still exists lst = get_list(listNum, False) if lst != "": lst.SetFocusedItem(focus)