def updateVideoRefreshRate(self, themePlayList):
# Check if the setting is enabled to switch the refresh rate
if not Settings.blockRefreshRateChange():
self.original_refreshrate = 0
return
log("ThemePlayer: Checking for update of refresh rate")
try:
# Check if we have any videos in the PlayList
hasVideoFiles = True
i = 0
while i < themePlayList.size():
if Settings.isVideoFile(themePlayList[i].getfilename()):
hasVideoFiles = True
break
i = i + 1
if hasVideoFiles:
# Save off the existing refresh setting
jsonresponse = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Settings.GetSettingValue", "params": { "setting": "videoplayer.adjustrefreshrate" }, "id": 1}')
data = simplejson.loads(jsonresponse)
if 'result' in data:
if 'value' in data['result']:
self.original_refreshrate = data['result']['value']
# Check if the refresh rate is currently set
log("ThemePlayer: Video refresh rate currently set to %d" % self.original_refreshrate)
# Check if the refresh rate is currently set, if it is, then we need
if self.original_refreshrate != 0:
# Disable the refresh rate setting
log("ThemePlayer: Disabling refresh rate")
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": { "setting": "videoplayer.adjustrefreshrate", "value": 0 }, "id": 1}')
except:
log("ThemePlayer: Failed to process video refresh")
def AddArtToLibrary(type, media, folder, limit, silent=False):
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.Get%ss", "params": {"properties": ["art", "file"], "sort": { "method": "label" } }, "id": 1}' % media.lower())
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if (json_response['result'] is not None) and ('%ss' % (media.lower()) in json_response['result']):
# iterate through the results
if not silent:
progressDialog = xbmcgui.DialogProgress(ADDON_LANGUAGE(32016))
progressDialog.create(ADDON_LANGUAGE(32016))
for count, item in enumerate(json_response['result']['%ss' % media.lower()]):
if not silent:
if progressDialog.iscanceled():
return
path = os.path.join(media_path(item['file']).encode("utf-8"), folder)
file_list = xbmcvfs.listdir(path)[1]
for i, file in enumerate(file_list):
if i + 1 > limit:
break
if not silent:
progressDialog.update((count * 100) / json_response['result']['limits']['total'], ADDON_LANGUAGE(32011) + ' %s: %s %i' % (item["label"], type, i + 1))
if progressDialog.iscanceled():
return
# just in case someone uses backslahes in the path
# fixes problems mentioned on some german forum
file_path = os.path.join(path, file).encode('string-escape')
if xbmcvfs.exists(file_path) and item['art'].get('%s%i' % (type, i), '') == "":
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.Set%sDetails", "params": { "%sid": %i, "art": { "%s%i": "%s" }}, "id": 1 }' %
(media, media.lower(), item.get('%sid' % media.lower()), type, i + 1, file_path))
def getNowPlaying(self):
# Get the active player
result = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}')
result = unicode(result, 'utf-8', errors='ignore')
self.logMsg("Got active player " + result, 2)
result = json.loads(result)
# Seems to work too fast loop whilst waiting for it to become active
while not result["result"]:
result = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}')
result = unicode(result, 'utf-8', errors='ignore')
self.logMsg("Got active player " + result, 2)
result = json.loads(result)
if 'result' in result and result["result"][0] is not None:
playerid = result["result"][0]["playerid"]
# Get details of the playing media
self.logMsg("Getting details of now playing media", 1)
result = xbmc.executeJSONRPC(
'{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"playerid": ' + str(
playerid) + ', "properties": ["showtitle", "tvshowid", "episode", "season", "playcount","genre"] } }')
result = unicode(result, 'utf-8', errors='ignore')
self.logMsg("Got details of now playing media" + result, 2)
result = json.loads(result)
return result
def getRecentEpisodes(tagname,limit):
#if the addon is called with recentepisodes parameter, we return the recentepisodes list of the given tagname
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
# First we get a list of all the TV shows - filtered by tag
json_query_string = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "sort": { "order": "descending", "method": "dateadded" }, "properties": [ "title","sorttitle" ], "filter": {"operator": "contains", "field": "tag", "value": "%s"} }, "id": "libTvShows"}' %tagname)
json_result = json.loads(json_query_string)
# If we found any, put all tv show id's in a list
if json_result.has_key('result') and json_result['result'].has_key('tvshows'):
alltvshowIds = list()
for tvshow in json_result['result']['tvshows']:
alltvshowIds.append(tvshow["tvshowid"])
alltvshowIds = set(alltvshowIds)
#get all recently added episodes
json_query2 = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "sort": {"order": "descending", "method": "dateadded"}, "filter": {"field": "playcount", "operator": "lessthan", "value":"1"}, "properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime", "cast", "writer", "dateadded", "lastplayed" ]}, "limits":{"end":%d}, "id": "1"}' %limit)
count = 0
if json_query2:
json_query2 = json.loads(json_query2)
if json_query2.has_key('result') and json_query2['result'].has_key('episodes'):
for item in json_query2['result']['episodes']:
if item["tvshowid"] in alltvshowIds:
liz = createListItem(item)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
count += 1
if count == limit:
break
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
def RefreshPVR(m3uPath, epgPath, logoPath, forceUpdate=False, forceUpdateIPTV=False):
if forceUpdateIPTV or common.getAutoIPTV():
UpdateIPTVSimpleSettings(m3uPath, epgPath, logoPath)
kodi16 = True if common.GetKodiVer() < 17 else False
if Addon.getSetting("autoPVR") == "true":
if (not json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.GetAddonDetails","params":{"addonid":"pvr.iptvsimple", "properties": ["enabled"]},"id":1}'))['result']['addon']['enabled'] or (kodi16 and not json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"pvrmanager.enabled"},"id":1}'))['result']['value'])):
tvOption = common.GetMenuSelected(localizedString(30317).encode('utf-8'), [localizedString(30318).encode('utf-8'), localizedString(30319).encode('utf-8')])
if tvOption != 0:
if tvOption == 1:
Addon.setSetting("useIPTV", "False")
return False
isIPTVnotRestarted = not EnableIptvClient() and not kodi16
isPVRnotRestarted = kodi16 and not EnablePVR()
if isIPTVnotRestarted and forceUpdate:
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":false},"id":1}')
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":true},"id":1}')
#iptvAddon = GetIptvAddon()
#if iptvAddon is None:
# return False
#iptvAddon.setSetting("m3uPathType", iptvAddon.getSetting("m3uPathType"))
if isPVRnotRestarted:
xbmc.executebuiltin('StopPVRManager')
xbmc.executebuiltin('StartPVRManager')
return True
else:
return False
def alphabetletter(self):
"""used with the alphabet scrollbar to jump to a letter"""
if KODI_VERSION > 16:
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
letter = self.params.get("letter", "").upper()
jumpcmd = ""
if letter in ["A", "B", "C", "2"]:
jumpcmd = "2"
elif letter in ["D", "E", "F", "3"]:
jumpcmd = "3"
elif letter in ["G", "H", "I", "4"]:
jumpcmd = "4"
elif letter in ["J", "K", "L", "5"]:
jumpcmd = "5"
elif letter in ["M", "N", "O", "6"]:
jumpcmd = "6"
elif letter in ["P", "Q", "R", "S", "7"]:
jumpcmd = "7"
elif letter in ["T", "U", "V", "8"]:
jumpcmd = "8"
elif letter in ["W", "X", "Y", "Z", "9"]:
jumpcmd = "9"
if jumpcmd:
xbmc.executebuiltin("SetFocus(50)")
for i in range(40):
xbmc.executeJSONRPC(
'{ "jsonrpc": "2.0", "method": "Input.ExecuteAction",\
"params": { "action": "jumpsms%s" }, "id": 1 }'
% (jumpcmd)
)
xbmc.sleep(50)
if xbmc.getInfoLabel("ListItem.Sortletter").upper() == letter:
break
请发表评论