📄 plugin.py
字号:
def ParseMainList(self):
"""
Wraps the channel.ParseMainList
"""
logFile.info("Plugin::ParseMainList")
try:
# only the channelName and code is present, so ParseMainList is needed
logFile.debug("Doing ParseMainlist")
episodeItems = self.channelObject.ParseMainList()
icon = self.channelObject.icon
thumb = self.channelObject.iconLarge
ok = False
for episodeItem in episodeItems:
logFile.debug(episodeItem.url)
if episodeItem.date == '':
item = xbmcgui.ListItem(episodeItem.name, iconImage=icon, thumbnailImage=thumb)
else:
item = xbmcgui.ListItem("%s (%s)" %(episodeItem.name, episodeItem.date), iconImage=icon, thumbnailImage=thumb)
item.setInfo("video", {"date": episodeItem.date, "title": episodeItem.name, "PlotOutline": episodeItem.description})
# create item and add an extra space at the end to prevent removal of last /
ok = xbmcplugin.addDirectoryItem(self.handle, "%s?%s|%s|%s " % (self.pluginName, self.channelObject.moduleName, self.channelObject.channelCode, episodeItem.url), item, isFolder=True)
if (not ok): break
#xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_DATE)
xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
# close the directory
xbmcplugin.endOfDirectory(self.handle, ok)
except:
xbmcplugin.endOfDirectory(self.handle, False)
logFile.debug("Plugin::Error parsing mainlist", exc_info=True)
#==============================================================================
def ProcessFolderList(self):
"""
Wraps the channel.ProcessFolderList
"""
logFile.info("Plugin::ProcessFolderList Doing ProcessFolderList")
try:
# strip the extra space from the url
self.params[2] = string.strip(self.params[2])
ok = False
episodeItems = self.channelObject.ProcessFolderList(self.params[2])
logFile.debug("ProcessFolderList returned %s items", len(episodeItems))
for episodeItem in episodeItems:
#if episodeItem.date != '':
# episodeItem.name = "%s (%s)" % (episodeItem.name, episodeItem.date)
logFile.debug("Adding: %s (%s) which is a %s episodeItem and complete=%s", episodeItem.name, episodeItem.mediaurl, episodeItem.type, episodeItem.complete)
if episodeItem.type == 'folder':
item = xbmcgui.ListItem(episodeItem.name)#, self.channelObject.folderIcon, self.channelObject.folderIcon)
item.setInfo("video", {"date": episodeItem.date, "title": episodeItem.name, "PlotOutline": episodeItem.description})
ok = xbmcplugin.addDirectoryItem(self.handle, "%s?%s|%s|%s " % (self.pluginName, self.channelObject.moduleName, self.channelObject.channelCode, episodeItem.url), item, isFolder=True)
elif episodeItem.type=="video" and (episodeItem.complete == False or (episodeItem.complete == True and episodeItem.downloadable == True)):
item = xbmcgui.ListItem(episodeItem.name, iconImage=self.channelObject.icon, thumbnailImage=self.channelObject.iconLarge)
item.setInfo("video", {"date": episodeItem.date, "title": episodeItem.name, "PlotOutline": episodeItem.description})
# create serialized cListItem
pickleString = pickle.dumps(episodeItem,0)
#xbmcplugin.addDirectoryItem(self.handle, "%s?%s|%s|processVideo|%s " % (self.pluginName, self.channelObject.moduleName, self.channelObject.channelCode, pickleString), item, isFolder=False)
ok = xbmcplugin.addDirectoryItem(self.handle, "%s?%s|%s|processVideo|%s " % (self.pluginName, self.channelObject.moduleName, self.channelObject.channelCode, pickleString), item, isFolder=True)
elif episodeItem.type=="video":
item = xbmcgui.ListItem(episodeItem.name, iconImage=self.channelObject.icon, thumbnailImage=self.channelObject.iconLarge)
item.setInfo("video", {"date": episodeItem.date, "title": episodeItem.name, "PlotOutline": episodeItem.description})
ok = xbmcplugin.addDirectoryItem(int(self.handle), "%s " % (episodeItem.mediaurl), item)
else:
logFile.critical("Plugin::ProcessFolderList: Cannot determine what to add")
if (not ok): break
#xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(handle=int(self.handle), sortMethod=xbmcplugin.SORT_METHOD_DATE)
xbmcplugin.addSortMethod(handle=int(self.handle), sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(self.handle, ok)
except:
xbmcplugin.endOfDirectory(self.handle, False)
logFile.debug("Plugin::Error Processing FolderList", exc_info=True)
#==============================================================================
def ProcessVideoItem(self):
"""
Wraps the channel.UpdateVideoItem and adds an folder with videofile options like
download and play videoitem
"""
logFile.info("Plugin::ProcessVideoItem starting")
try:
# de-serialize
pickleString = self.params[3];
pickleItem = pickle.loads(pickleString)
ok = False
#logFile.debug("%s, %s, %s, %s, %s", pickleItem.name, pickleItem.url, pickleItem.description, pickleItem.mediaurl, pickleItem.complete)
episodeItem = pickleItem #common.clistItem("video", self.params[2], type="video")
if episodeItem.date != '':
episodeItem.name = "%s (%s)" % (episodeItem.name, episodeItem.date)
logFile.debug("mediaUrl=%s", episodeItem.mediaurl)
#update the item is not up to date
if episodeItem.complete==False:
logFile.debug("Trying to update a videoItem")
episodeItem =self.channelObject.UpdateVideoItem(episodeItem)
logFile.debug("mediaUrl=%s", episodeItem.mediaurl)
if episodeItem.complete==True and episodeItem.mediaurl != '':
title = "Play Item: %s " % episodeItem.name
item = xbmcgui.ListItem(title, episodeItem.name, self.channelObject.icon, self.channelObject.iconLarge)
item.setInfo("video", {"date": episodeItem.date, "title": title, "PlotOutline": episodeItem.description})
ok = xbmcplugin.addDirectoryItem(int(self.handle), "%s " % (episodeItem.mediaurl), item)
else:
logFile.error("could not update videoItem")
if episodeItem.downloadable == True:
title = "Download Item: %s" % episodeItem.name
item = xbmcgui.ListItem(title, episodeItem.name, self.channelObject.icon, self.channelObject.iconLarge)
item.setInfo("video", {"date": episodeItem.date, "title": title, "PlotOutline": episodeItem.description})
pickleString = pickle.dumps(episodeItem)
ok = xbmcplugin.addDirectoryItem(int(self.handle), "%s?%s|%s|downloadVideo|%s " % (self.pluginName, self.channelObject.moduleName, self.channelObject.channelCode, pickleString), item)
#xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_DATE)
xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(self.handle, ok)
except:
xbmcplugin.endOfDirectory(self.handle, False)
logFile.critical("Error Updating VideoItem", exc_info=True)
pass
#==============================================================================
def DownloadVideoItem(self):
"""
Warps the DownloadVideoItem method. Downloads the item, show the diffent dialogs.
"""
logFile.info("Plugin::DownloadVideoItem starting")
try:
logFile.debug("Trying to update a videoItem")
# de-serialize
pickleString = self.params[3];
pickleItem = pickle.loads(pickleString)
self.channelObject.DownloadVideoItem(pickleItem)
xbmcplugin.endOfDirectory(self.handle, True)
except:
logFile.critical("Error Downloading VideoItem", exc_info=True)
xbmcplugin.endOfDirectory(self.handle)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -