本文整理汇总了Python中common.DataObjects.ListItem.add_request_data方法的典型用法代码示例。如果您正苦于以下问题:Python ListItem.add_request_data方法的具体用法?Python ListItem.add_request_data怎么用?Python ListItem.add_request_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.DataObjects.ListItem
的用法示例。
在下文中一共展示了ListItem.add_request_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: retrieveIndVideoLinks
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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))
示例2: __retrieveAndCreateMovieItem__
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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
示例3: displayFavouriteTVShows
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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.')
示例4: __preparePlayListItem__
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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')
xbmcListItem = xbmcgui.ListItem(label=AddonUtils.getBoldString('DirectPlay') + ' | ' + '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
示例5: retrieveVideoLinks
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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: displayMovies
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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
示例7: __preparePlayListItem__
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
def __preparePlayListItem__(video_source_id, video_source_img, video_source_name, 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)
item.add_moving_data('videoSourceName', video_source_name)
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
示例8: retrieveVideoLinks
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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))
示例9: retrieveUserPlaylists
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
def retrieveUserPlaylists(userId, pageNbr=0, maxCount=50):
url = 'http://gdata.youtube.com/feeds/api/users/' + userId + '/playlists?alt=json&v=2&max-results=' + str(maxCount) + '&start-index=' + str((pageNbr * maxCount) + 1)
jData = json.loads(HttpUtils.HttpClient().getHtmlContent(url))
entries = jData['feed']['entry']
items = []
for entry in entries:
playlistId = unicode(entry['yt$playlistId']['$t']).encode('utf-8')
title = unicode(entry['title']['$t']).encode('utf-8')
thumbnail = unicode(entry['media$group']['media$thumbnail'][1]['url']).encode('utf-8')
item = ListItem()
item.add_request_data('userId', userId)
item.add_request_data('playlistId', playlistId)
item.set_next_action_name('show_Playlist_Videos')
xbmcListItem = xbmcgui.ListItem(label=title, iconImage=thumbnail, thumbnailImage=thumbnail)
item.set_xbmc_list_item_obj(xbmcListItem)
items.append(item)
if(len(items) == maxCount):
item = ListItem()
item.add_request_data('userId', userId)
item.add_request_data('pageNbr', pageNbr + 1)
item.set_next_action_name('show_Playlists')
xbmcListItem = xbmcgui.ListItem(label='---- Next Page ---->')
item.set_xbmc_list_item_obj(xbmcListItem)
items.append(item)
return items
示例10: retrieveUserPlaylistVideos
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
def retrieveUserPlaylistVideos(playlistId, pageNbr=0, maxCount=50):
url = 'http://gdata.youtube.com/feeds/api/playlists/' + playlistId + '?alt=json&v=2&max-results=' + str(maxCount) + '&start-index=' + str((pageNbr * maxCount) + 1)
jData = json.loads(HttpUtils.HttpClient().getHtmlContent(url))
entries = jData['feed']['entry']
items = []
for entry in entries:
videoId = entry['media$group']['yt$videoid']['$t']
title = unicode(entry['title']['$t']).encode('utf-8')
thumbnail = 'http://i.ytimg.com/vi/' + videoId + '/default.jpg'
item = ListItem()
item.add_request_data('videoLink', 'http://www.youtube.com/watch?v=' + videoId + '&')
item.add_request_data('videoTitle', title)
item.set_next_action_name('play_Video')
xbmcListItem = xbmcgui.ListItem(label=title, iconImage=thumbnail, thumbnailImage=thumbnail)
item.set_xbmc_list_item_obj(xbmcListItem)
items.append(item)
if(len(items) == maxCount):
item = ListItem()
item.add_request_data('playlistId', playlistId)
item.add_request_data('pageNbr', pageNbr + 1)
item.set_next_action_name('show_Playlist_Videos')
xbmcListItem = xbmcgui.ListItem(label='---- Next Page ---->')
item.set_xbmc_list_item_obj(xbmcListItem)
items.append(item)
return items
示例11: __retrieveEventMatches__
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
def __retrieveEventMatches__(eventTarget):
url = FIXTURE_URL + 'target=' + eventTarget
print url
soup = HttpUtils.HttpClient().getBeautifulSoup(url)
items = []
for row in soup.findChildren(name='tr'):
rowClass = row['class']
if re.search('tableHeading', rowClass):
continue
title = ''
matchLinks = {}
next_action_name = ''
if((not row.has_key('toggler')) or (row['toggler'] != 'yes')):
matchCols = row.findChildren('td')
localMatchDate = 'Date Not Fixed!!'
try:
matchDate = re.compile('CXGetLocalDateTime(.+?);').findall(matchCols[0].getText())[0]
datetime_obj = None
try:
datetime_obj = time.strptime(matchDate, "('%m/%d/%Y %H:%M:%S %Z')")
except ValueError:
datetime_obj = time.strptime(matchDate, "('%d %b %Y %H:%M %Z')")
localMatchDate = time.strftime('(%a, %b %d %Y %I:%M %p)', time.localtime(calendar.timegm(datetime_obj)))
except Exception, e:
logging.exception(e)
title = ' ' + localMatchDate + ' ' + unicode(matchCols[1].getText()).encode('utf-8')
next_action_name = 'Match_Links'
for matchLink in matchCols[2].findChildren('a'):
iconSrc = unicode(matchLink.img['src']).encode('utf-8')
if re.search('live.png', iconSrc):
matchLinks['LIVE'] = unicode(matchLink['href']).encode('utf-8')
elif re.search('replay.png', iconSrc):
matchLinks['Replay'] = unicode(matchLink['href']).encode('utf-8')
elif re.search('Scorebaord.png', iconSrc):
matchLinks['Scoreboard'] = unicode(matchLink['href']).encode('utf-8')
elif re.search('highlights.png', iconSrc):
matchLinks['Highlights'] = unicode(matchLink['href']).encode('utf-8')
else:
title = '[COLOR blue][B]' + row.findChild('td').getText() + '[/B][/COLOR]'
next_action_name = 'Series'
cricket_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=Container().getAddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='cricket-icon.png')
item = ListItem()
item.add_request_data('matchLinks', matchLinks)
item.set_next_action_name(next_action_name)
xbmcListItem = xbmcgui.ListItem(label=title, iconImage=cricket_icon_filepath, thumbnailImage=cricket_icon_filepath)
item.set_xbmc_list_item_obj(xbmcListItem)
items.append(item)
示例12: displayMovies
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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)
示例13: displayChannels
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
def displayChannels(request_obj, response_obj):
addonContext = Container().getAddonContext()
item = ListItem()
item.set_next_action_name('add_Channel')
youtube_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='Add_New_YouTube_V1.png')
xbmcListItem = xbmcgui.ListItem(label='Add New Channel', iconImage=youtube_icon_filepath, thumbnailImage=youtube_icon_filepath)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
filepath = AddonUtils.getCompleteFilePath(baseDirPath=addonContext.addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True)
if not AddonUtils.doesFileExist(filepath):
new_items = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveYouTubeUserInfo__'), PRE_LOADED_CHANNELS, 'Loading default list of channels...', 'Remove the channel you hate in default list using context menu.')
index = 0
channelsJsonObj = {}
for username in PRE_LOADED_CHANNELS:
channelsJsonObj[username] = new_items[index]
index = index + 1
AddonUtils.saveObjToJsonFile(filepath, channelsJsonObj)
try:
channelsJsonObj = AddonUtils.getJsonFileObj(filepath)
print 'CHANNELS JSON LOADED'
if len(channelsJsonObj) == 0:
d = xbmcgui.Dialog()
if d.yesno('NO channels added yet!', 'Would you like to add YouTube channel right now?', 'Get username from YouTube URL.'):
isAdded = addNewChannel(request_obj, response_obj)
if not isAdded:
return
else:
channelsJsonObj = AddonUtils.getJsonFileObj(filepath)
for channelUsername in channelsJsonObj:
userInfo = channelsJsonObj[channelUsername]
item = ListItem()
item.add_request_data('userId', channelUsername)
item.set_next_action_name('show_Channel')
xbmcListItem = xbmcgui.ListItem(label=unicode(userInfo['title']).encode("utf-8"), iconImage=userInfo['thumbnail'], thumbnailImage=userInfo['thumbnail'])
contextMenuItems = []
data = '?actionId=' + urllib.quote_plus("remove_YouTube_Channel") + '&data=' + urllib.quote_plus(AddonUtils.encodeData({"userId":channelUsername}))
contextMenuItems.append(('Remove channel', 'XBMC.RunPlugin(%s?%s)' % (sys.argv[0], data)))
xbmcListItem.addContextMenuItems(contextMenuItems, replaceItems=False)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
except:
raise
AddonUtils.deleteFile(filepath)
print 'MY CHANNELS CORRUPT FILE DELETED = ' + filepath
示例14: displayChannels
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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
# 需要导入模块: from common.DataObjects import ListItem [as 别名]
# 或者: from common.DataObjects.ListItem import add_request_data [as 别名]
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)