本文整理汇总了Python中common.XBMCInterfaceUtils类的典型用法代码示例。如果您正苦于以下问题:Python XBMCInterfaceUtils类的具体用法?Python XBMCInterfaceUtils怎么用?Python XBMCInterfaceUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XBMCInterfaceUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __loginAndSaveCookieStore__
def __loginAndSaveCookieStore__(cookieStore):
AddonUtils.deleteFile(cookieStore)
email = Container().getAddonContext().addon.getSetting("email")
password = Container().getAddonContext().addon.getSetting("password")
if email == None or email == "" or password == None or password == "":
d = xbmcgui.Dialog()
d.ok(
"Welcome to Willow TV",
"Watch LIVE CRICKET on your favorite Willow TV.",
"Please provide your login details for both",
"Willow TV and YouTube.",
)
Container().getAddonContext().addon.openSettings(sys.argv[0])
return False
params = {"Email": email, "Password": password, "KeepSigned": "true", "LoginFormSubmit": "true"}
html = HttpUtils.HttpClient().getHtmlContent(LOGIN_URL, params)
HttpUtils.HttpClient().saveCookiesToFile(cookieStore)
match = re.compile("Error: Your email or password is incorrect").findall(html)
if len(match) > 0:
XBMCInterfaceUtils.displayDialogMessage(
"Login Failure", "Error: Your email or password is incorrect.", "Please verify your login details."
)
return False
else:
return True
示例2: prepareVideoLinkForPlayable
def prepareVideoLinkForPlayable(request_obj, response_obj):
items = response_obj.get_item_list()
playable_items = []
for item in items:
if item.get_next_action_name() == 'Play':
playable_items.append(item)
if len(playable_items) > 0:
XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__prepareVideoLink__'), playable_items, 'Preparing video link', 'Failed to retrieve video information, please try again later')
示例3: addEmbeddedVideoInfoInPlayableItems
def addEmbeddedVideoInfoInPlayableItems(request_obj, response_obj):
items = response_obj.get_item_list()
playable_items = []
for item in items:
if item.get_next_action_name() == 'Play':
playable_items.append(item)
try:
XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__addEmbeddedVideoInfo_in_item__'), playable_items, 'Retrieving video info', 'Failed to retrieve video information, please try again later')
except Exception, e:
Logger.logFatal(e)
示例4: addVideoInfoInPlayableItems
def addVideoInfoInPlayableItems(request_obj, response_obj):
items = response_obj.get_item_list()
playable_items = []
for item in items:
if item.get_next_action_name() == 'Play':
playable_items.append(item)
try:
XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__addVideoInfo_in_item'), playable_items, 'Retrieving video info', failure_message=None)
except Exception, e:
Logger.logFatal(e)
示例5: showUserUploads
def showUserUploads(request_obj, response_obj):
try:
items = None
if request_obj.get_data().has_key('pageNbr'):
items = retrieveUserUploads(request_obj.get_data()['userId'], request_obj.get_data()['pageNbr'])
else:
items = retrieveUserUploads(request_obj.get_data()['userId'])
response_obj.set_item_list(items)
except:
XBMCInterfaceUtils.displayDialogMessage('No video items found!', 'This channel does not contain any video items.')
示例6: start
def start(addon_id, addon_ver=None):
try:
Logger.logDebug(sys.argv)
global __addon_id__
__addon_id__ = addon_id
__addon_ver__ = addon_ver
containerObj = Container(addon_id=addon_id, addon_ver=addon_ver)
action_id = containerObj.getTurtleRequest().get_action_id()
containerObj.performAction(action_id)
except urllib2.URLError, e:
Logger.logFatal(e)
XBMCInterfaceUtils.displayDialogMessage('Unable to connect', 'Please choose a different source if available in add-on.', 'Website used in add-on is down, try to access using web browser.', 'Please share logs with developer if problem keeps coming!')
示例7: __prepareVideoSourceLinks__
def __prepareVideoSourceLinks__(videoSourceLinks, source):
new_items = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__prepareVideoLink__'), videoSourceLinks, 'Retrieving streaming links for source #' + source, 'Failed to retrieve stream information, please try again later')
if len(new_items) == 0:
XBMCInterfaceUtils.displayDialogMessage('No video items found!', 'Unable to resolve video items from source #' + source, 'Continuing with next source...')
return []
count = 0
for item in new_items:
xbmcItem = item.get_xbmc_list_item_obj()
count = count + 1
xbmcItem.setLabel('Source #' + source + ' | ' + xbmcItem.getLabel() + str(count))
new_items.append(__preparePlayListItem__(new_items, source))
return new_items
示例8: displayLinks
def displayLinks(request_obj, response_obj):
if not request_obj.get_data()['isLoginSuccess']:
return
matchLinks = request_obj.get_data()['matchLinks']
if len(matchLinks) == 0:
XBMCInterfaceUtils.displayDialogMessage('Match not started yet', 'Error: This match is not started.', 'Please verify match schedule.')
return
d = xbmcgui.Dialog()
index = d.select('What do you wanna watch:', matchLinks.keys())
key = matchLinks.keys()[index]
print 'SELECTED : ' + key
url = matchLinks[key]
soup = HttpUtils.HttpClient().getBeautifulSoup(url)
print soup
示例9: displayChannels
def displayChannels(request_obj, response_obj):
content = BeautifulSoup.SoupStrainer('div', {'class':re.compile(r'\bchannels\b')})
soup = HttpClient().getBeautifulSoup(url='http://www.watchsuntv.com/play', parseOnlyThese=content)
channels = soup.findAll('li', {'class':'channel-info'})
list_items = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__displayChannels__'), channels, 'Preparing channel items', 'Failed to retrieve channel information, please try again later')
response_obj.extendItemList(list_items)
response_obj.set_xbmc_sort_method(xbmcplugin.SORT_METHOD_LABEL)
示例10: displayRecentMovies
def displayRecentMovies(request_obj, response_obj):
contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'sub-sidebar'})
soup = HttpClient().getBeautifulSoup(url='http://www.pinoymovie.co/', parseOnlyThese=contentDiv)
soup = soup.findChild('div', {'class':'right'})
movieLinkTags = soup.findChildren('a')
recentMoviesItems = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveRecentMovies__'), movieLinkTags, 'Retrieving recent movies and its information', 'Failed to retrieve video information, please try again later', line1='Takes about 5 minutes')
response_obj.extendItemList(recentMoviesItems)
示例11: __processAndAddVideoInfo__
def __processAndAddVideoInfo__(item, data):
video_info = findVideoInfo(data)
if video_info is None:
raise Exception(ExceptionHandler.VIDEO_PARSER_NOT_FOUND, 'Video information is not found. Please check other sources.')
if video_info.is_video_stopped():
raise Exception(ExceptionHandler.VIDEO_STOPPED, 'Video is either removed or not found. Please check other links.')
XBMCInterfaceUtils.updateListItem_With_VideoInfo(video_info, item.get_xbmc_list_item_obj())
qual = int(AddonContext().addon.getSetting('playbackqual'))
video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_HD_1080)
if video_strm_link == None or qual != 0:
video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_HD_720)
if video_strm_link == None or qual == 2:
video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_SD)
if video_strm_link == None:
video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_LOW)
item.get_moving_data()['videoStreamUrl'] = video_strm_link
示例12: start
def start(addon_id, service_name, context_root, default_port, allowed_port_range):
server = None
try:
sys.argv = None # To handle the situations where some library expects system arguments. Main change made for t0mm0 urlresolver library.
global __addon_id__
global __registered_services__
global __context_root__
global __port__
global __port_range__
global __service_name__
__addon_id__ = addon_id
__context_root__ = context_root
__port__ = default_port
__port_range__ = allowed_port_range
__service_name__ = service_name
containerObj = Container(addon_id=addon_id)
iconimage = AddonUtils.getCompleteFilePath(baseDirPath=containerObj.getAddonContext().addonPath, filename='icon.png')
serviceport = int(containerObj.getAddonContext().addon.getSetting('serviceport'))
XBMCInterfaceUtils.setSuppressDialogMsg(True)
if serviceport < __port_range__[0] or serviceport > __port_range__[1] :
containerObj.getAddonContext().addon.setSetting('serviceport', str(__port__))
serviceport = __port__
XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service: Port updated', 'Service port set to default value 8181', iconimage=iconimage)
server = JSONRPCServer(context_root=__context_root__, server_port=serviceport)
server.registerService('serviceName', serviceMethod)
defined_services = containerObj.getAddonContext().getTurtleServices()
if len(defined_services) == 0:
Logger.logError(__service_name__ + ' Service :: There are no services defined for registration, end this service program now.')
return
for service in defined_services:
server.registerService(service.get_service_name(), serviceMethod)
__registered_services__[service.get_service_name()] = service.get_action_id()
Logger.logInfo(__service_name__ + ' Service :: service registered = %s @ %s' % (service.get_service_name(), __context_root__))
server.start()
# XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service has started', 'Use web browser PlayIt extension to play video.', iconimage=iconimage)
while not xbmc.abortRequested:
time.sleep(1)
Logger.logInfo(__service_name__ + ' Service :: ABORT request received from XBMC. PlayIt service will stop now.')
except Exception, e:
Logger.logFatal(__service_name__ + ' Service :: ERROR OCCURRED: ' + str(e))
ExceptionHandler.handle(e)
示例13: playRawAudio
def playRawAudio(request_obj, response_obj):
pbType = int(Container().getAddonContext().addon.getSetting('playbacktype'))
Container().ga_client.reportAction('audio')
if XBMCInterfaceUtils.isPlayingVideo():
response_obj.addServiceResponseParam("status", "error")
response_obj.addServiceResponseParam("title", "Stop active video!")
response_obj.addServiceResponseParam("message", "Note: XBMC cannot play audio when video playback is in progress.")
item = ListItem()
item.set_next_action_name('respond')
response_obj.addListItem(item)
elif pbType == 2 and XBMCInterfaceUtils.isPlaying():
response_obj.addServiceResponseParam("status", "error")
response_obj.addServiceResponseParam("title", "XBMC is already playing.")
response_obj.addServiceResponseParam("message", "Check PlayIt Service add-on settings. Your this request is ignored.")
item = ListItem()
item.set_next_action_name('respond')
response_obj.addListItem(item)
else:
if pbType == 0:
XBMCInterfaceUtils.stopPlayer()
if not XBMCInterfaceUtils.isPlaying():
XBMCInterfaceUtils.clearPlayList(list_type="audio")
response_obj.addServiceResponseParam("message", "Enjoy your music!")
else:
response_obj.addServiceResponseParam("title", "Request Enqueued!")
response_obj.addServiceResponseParam("message", "Your request has been added to player queue.")
item = ListItem()
item.get_moving_data()['audioStreamUrl'] = request_obj.get_data()['track_link']
item.set_next_action_name('Play')
xbmcListItem = xbmcgui.ListItem(label=request_obj.get_data()['track_title'], iconImage=request_obj.get_data()['track_artwork_url'], thumbnailImage=request_obj.get_data()['track_artwork_url'])
xbmcListItem.setInfo('music', {'title':request_obj.get_data()['track_title']})
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)
response_obj.addServiceResponseParam("status", "success")
示例14: serviceMethod
def serviceMethod(name, **params):
actionId = __registered_services__[name]
data = {'data':AddonUtils.encodeData(params)}
service_response_obj = None
try:
containerObj = Container(addon_id=__addon_id__)
iconimage = AddonUtils.getCompleteFilePath(baseDirPath=containerObj.getAddonContext().addonPath, filename='icon.png')
XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service', 'Processing received request...', iconimage=iconimage)
containerObj.reloadTurtleRequest(data)
containerObj.performAction(actionId)
service_response_obj = containerObj.getTurtleResponse().get_service_response_obj()
except Exception, e:
print __service_name__ + ' Service :: ERROR OCCURRED: ' + str(e)
ExceptionHandler.handle(e)
service_response_obj = {"status":"exception", "message":"an unexpected error occurred, please check your input"}
XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service', 'Error while processing your request', time='5000')
示例15: retieveMovieStreams
def retieveMovieStreams(request_obj, response_obj):
soup = None
if request_obj.get_data().has_key('movieInfoUrl'):
html = HttpUtils.HttpClient().getHtmlContent(url=(BASE_WSITE_URL + request_obj.get_data()['movieInfoUrl'][3:]))
soup = BeautifulSoup.BeautifulSoup(html)
elif request_obj.get_data().has_key('moviePageUrl'):
contentDiv = BeautifulSoup.SoupStrainer('div', {'dir':'ltr'})
soup = HttpUtils.HttpClient().getBeautifulSoup(url=request_obj.get_data()['moviePageUrl'], parseOnlyThese=contentDiv)
if soup == None:
return
videoSourceLink = None
scriptTags = []
for row in soup('script', {'type':'text/javascript'}):
if re.search('jwplayer', ''.join(row.contents)):
jwplayer = ''.join(row.contents)
m_obj = re.search(r'({.*})', jwplayer)
if m_obj:
jwplayerStr = m_obj.group(1).replace("'", "\"")
matches = re.search('"file": "(.+?)"', jwplayerStr, re.IGNORECASE)
if matches:
videoSourceLink = matches.group(1)
break
XBMCInterfaceUtils.displayDialogMessage('Do you know?', 'The content of this add-on is from www.einthusan.com.', 'Please help Einthusan by visiting his website regularly.', 'The developer has no relation with www.einthusan.com. OK to proceed!', msgType='[B]INFO & REQUEST: [/B]')
item = ListItem()
item.set_next_action_name('Play')
item.get_moving_data()['videoStreamUrl'] = videoSourceLink
xbmcListItem = xbmcgui.ListItem(label=request_obj.get_data()['movieTitle'])
if(request_obj.get_data().has_key('videoInfo')):
meta = request_obj.get_data()['videoInfo']
xbmcListItem.setIconImage(meta['thumb_url'])
xbmcListItem.setThumbnailImage(meta['cover_url'])
xbmcListItem.setInfo('video', meta)
item.set_xbmc_list_item_obj(xbmcListItem)
response_obj.addListItem(item)