本文整理汇总了Python中common.DataObjects.ListItem类的典型用法代码示例。如果您正苦于以下问题:Python ListItem类的具体用法?Python ListItem怎么用?Python ListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ping
def ping(request_obj, response_obj):
Container().ga_client.reportAction('ping')
response_obj.addServiceResponseParam("response", "pong")
response_obj.addServiceResponseParam("message", "Hi there, I am PlayIt")
item = ListItem()
item.set_next_action_name('pong')
response_obj.addListItem(item)
示例2: addYeahLiveItem
def addYeahLiveItem(request_obj, response_obj):
yeahfilepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=False)
if AddonUtils.doesFileExist(yeahfilepath):
yeah_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='YEAH.png')
item = ListItem()
item.set_next_action_name('Yeah_TV')
xbmcListItem = xbmcgui.ListItem(label='[B]YEAH[/B] STREAMS', iconImage=yeah_icon_filepath, thumbnailImage=yeah_icon_filepath)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
示例3: retrieveIndVideoLinks
def retrieveIndVideoLinks(request_obj, response_obj):
video_source_id = 0
video_source_img = None
video_part_index = 0
video_playlist_items = []
contentDiv = BeautifulSoup.SoupStrainer('p', {'style':re.compile(r'\bcenter\b')})
soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=contentDiv)
for child in soup.findChildren():
if child.name == 'img':
if len(video_playlist_items) > 0:
response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
video_source_id = video_source_id + 1
video_source_img = child['src']
video_part_index = 0
video_playlist_items = []
elif child.name == 'a':
video_part_index = video_part_index + 1
video_link = {}
video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) + ' | ' + child.getText()
video_link['videoLink'] = str(child['href'])
video_playlist_items.append(video_link)
item = ListItem()
item.add_request_data('videoLink', video_link['videoLink'])
item.add_request_data('videoTitle', video_link['videoTitle'])
item.set_next_action_name('SnapAndPlayVideo')
xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
if len(video_playlist_items) > 0:
response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
示例4: displayFavouriteTVShows
def displayFavouriteTVShows(request_obj, response_obj):
addonContext = Container().getAddonContext()
filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=FAV_TV_SHOWS_JSON_FILE, makeDirs=True)
try:
if AddonUtils.doesFileExist(filepath):
favTVShowsJsonObj = AddonUtils.getJsonFileObj(filepath)
if len(favTVShowsJsonObj) == 0:
d = xbmcgui.Dialog()
d.ok('No Favourites added yet!', 'Please use context menu on TV Show to add new favourite.', '')
for tvShowName in favTVShowsJsonObj:
tvShowInfo = favTVShowsJsonObj[tvShowName]
item = ListItem()
item.add_request_data('tvShowName', tvShowInfo['tvShowName'])
item.add_request_data('tvShowUrl', tvShowInfo['tvShowUrl'])
item.set_next_action_name('Show_Episodes')
xbmcListItem = xbmcgui.ListItem(label=unicode(tvShowInfo['tvShowName']).encode("utf-8"))
contextMenuItems = []
data = '?actionId=' + urllib.quote_plus("remove_Fav_TVShow") + '&data=' + urllib.quote_plus(AddonUtils.encodeData({"tvShowName":tvShowInfo['tvShowName'], "tvShowUrl":tvShowInfo['tvShowUrl']}))
contextMenuItems.append(('Remove favourite', 'XBMC.RunPlugin(%s?%s)' % (sys.argv[0], data)))
xbmcListItem.addContextMenuItems(contextMenuItems, replaceItems=True)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
else:
d = xbmcgui.Dialog()
d.ok('No favourites added yet!', 'Please use context menu on TV Show to add new favourite.', '')
except:
AddonUtils.deleteFile(filepath)
d = xbmcgui.Dialog()
d.ok('FAILED to display TV Shows', 'Please add favorite again.')
示例5: retrieveVideoLinks
def retrieveVideoLinks(request_obj, response_obj):
video_source_id = 1
video_source_img = None
video_source_name = None
video_part_index = 0
video_playlist_items = []
ignoreAllLinks = False
content = BeautifulSoup.SoupStrainer('blockquote', {'class':re.compile(r'\bpostcontent\b')})
soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=content)
for e in soup.findAll('br'):
e.extract()
Logger.logDebug(soup)
if soup.has_key('div'):
soup = soup.findChild('div', recursive=False)
prevChild = ''
prevAFont = None
for child in soup.findChildren():
if (child.name == 'img' or child.name == 'b' or (child.name == 'font' and not child.findChild('a'))):
if (child.name == 'b' and prevChild == 'a') or (child.name == 'font' and child == prevAFont):
continue
else:
if len(video_playlist_items) > 0:
response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_source_name, video_playlist_items))
if video_source_img is not None:
video_source_id = video_source_id + 1
video_source_img = None
video_source_name = None
video_part_index = 0
video_playlist_items = []
ignoreAllLinks = False
elif not ignoreAllLinks and child.name == 'a' and not re.search('multi', str(child['href']), re.IGNORECASE):
video_part_index = video_part_index + 1
video_link = {}
video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) + ' | ' + child.getText()
video_link['videoLink'] = str(child['href'])
try:
try:
__prepareVideoLink__(video_link)
except Exception, e:
Logger.logFatal(e)
video_hosting_info = SnapVideo.findVideoHostingInfo(video_link['videoLink'])
if video_hosting_info is None or video_hosting_info.get_video_hosting_name() == 'UrlResolver by t0mm0':
raise
video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image()
video_link['videoSourceName'] = video_hosting_info.get_video_hosting_name()
video_playlist_items.append(video_link)
video_source_img = video_link['videoSourceImg']
video_source_name = video_link['videoSourceName']
item = ListItem()
item.add_request_data('videoLink', video_link['videoLink'])
item.add_request_data('videoTitle', video_link['videoTitle'])
item.set_next_action_name('SnapAndPlayVideo')
xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
prevAFont = child.findChild('font')
except:
示例6: __preparePlayListItem__
def __preparePlayListItem__(video_source_id, video_source_img, video_playlist_items):
item = ListItem()
item.add_request_data('videoPlayListItems', video_playlist_items)
item.set_next_action_name('SnapAndDirectPlayList')
item.add_moving_data('isContinuousPlayItem', True)
xbmcListItem = xbmcgui.ListItem(label='[COLOR blue]' + AddonUtils.getBoldString('Continuous Play') + '[/COLOR]' + ' | ' + 'Source #' + str(video_source_id) + ' | ' + 'Parts = ' + str(len(video_playlist_items)) , iconImage=video_source_img, thumbnailImage=video_source_img)
item.set_xbmc_list_item_obj(xbmcListItem)
return item
示例7: displayMovies
def displayMovies(request_obj, response_obj):
url = request_obj.get_data()['movieCategoryUrl']
print "indisplay" + url
if request_obj.get_data().has_key('page'):
url_parts = url.split('?')
url_part_A = ''
url_part_B = ''
if len(url_parts) == 2:
url_part_A = url_parts[0]
url_part_B = '?' + url_parts[1]
else:
url_part_A = url
if url_part_A[len(url_part_A) - 1] != '/':
url_part_A = url_part_A + '/'
url = url_part_A + 'page/' + request_obj.get_data()['page'] + url_part_B
contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'})
soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv)
movieTags = soup.findChildren('div', {'class':'post'})
print "intags" + str(movieTags)
if len(movieTags) == 0:
movieTags = soup.findChildren('div', {'class':'videopost'})
for movieTag in movieTags:
item = __retrieveAndCreateMovieItem__(movieTag)
response_obj.addListItem(item)
response_obj.set_xbmc_content_type('movies')
try:
pagesInfoTag = soup.findChild('div', {'class':'navigation'})
current_page = int(pagesInfoTag.find('span', {'class':'page current'}).getText())
#print current_page
pages = pagesInfoTag.findChildren('a', {'class':'page'})
#print pages
last_page = int(pages[len(pages) - 1].getText())
if current_page < last_page:
for page in range(current_page + 1, last_page + 1):
createItem = False
if page == last_page:
pageName = AddonUtils.getBoldString(' -> Last Page #' + str(page))
createItem = True
elif page <= current_page + 4:
pageName = AddonUtils.getBoldString(' -> Page #' + str(page))
createItem = True
if createItem:
item = ListItem()
item.add_request_data('movieCategoryUrl', request_obj.get_data()['movieCategoryUrl'])
item.add_request_data('page', str(page))
item.set_next_action_name('Movies_List_Next_Page')
xbmcListItem = xbmcgui.ListItem(label=pageName)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
except: pass
示例8: displayMenuItems
def displayMenuItems(request_obj, response_obj):
# TV Shows item
onDemand_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='onDemand.png')
item = ListItem()
item.set_next_action_name('On_Demand')
xbmcListItem = xbmcgui.ListItem(label='TV ON DEMAND', iconImage=onDemand_icon_filepath, thumbnailImage=onDemand_icon_filepath)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
# LIVE TV item
live_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='live.png')
item = ListItem()
item.set_next_action_name('Live')
xbmcListItem = xbmcgui.ListItem(label='LIVE TV', iconImage=live_icon_filepath, thumbnailImage=live_icon_filepath)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
示例9: retrieveVideoLinks
def retrieveVideoLinks(request_obj, response_obj):
video_source_id = 1
video_source_img = None
video_part_index = 0
video_playlist_items = []
ignoreAllLinks = False
content = BeautifulSoup.SoupStrainer('blockquote', {'class':re.compile(r'\bpostcontent\b')})
soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=content)
if soup.has_key('div'):
soup = soup.findChild('div', recursive=False)
prevChild = ''
for child in soup.findChildren():
if child.name == 'img' or child.name == 'font'or child.name == 'b' :
if child.name == 'b' and prevChild == 'a':
continue
else:
if len(video_playlist_items) > 0:
response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
if video_source_img is not None:
video_source_id = video_source_id + 1
video_source_img = None
video_part_index = 0
video_playlist_items = []
ignoreAllLinks = False
elif not ignoreAllLinks and child.name == 'a' and not re.search('multi', str(child['href']), re.IGNORECASE):
video_part_index = video_part_index + 1
video_link = {}
video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) + ' | ' + child.getText()
video_link['videoLink'] = str(child['href'])
try:
__prepareVideoLink__(video_link)
video_playlist_items.append(video_link)
video_source_img = video_link['videoSourceImg']
item = ListItem()
item.add_request_data('videoLink', video_link['videoLink'])
item.add_request_data('videoTitle', video_link['videoTitle'])
item.set_next_action_name('SnapAndPlayVideo')
xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
except:
print 'Unable to recognize a source = ' + video_link['videoLink']
video_source_img = None
video_part_index = 0
video_playlist_items = []
ignoreAllLinks = True
prevChild = child.name
if len(video_playlist_items) > 0:
response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
示例10: prepareVideoItem
def prepareVideoItem(request_obj, response_obj):
item = ListItem()
item.add_moving_data('videoUrl', request_obj.get_data()['videoLink'])
item.set_next_action_name('Play')
xbmcListItem = xbmcgui.ListItem(label=request_obj.get_data()['videoTitle'])
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
示例11: playChannel
def playChannel(request_obj, response_obj):
item = ListItem()
item.set_next_action_name('Play')
item.add_moving_data('videoStreamUrl', request_obj.get_data()['channelUrl'])
xbmcListItem = xbmcgui.ListItem(label=request_obj.get_data()['channelName'], iconImage=request_obj.get_data()['channelLogo'], thumbnailImage=request_obj.get_data()['channelLogo'])
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
示例12: __retrieveAndCreateMovieItem__
def __retrieveAndCreateMovieItem__(movieTag):
thumbTag = movieTag.findChild('div', {'class':'thumbnail'})
imgUrl = ''
if thumbTag is not None:
aTag = thumbTag.findChild('a')
imgTag = aTag.findChild('img')
imgUrl = imgTag['src']
titleTag = movieTag.findChild('h2')
aTag = titleTag.findChild('a')
movieUrl = str(aTag['href'])
title = unicode(titleTag.getText()).encode('utf8').replace('’', '\'').replace('&', '&').replace('…', '...')
descTag = movieTag.findChild('div', {'class':'entry'})
desc = ''
if descTag is not None:
desc = unicode(descTag.getText()).encode('utf8').replace('’', '\'').replace('&', '&').replace('…', '...')
rating = 0.0
ratingTag = movieTag.findChild('div', {'class':'post-ratings'})
if ratingTag is not None:
ratingInfo = ratingTag.getText()
ratingFound = re.compile('average:(.+?)out of 5').findall(ratingInfo)
if len(ratingFound) > 0:
rating = float(ratingFound[0])
rating = (rating / 5) * 10
item = ListItem()
item.set_next_action_name('Movie_VLinks')
item.add_request_data('movieUrl', movieUrl)
xbmcListItem = xbmcgui.ListItem(label=title, iconImage=imgUrl, thumbnailImage=imgUrl)
xbmcListItem.setInfo('video', {'plot':desc, 'plotoutline':desc, 'title':title, 'originaltitle':title, 'rating':rating})
item.set_xbmc_list_item_obj(xbmcListItem)
return item
示例13: displayMovies
def displayMovies(request_obj, response_obj):
url = request_obj.get_data()["movieCategoryUrl"]
if request_obj.get_data().has_key("page"):
url_parts = url.split("?")
url_part_A = ""
url_part_B = ""
if len(url_parts) == 2:
url_part_A = url_parts[0]
url_part_B = "?" + url_parts[1]
else:
url_part_A = url
if url_part_A[len(url_part_A) - 1] != "/":
url_part_A = url_part_A + "/"
url = url_part_A + "page/" + request_obj.get_data()["page"] + url_part_B
contentDiv = BeautifulSoup.SoupStrainer("div", {"id": "content"})
soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv)
movieTags = soup.findChildren("div", {"class": "post"})
for movieTag in movieTags:
item = __retrieveAndCreateMovieItem__(movieTag)
response_obj.addListItem(item)
response_obj.set_xbmc_content_type("movies")
pagesInfoTag = soup.findChild("div", {"class": "navigation"})
print pagesInfoTag
current_page = int(pagesInfoTag.find("span", {"class": "page current"}).getText())
print current_page
pages = pagesInfoTag.findChildren("a", {"class": "page"})
print pages
last_page = int(pages[len(pages) - 1].getText())
if current_page < last_page:
for page in range(current_page + 1, last_page + 1):
createItem = False
if page == last_page:
pageName = AddonUtils.getBoldString(" -> Last Page #" + str(page))
createItem = True
elif page <= current_page + 4:
pageName = AddonUtils.getBoldString(" -> Page #" + str(page))
createItem = True
if createItem:
item = ListItem()
item.add_request_data("movieCategoryUrl", request_obj.get_data()["movieCategoryUrl"])
item.add_request_data("page", str(page))
item.set_next_action_name("Movies_List_Next_Page")
xbmcListItem = xbmcgui.ListItem(label=pageName)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
示例14: displayChannels
def displayChannels(request_obj, response_obj):
channels = request_obj.get_data()['channels']
for channelName in channels:
channelInfo = channels[channelName]
channelUrl = channelInfo['channelUrl']
channelLogo = channelInfo['channelLogo']
item = ListItem()
item.set_next_action_name('play_Live_Channel')
item.add_request_data('channelName', channelName)
item.add_request_data('channelLogo', channelLogo)
item.add_request_data('channelUrl', channelUrl)
xbmcListItem = xbmcgui.ListItem(label=channelName, iconImage=channelLogo, thumbnailImage=channelLogo)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
response_obj.set_xbmc_sort_method(xbmcplugin.SORT_METHOD_LABEL)
示例15: displayChannels
def displayChannels(request_obj, response_obj):
filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE)
channelsList = AddonUtils.getJsonFileObj(filepath)
for channelUrl in channelsList:
if request_obj.get_data()['category'] == channelsList[channelUrl]['category']:
channelName = channelsList[channelUrl]['channel']
channelLogo = channelsList[channelUrl]['thumb']
item = ListItem()
item.set_next_action_name('play_Live_Channel')
item.add_request_data('channelName', channelName)
item.add_request_data('channelLogo', channelLogo)
item.add_request_data('channelUrl', channelUrl)
xbmcListItem = xbmcgui.ListItem(label=channelName, iconImage=channelLogo, thumbnailImage=channelLogo)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
response_obj.set_xbmc_sort_method(xbmcplugin.SORT_METHOD_LABEL)