本文整理匯總了Python中resources.lib.kodion.items.DirectoryItem.set_image方法的典型用法代碼示例。如果您正苦於以下問題:Python DirectoryItem.set_image方法的具體用法?Python DirectoryItem.set_image怎麽用?Python DirectoryItem.set_image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類resources.lib.kodion.items.DirectoryItem
的用法示例。
在下文中一共展示了DirectoryItem.set_image方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_root
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_root(self, context, re_match):
result = []
# favorites
if len(context.get_favorite_list().list()) > 0:
fav_item = kodion.items.FavoritesItem(context, fanart=self.get_fanart(context))
fav_item.set_name('[B]%s[/B]' % fav_item.get_name())
result.append(fav_item)
pass
# watch later
if len(context.get_watch_later_list().list()) > 0:
watch_later_item = kodion.items.WatchLaterItem(context, fanart=self.get_fanart(context))
result.append(watch_later_item)
pass
# list channels
for channel_id in self._channel_ids:
channel_config = Client.CHANNELS[channel_id]
channel_id = channel_config['id']
channel_title = channel_config['title']
channel_item = DirectoryItem(channel_title, context.create_uri([channel_id, 'formats']))
channel_item.set_fanart(context.create_resource_path('media', channel_id, 'background.jpg'))
channel_item.set_image(context.create_resource_path('media', channel_id, 'logo.png'))
result.append(channel_item)
pass
# search
search_item = kodion.items.SearchItem(context, image=context.create_resource_path('media', 'search.png'),
fanart=self.get_fanart(context))
result.append(search_item)
return result
示例2: _do_formats
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def _do_formats(self, context, json_formats):
result = []
formats = json_formats.get("items", [])
# show only free videos if not logged in or or the setting is enabled
show_only_free_videos = not self.is_logged_in() and context.get_settings().get_bool(
"nowtv.videos.only_free", False
)
for format_data in formats:
if show_only_free_videos and not format_data["free"]:
continue
format_title = format_data["title"]
params = {}
if format_data.get("seoUrl", ""):
params["seoUrl"] = format_data["seoUrl"]
pass
format_item = DirectoryItem(
format_title,
# /rtl/format/2/
context.create_uri([format_data["station"], "format", str(format_data["id"])], params),
)
format_item.set_image(format_data["images"]["thumb"])
format_item.set_fanart(format_data["images"]["fanart"])
result.append(format_item)
if self.is_logged_in():
if context.get_path() == "/nowtv/favorites/list/":
context_menu = [
(
context.localize(self._local_map["nowtv.remove_from_favs"]),
"RunPlugin(%s)"
% context.create_uri(["nowtv", "favorites", "delete"], {"format_id": format_data["id"]}),
)
]
pass
else:
context_menu = [
(
context.localize(self._local_map["nowtv.add_to_favs"]),
"RunPlugin(%s)"
% context.create_uri(["nowtv", "favorites", "add"], {"format_id": format_data["id"]}),
)
]
pass
else:
context_menu = [
(
context.localize(self._local_map["nowtv.add_to_favs"]),
"RunPlugin(%s)"
% context.create_uri(
[kodion.constants.paths.FAVORITES, "add"], {"item": kodion.items.to_jsons(format_item)}
),
)
]
pass
format_item.set_context_menu(context_menu)
pass
return result
示例3: on_root
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_root(self, context, re_match):
result = []
client = self.get_client(context)
if self.is_logged_in():
# online favorites
fav_item = DirectoryItem('[B]%s[/B]' % context.localize(kodion.constants.localize.FAVORITES),
context.create_uri(['nowtv', 'favorites', 'list']),
image=context.create_resource_path('media/favorites.png'),
fanart=self.get_fanart(context))
result.append(fav_item)
# online watch later
wl_item = DirectoryItem('[B]%s[/B]' % context.localize(kodion.constants.localize.WATCH_LATER),
context.create_uri(['nowtv', 'watch_later', 'list']),
image=context.create_resource_path('media/watch_later.png'),
fanart=self.get_fanart(context))
result.append(wl_item)
pass
else:
# offline favorites
if len(context.get_favorite_list().list()) > 0:
fav_item = kodion.items.FavoritesItem(context, fanart=self.get_fanart(context))
fav_item.set_name('[B]%s[/B]' % fav_item.get_name())
result.append(fav_item)
pass
# offline watch later
if len(context.get_watch_later_list().list()) > 0:
wl_item = kodion.items.WatchLaterItem(context, fanart=self.get_fanart(context))
wl_item.set_name('[B]%s[/B]' % wl_item.get_name())
result.append(wl_item)
pass
pass
# watch later
if len(context.get_watch_later_list().list()) > 0:
watch_later_item = kodion.items.WatchLaterItem(context, fanart=self.get_fanart(context))
result.append(watch_later_item)
pass
# list channels
for channel_id in self._channel_ids:
channel_config = Client.CHANNELS[channel_id]
channel_id = channel_config['id']
channel_title = channel_config['title']
channel_item = DirectoryItem(channel_title, context.create_uri([channel_id, 'formats']))
channel_item.set_fanart(context.create_resource_path('media', channel_id, 'background.jpg'))
channel_item.set_image(context.create_resource_path('media', channel_id, 'logo.png'))
result.append(channel_item)
pass
# search
search_item = kodion.items.SearchItem(context, image=context.create_resource_path('media', 'search.png'),
fanart=self.get_fanart(context))
result.append(search_item)
return result
示例4: on_channel_format
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_channel_format(self, context, re_match):
channel_id = re_match.group("channel_id")
format_id = re_match.group("format_id")
channel_config = Client.CHANNELS[channel_id]
client = self.get_client(context)
# try to process tabs
seo_url = context.get_param("seoUrl", "")
if not seo_url:
raise KodionException("seoUrl missing")
format_tabs = client.get_format_tabs(channel_config, seo_url)
# only on season tab -> show the content directly
if len(format_tabs) == 1 and format_tabs[0]["type"] == "tab":
format_tab = format_tabs[0]
return self._on_channel_format_list(context, channel_config, format_tab["id"])
# show the tabs/sections
tabs = []
for format_tab in format_tabs:
if format_tab["type"] == "tab":
tab_item = DirectoryItem(
format_tab["title"],
# /[CHANNEL_ID]/format/[FORMAT_ID]/list/[FORMAT_LIST_ID]/
context.create_uri([channel_id, "format", format_id, "list", str(format_tab["id"])]),
)
tab_item.set_image(format_tab["images"]["thumb"])
tab_item.set_fanart(format_tab["images"]["fanart"])
tabs.append(tab_item)
pass
elif format_tab["type"] == "date-span":
tab_title = format_tab["title"]
image = format_tab["images"]["thumb"]
fanart = format_tab["images"]["fanart"]
tab_item = DirectoryItem(
tab_title,
# /[CHANNEL_ID]/format/[FORMAT_ID]/year/[YEAR]/
context.create_uri(
[channel_id, "format", format_id, "year", tab_title],
{"start": format_tab["start"], "end": format_tab["end"], "image": image, "fanart": fanart},
),
)
tab_item.set_image(image)
tab_item.set_fanart(fanart)
tabs.append(tab_item)
pass
else:
raise KodionException('Unknown type "%s" for tab' % format_tab["type"])
pass
return tabs
示例5: on_channel_format
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_channel_format(self, context, re_match):
channel_id = re_match.group('channel_id')
format_id = re_match.group('format_id')
channel_config = Client.CHANNELS[channel_id]
client = self.get_client(context)
# try to process tabs
seo_url = context.get_param('seoUrl', '')
if not seo_url:
raise KodionException('seoUrl missing')
format_tabs = client.get_format_tabs(channel_config, seo_url)
# only on season tab -> show the content directly
if len(format_tabs) == 1 and format_tabs[0]['type'] == 'tab':
format_tab = format_tabs[0]
return self._on_channel_format_list(context, channel_config, format_tab['id'])
# show the tabs/sections
tabs = []
for format_tab in format_tabs:
if format_tab['type'] == 'tab':
tab_item = DirectoryItem(format_tab['title'],
# /[CHANNEL_ID]/format/[FORMAT_ID]/list/[FORMAT_LIST_ID]/
context.create_uri(
[channel_id, 'format', format_id, 'list', str(format_tab['id'])]))
tab_item.set_image(format_tab['images']['thumb'])
tab_item.set_fanart(format_tab['images']['fanart'])
tabs.append(tab_item)
pass
elif format_tab['type'] == 'date-span':
tab_title = format_tab['title']
image = format_tab['images']['thumb']
fanart = format_tab['images']['fanart']
tab_item = DirectoryItem(tab_title,
# /[CHANNEL_ID]/format/[FORMAT_ID]/year/[YEAR]/
context.create_uri([channel_id, 'format', format_id, 'year', tab_title],
{'start': format_tab['start'],
'end': format_tab['end'],
'image': image,
'fanart': fanart}))
tab_item.set_image(image)
tab_item.set_fanart(fanart)
tabs.append(tab_item)
pass
else:
raise KodionException('Unknown type "%s" for tab' % format_tab['type'])
pass
return tabs
示例6: on_root
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_root(self, context, re_match):
result = []
# watch later
if len(context.get_watch_later_list().list()) > 0:
watch_later_item = DirectoryItem(
"[B]" + context.localize(constants.localize.WATCH_LATER) + "[/B]",
context.create_uri([constants.paths.WATCH_LATER, "list"]),
image=context.create_resource_path("media", "watch_later.png"),
)
watch_later_item.set_fanart(self.get_fanart(context))
result.append(watch_later_item)
pass
# search
search_item = DirectoryItem(
"[B]" + context.localize(constants.localize.SEARCH) + "[/B]",
context.create_uri([constants.paths.SEARCH, "list"]),
image=context.create_resource_path("media", "search.png"),
)
search_item.set_fanart(self.get_fanart(context))
result.append(search_item)
# "Neu bei Netzkino/DZANGO"
config = self._client.get_config()
category_id = str(config["new"]["id"])
category_item = DirectoryItem(
u"[B]%s[/B]" % config["new"]["title"], context.create_uri(["category", category_id])
)
category_image_url = config["category_image_url"]
if category_image_url:
category_item.set_image(category_image_url % category_id)
pass
category_item.set_fanart(self.get_fanart(context))
result.append(category_item)
# categories
categories = context.get_function_cache().get(FunctionCache.ONE_DAY, self._client.get_categories)
for category in categories:
category_id = str(category["id"])
category_item = DirectoryItem(category["title"], context.create_uri(["category", category_id]))
category_image_url = config["category_image_url"]
if category_image_url:
category_item.set_image(category_image_url % category_id)
pass
category_item.set_fanart(self.get_fanart(context))
result.append(category_item)
pass
return result, {self.RESULT_CACHE_TO_DISC: False}
示例7: on_root
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_root(self, context, re_match):
result = []
# watch later
if len(context.get_watch_later_list().list()) > 0:
watch_later_item = DirectoryItem('[B]' + context.localize(constants.localize.WATCH_LATER) + '[/B]',
context.create_uri([constants.paths.WATCH_LATER, 'list']),
image=context.create_resource_path('media', 'watch_later.png'))
watch_later_item.set_fanart(self.get_fanart(context))
result.append(watch_later_item)
pass
# search
search_item = DirectoryItem('[B]' + context.localize(constants.localize.SEARCH) + '[/B]',
context.create_uri([constants.paths.SEARCH, 'list']),
image=context.create_resource_path('media', 'search.png')
)
search_item.set_fanart(self.get_fanart(context))
result.append(search_item)
# "Neu bei Netzkino/DZANGO"
config = self._client.get_config()
category_id = str(config['new']['id'])
category_item = DirectoryItem(u'[B]%s[/B]' % config['new']['title'],
context.create_uri(['category', category_id]))
category_image_url = config['category_image_url']
if category_image_url:
category_item.set_image(category_image_url % category_id)
pass
category_item.set_fanart(self.get_fanart(context))
result.append(category_item)
# categories
categories = context.get_function_cache().get(FunctionCache.ONE_DAY, self._client.get_categories)
for category in categories:
category_id = str(category['id'])
category_item = DirectoryItem(category['title'],
context.create_uri(['category', category_id]))
category_image_url = config['category_image_url']
if category_image_url:
category_item.set_image(category_image_url % category_id)
pass
category_item.set_fanart(self.get_fanart(context))
result.append(category_item)
pass
return result, {self.RESULT_CACHE_TO_DISC: False}
示例8: _feed_to_item
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def _feed_to_item(self, json_data, context):
result = []
data = json_data['data']['data']
for item in data:
gallery_item = DirectoryItem(item['title'],
context.create_uri(['show', str(item['id'])]))
gallery_item.set_fanart(self.get_fanart(context))
image = item.get('thumbnails', [])
if len(image) > 0:
image = image[0].get('url', '')
gallery_item.set_image(image)
pass
result.append(gallery_item)
pass
return result
示例9: _do_formats
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def _do_formats(self, context, json_formats):
result = []
formats = json_formats.get('items', [])
# show only free videos if not logged in or or the setting is enabled
show_only_free_videos = not self.is_logged_in() or context.get_settings().get_bool('nowtv.videos.only_free',
False)
for format_data in formats:
if show_only_free_videos and not format_data['free']:
continue
format_title = format_data['title']
params = {}
if format_data.get('seoUrl', ''):
params['seoUrl'] = format_data['seoUrl']
pass
format_item = DirectoryItem(format_title,
# /rtl/format/2/
context.create_uri([format_data['station'], 'format', str(format_data['id'])],
params))
format_item.set_image(format_data['images']['thumb'])
format_item.set_fanart(format_data['images']['fanart'])
result.append(format_item)
if self.is_logged_in():
if context.get_path() == '/nowtv/favorites/list/':
context_menu = [(context.localize(self._local_map['nowtv.remove_from_favs']),
'RunPlugin(%s)' % context.create_uri(['nowtv', 'favorites', 'delete'],
{'format_id': format_data['id']}))]
pass
else:
context_menu = [(context.localize(self._local_map['nowtv.add_to_favs']),
'RunPlugin(%s)' % context.create_uri(['nowtv', 'favorites', 'add'],
{'format_id': format_data['id']}))]
pass
else:
context_menu = [(context.localize(self._local_map['nowtv.add_to_favs']),
'RunPlugin(%s)' % context.create_uri([kodion.constants.paths.FAVORITES, 'add'],
{'item': kodion.items.to_jsons(format_item)}))]
pass
format_item.set_context_menu(context_menu)
pass
return result
示例10: _do_formats
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def _do_formats(self, context, json_formats):
result = []
formats = json_formats.get('items', [])
for format_data in formats:
format_title = format_data['title']
params = {}
if format_data.get('seoUrl', ''):
params['seoUrl'] = format_data['seoUrl']
pass
format_item = DirectoryItem(format_title,
context.create_uri([format_data['station'], 'format', str(format_data['id'])], params))
format_item.set_image(format_data['images']['thumb'])
format_item.set_fanart(format_data['images']['fanart'])
result.append(format_item)
context_menu = [(context.localize(self._local_map['nowtv.add_to_favs']),
'RunPlugin(%s)' % context.create_uri([kodion.constants.paths.FAVORITES, 'add'],
{'item': kodion.items.to_jsons(format_item)}))]
format_item.set_context_menu(context_menu)
pass
return result
示例11: on_channel_format
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def on_channel_format(self, context, re_match):
channel_id = re_match.group('channel_id')
channel_config = Client.CHANNELS[channel_id]
client = self.get_client(context)
# try to process tabs
seo_url = context.get_param('seoUrl', '')
if seo_url:
format_tabs = client.get_format_tabs(channel_config, seo_url)
# with only one tab we could display the whole list of videos
if len(format_tabs) == 1:
format_tab = format_tabs[0]
return self._on_channel_format_list(context, channel_config, format_tab['id'])
# show the tabs/sections
tabs = []
for format_tab in format_tabs:
if format_tab['type'] == 'season' or format_tab['type'] == 'year':
tab_item = DirectoryItem(format_tab['title'],
context.create_uri([channel_id, 'formatlist', str(format_tab['id'])]))
tab_item.set_image(format_tab['images']['thumb'])
tab_item.set_fanart(format_tab['images']['fanart'])
tabs.append(tab_item)
pass
elif format_tab['type'] == 'year':
tab_item = DirectoryItem(format_tab['title'],
context.create_uri([channel_id, 'yearlist', str(format_tab['id'])]))
tab_item.set_image(format_tab['images']['thumb'])
tab_item.set_fanart(format_tab['images']['fanart'])
tabs.append(tab_item)
pass
else:
raise KodionException('Unknown type "%s" for tab' % format_tab['type'])
pass
return tabs
format_id = re_match.group('format_id')
return []
示例12: _on_library
# 需要導入模塊: from resources.lib.kodion.items import DirectoryItem [as 別名]
# 或者: from resources.lib.kodion.items.DirectoryItem import set_image [as 別名]
def _on_library(self, context, re_match):
context.set_content_type(kodion.constants.content_type.TV_SHOWS)
context.add_sort_method(kodion.constants.sort_method.LABEL)
result = []
json_data = context.get_function_cache().get(FunctionCache.ONE_HOUR, self.get_client(context).get_formats)
format_list = json_data.get('result', {}).get('content', {}).get('formatlist')
for key in format_list:
now_format = format_list[key]
title = now_format['formatlong']
format_id = now_format['formatid']
free_episodes = int(now_format.get('free_episodes', '0'))
if free_episodes >= 1:
format_item = DirectoryItem(title,
context.create_uri(['format', format_id]))
# set image
image = self.get_client(context).get_config()['images']['format-thumbnail-url'].replace('%FORMAT_ID%',
format_id)
format_item.set_image(image)
# set fanart
fanart = self.get_client(context).get_config()['images']['format-fanart-url'].replace('%FORMAT_ID%',
format_id)
format_item.set_fanart(fanart)
context_menu = [(context.localize(self._local_map['now.add_to_favs']),
'RunPlugin(%s)' % context.create_uri([kodion.constants.paths.FAVORITES, 'add'],
{'item': kodion.items.to_jsons(format_item)}))]
format_item.set_context_menu(context_menu)
result.append(format_item)
pass
pass
return result