本文整理汇总了Python中resources.lib.util.xml.JenList.list_fanart方法的典型用法代码示例。如果您正苦于以下问题:Python JenList.list_fanart方法的具体用法?Python JenList.list_fanart怎么用?Python JenList.list_fanart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resources.lib.util.xml.JenList
的用法示例。
在下文中一共展示了JenList.list_fanart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_search
# 需要导入模块: from resources.lib.util.xml import JenList [as 别名]
# 或者: from resources.lib.util.xml.JenList import list_fanart [as 别名]
def do_search(term=None):
import os
import xbmc
import xbmcgui
import time
import datetime
import urllib2
import shutil
search_term = term.lower()
result = run_hook("do_search", search_term)
if result:
display_list(result, "videos")
return
jenlist = JenList("")
jenlist.list_image = xbmcaddon.Addon().getAddonInfo('icon')
theme = xbmcaddon.Addon().getSetting('theme')
if theme and theme != 'DEFAULT' and theme != 'none':
jenlist.list_fanart = jenlist.set_theme(theme)
else:
jenlist.list_fanart = xbmcaddon.Addon().getAddonInfo('fanart')
result_list = []
exact_result_list = []
item_xml_result_list = []
exact_item_xml_result_list = []
dest_file = os.path.join(xbmc.translatePath(
xbmcaddon.Addon().getSetting("cache_folder")), "search.db")
url = __builtin__.search_db_location
request = urllib2.Request(url)
response = urllib2.urlopen(request)
try:
changed = response.headers["Last-Modified"]
changed_struct = time.strptime(changed, "%a, %d %b %Y %H:%M:%S GMT")
epoch_changed = int(time.mktime(changed_struct))
if not os.path.exists(dest_file) or \
int(os.path.getmtime(dest_file)) < epoch_changed:
dp = xbmcgui.DialogProgress()
dp.create(_('Loading database file'), _('Please Wait'))
if response.getcode() == 200:
with open(dest_file, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
if os.path.getsize(dest_file) == 0:
koding.dolog("0 size db: " + repr(dest_file))
os.remove(dest_file)
dp.close()
except: # server down
if not os.path.exists(dest_file):
import xbmcgui
addon_name = xbmcaddon.Addon().getAddonInfo('name')
xbmcgui.Dialog().ok(addon_name, _("no local file found, and server seems down"))
dp.close()
response.close()
results = koding.DB_Query(dest_file, 'SELECT * from search where item like "%%%s%%"' % search_term)
for result in results:
item = jenlist.process_item(result["item"])
playlister = result["poster"]
title = item["label"].lower()
if search_term in title:
item["info"] = {}
try:
item['label'] = '{0} - {1}'.format(playlister,
item["label"])
except:
import xbmc
koding.dolog("playlister: " + repr(playlister))
koding.dolog("label:" + repr(item["lable"]))
koding.dolog("item: " + repr(item))
raise Exception()
if title.startswith(search_term + " "):
exact_result_list.append(item)
exact_item_xml_result_list.append(result["item"])
continue
result_list.append(item)
item_xml_result_list.append(result["item"])
meta = xbmcaddon.Addon().getSetting("metadata") == "true"
if meta:
# TODO find way to get it all in single cal
info = get_info(exact_item_xml_result_list)
if info:
for index, item in enumerate(exact_result_list):
item["info"].update(info[index])
info = get_info(item_xml_result_list)
if info:
for index, item in enumerate(result_list):
item["info"].update(info[index])
exact_result_list = sorted(exact_result_list,
key=lambda item: title)
exact_result_list.extend(sorted(result_list,
key=lambda item: title))
display_list(exact_result_list, "videos")