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
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')
def displayUC(request_obj, response_obj): print 'UNDER CONSTRUCTION' XBMCInterfaceUtils.displayDialogMessage( heading='UNDER Construction', line1='Please wait for update!!', line2='Enjoy HD movies for the time being.', line3='')
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')
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)
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.')
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)
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.')
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
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!')
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
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
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)
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)
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!')
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)
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")
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')
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
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)
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)
def retrieveMovies(categoryUrlSuffix): loopCount = 10 titles = [] if categoryUrlSuffix == 'BluRay' : XBMCInterfaceUtils.displayDialogMessage('HD Movies', 'Bluray movies not supported at the moment!', msgType='[B]INFO & REQUEST: [/B]') return titles queryParms = '&organize=Activity&filtered=RecentlyPosted&org_type=Activity' print categoryUrlSuffix if categoryUrlSuffix.find('_') > 0 : options_url = re.compile("(.+?)_(.*)").findall(categoryUrlSuffix) categoryUrlSuffix = options_url[0][1] if options_url[0][0].isdigit(): queryParms = '&organize=Year&filtered=' + options_url[0][0] + '&org_type=Year' else: queryParms = '&organize=Alphabetical&filtered=' + options_url[0][0] + '&org_type=Alphabetical' webpage = urlopen(BASE_WSITE_URL + 'movies/index.php?lang=' + categoryUrlSuffix + queryParms) soup2 = BeautifulSoup.BeautifulSoup(webpage) numDiv = soup2.find('div', {'class': 'numerical-nav'}) if numDiv : links = numDiv.findChildren('a') [-1] loopCount = int(links.text) for i in range(1, loopCount) : webpage = urlopen(BASE_WSITE_URL + 'movies/index.php?lang=' + categoryUrlSuffix + queryParms + '&page=' + str(i)).read() if re.match('page not found', webpage): break soup2 = BeautifulSoup.BeautifulSoup(webpage) for row in soup2('a', {'class' : 'movie-title'}) : print row.contents titleInfo = ''.join(row.contents) movieInfoUrl = row['href'] title = {} title['info'] = titleInfo title['link'] = movieInfoUrl titles.append(title) return titles
def start(addon_id, service_name, context_root, default_port, allowed_port_range): try: 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: print __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() print __service_name__ + ' Service :: service registered = %s @ %s' % ( service.get_service_name(), __context_root__) server.start() XBMCInterfaceUtils.displayNotification( __service_name__ + ' Service has started', 'Use safari extension to play video remotely', iconimage=iconimage) while not xbmc.abortRequested: time.sleep(5) print __service_name__ + ' Service :: ABORT request received from XBMC. PlayIt service will stop now.' except Exception, e: print __service_name__ + ' Service :: ERROR OCCURRED: ' + str(e) ExceptionHandler.handle(e)
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
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 by hosting website. Please check other links.') if video_info.get_video_link(DataObjects.XBMC_EXECUTE_PLUGIN) is not None: item.get_moving_data()['pluginUrl'] = video_info.get_video_link(DataObjects.XBMC_EXECUTE_PLUGIN) else: if Container().getAddonContext().addon.getSetting('ga_video_title') == 'true': Container().ga_client.reportContentUsage(video_info.get_video_hosting_info().get_video_hosting_name(), video_info.get_video_name()) XBMCInterfaceUtils.updateListItem_With_VideoInfo(video_info, item.get_xbmc_list_item_obj()) qual_set = Container().getAddonContext().addon.getSetting('playbackqual') if qual_set == '': qual_set = '0' qual = int(qual_set) video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_HD_1080) if video_strm_link is None or qual != 0: video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_HD_720) if video_strm_link is None or qual == 2: video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_SD) if video_strm_link is None: video_strm_link = video_info.get_video_link(DataObjects.VIDEO_QUAL_LOW) item.get_moving_data()['videoStreamUrl'] = video_strm_link
def start(addon_id, service_name, context_root, default_port, allowed_port_range): try: 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: print __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() print __service_name__ + ' Service :: service registered = %s @ %s' % (service.get_service_name(), __context_root__) server.start() XBMCInterfaceUtils.displayNotification(__service_name__ + ' Service has started', 'Use safari extension to play video remotely', iconimage=iconimage) while not xbmc.abortRequested: time.sleep(5) print __service_name__ + ' Service :: ABORT request received from XBMC. PlayIt service will stop now.' except Exception, e: print __service_name__ + ' Service :: ERROR OCCURRED: ' + str(e) ExceptionHandler.handle(e)
def addEmbeddedVideoInfo(request_obj, response_obj): items = response_obj.get_item_list() XBMCInterfaceUtils.callBackDialogProgressBar( getattr(sys.modules[__name__], '__addEmbeddedVideoInfo_in_item__'), items, 'Retrieving video info', 'Failed to retrieve video information, please try again later')
def __addVideoHostingInfo_in_item(item): videoHostingInfo = findVideoHostingInfo(item.get_moving_data()['videoUrl']) item.set_xbmc_list_item_obj( XBMCInterfaceUtils.updateListItem_With_VideoHostingInfo( videoHostingInfo, item.get_xbmc_list_item_obj()))
def judgeTurtleNextAction(self, actionObj): ProgressDisplayer().displayMessage( 80, line1='Preparing items for display or play', line2='Total items: ' + str(len(self.response_obj.get_item_list()))) if self.response_obj.get_redirect_action_name() is None: isAnyPlayableItem = False isItemsList = False playlist_type = None for item in self.response_obj.get_item_list(): nextActionId = actionObj.get_next_action_map()[ item.get_next_action_name()] if nextActionId == '__play__': if item.get_moving_data().has_key('pluginUrl'): XBMCInterfaceUtils.executePlugin( item.get_moving_data()['pluginUrl']) else: if not isAnyPlayableItem and not XBMCInterfaceUtils.isPlaying( ): XBMCInterfaceUtils.clearPlayList( ) # Clear playlist item only when at least one video item is found. playlist_type = XBMCInterfaceUtils.addPlayListItem( item) isAnyPlayableItem = True elif nextActionId == '__service_response__': # Do Nothing , get response object from container for parameters to be returned pass elif nextActionId == '__download__': downloadPath = self.addon_context.addon.getSetting( 'downloadPath') if downloadPath is None or downloadPath == '': XBMCInterfaceUtils.displayDialogMessage( "Download path not provided", "Please provide download path in add-on settings.", "The download path should be a local directory.") self.addon_context.addon.openSettings(sys.argv[0]) downloadPath = self.addon_context.addon.getSetting( 'downloadPath') if downloadPath is not None and downloadPath != '': XBMCInterfaceUtils.downloadVideo(item, downloadPath) elif nextActionId == '__resolved__': XBMCInterfaceUtils.setResolvedMediaUrl(item) else: isItemsList = True is_Folder = self.addon_context.isNextActionFolder( actionObj.get_action_id(), item.get_next_action_name()) downloadAction = self.addon_context.getDownloadActionIfDownloadable( actionObj.get_action_id(), item.get_next_action_name()) if (downloadAction is not None): XBMCInterfaceUtils.addContextMenuItem( item, 'Download Video', downloadAction) XBMCInterfaceUtils.addFolderItem(item, nextActionId, is_Folder) del item # deletes item if isAnyPlayableItem == True: ProgressDisplayer().end() try: if playlist_type is not None: XBMCInterfaceUtils.play(list_type=playlist_type) else: XBMCInterfaceUtils.play() except Exception, e: Logger.logFatal(e) elif isItemsList: if self.response_obj.get_xbmc_sort_method() is not None: XBMCInterfaceUtils.sortMethod( self.response_obj.get_xbmc_sort_method()) if self.response_obj.get_xbmc_content_type() is not None: XBMCInterfaceUtils.setContentType( self.response_obj.get_xbmc_content_type()) XBMCInterfaceUtils.setSortMethods()
def prepareVideoLink(request_obj, response_obj): items = response_obj.get_item_list() XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__prepareVideoLink__'), items, 'Preparing video link', 'Failed to retrieve video information, please try again later')
def retieveMovieInfoAndAddItem(request_obj, response_obj): items = response_obj.get_item_list() XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__addMovieInfo_in_item'), items, 'Retrieving info', 'Failed to retrieve information, please try again later')
def retrieveTVShowsAndSave(request_obj, response_obj): oldfilepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=OLD_CHANNELS_JSON_FILE, makeDirs=True) AddonUtils.deleteFile(oldfilepath) filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonProfile, extraDirPath=AddonUtils.ADDON_SRC_DATA_FOLDER, filename=CHANNELS_JSON_FILE, makeDirs=True) refresh = AddonContext().addon.getSetting('drForceRefresh') if refresh == None or refresh != 'true': lastModifiedTime = AddonUtils.getFileLastModifiedTime(filepath) if lastModifiedTime is not None: diff = long((time.time() - lastModifiedTime) / 3600) if diff < 720: return else: print CHANNELS_JSON_FILE + ' was last created 30 days ago, refreshing data.' else: print CHANNELS_JSON_FILE + ' request to force refresh data. ' tvChannels = {"UTV Stars": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/uu/utv_stars.jpg", "channelType": "IND", "running_tvshows_url": "/utv-stars/", "finished_tvshows_url": None}, "Star Plus": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_plus.jpg", "channelType": "IND", "running_tvshows_url": "/star-plus/", "finished_tvshows_url": "/star-plus-past-shows/"}, "Zee TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_tv.jpg", "channelType": "IND", "running_tvshows_url": "/zee-tv/", "finished_tvshows_url": "/zee-tv-past-shows/"}, "Sony TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/set_in.jpg", "channelType": "IND", "running_tvshows_url": "/sony-tv/", "finished_tvshows_url": "/sony-tv-past-shows/"}, "Star One": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_one.jpg", "channelType": "IND", "running_tvshows_url": "/star-one/", "finished_tvshows_url": "/star-one-past-shows/"}, "Life OK": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ll/life_ok_in.jpg", "channelType": "IND", "running_tvshows_url": "/life-ok/", "finished_tvshows_url": None}, "Star Jalsha": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_jalsha.jpg", "channelType": "IND", "running_tvshows_url": "/star-jalsha/", "finished_tvshows_url": "/star-jalsha-past-shows/"}, "Sahara One": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/sahara_one.jpg", "channelType": "IND", "running_tvshows_url": "/sahara-one/", "finished_tvshows_url": "/sahara-one-past-shows/"}, "Colors": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/colors_in.jpg", "channelType": "IND", "running_tvshows_url": "/colors-channel/", "finished_tvshows_url": "/colors-past-shows/"}, "NDTV Imagine": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ii/imagine_tv_in.jpg", "channelType": "IND", "running_tvshows_url": "/ndtv-imagine/", "finished_tvshows_url": "/ndtv-past-shows/"}, "Sab TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/sony_sab_tv.jpg", "channelType": "IND", "running_tvshows_url": "/sab-tv/", "finished_tvshows_url": "/sab-tv-past-shows/"}, "MTV (India/Pakistan)": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/mm/mtv_india.jpg", "channelType": "IND", "running_tvshows_url": "/mtv-india-pakistan/", "finished_tvshows_url": "/mtv-india-pakistan-past-shows/"}, "Bindass TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/uu/utv_bindass.jpg", "channelType": "IND", "running_tvshows_url": "/bindass-tv/", "finished_tvshows_url": "/bindass-tv-past-shows/"}, "Channel [V]": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/channel_v_in.jpg", "channelType": "IND", "running_tvshows_url": "/channel-v/", "finished_tvshows_url": "/channel-v-past-shows/"}, "DD National": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/dd/dd_national.jpg", "channelType": "IND", "running_tvshows_url": "/dd-national/", "finished_tvshows_url": "/dd-national-others-past-shows/"}, "Ary Digital": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/aa/atn_ary_digital.jpg", "channelType": "PAK", "running_tvshows_url": "/ary-digital/", "finished_tvshows_url": "/ary-past-shows/"}, "GEO TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/gg/geo_tv.jpg", "channelType": "PAK", "running_tvshows_url": "/geo-tv/", "finished_tvshows_url": "/geo-tv-past-shows/"}, "HUM TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/hh/hum_tv.jpg", "channelType": "PAK", "running_tvshows_url": "/hum-tv/", "finished_tvshows_url": "/hum-tv-past-shows/"}, "A PLUS": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/aa/a_plus.jpg", "channelType": "PAK", "running_tvshows_url": "/plus/", "finished_tvshows_url": "/plus-past-shows/"}, "POGO": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/pp/pogo.jpg", "channelType": "IND", "running_tvshows_url": "/pogo/", "finished_tvshows_url": None}, "Nickelodeon": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/nn/nickelodeon_in.jpg", "channelType": "IND", "running_tvshows_url": "/nick/", "finished_tvshows_url": None}, "Disney Channel": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/dd/disney_channel_in.jpg", "channelType": "IND", "running_tvshows_url": "/disney-channel/", "finished_tvshows_url": None}, "Hungama TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/hh/hungama.jpg", "channelType": "IND", "running_tvshows_url": "/hungama-tv/", "finished_tvshows_url": None}, "Cartoon Network": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/cc/cartoon_network_in.jpg", "channelType": "IND", "running_tvshows_url": "/cartoon-network/", "finished_tvshows_url": None}, "Star Pravah": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_pravah.jpg", "channelType": "IND", "running_tvshows_url": "/star-pravah/", "finished_tvshows_url": None}, "Zee Marathi": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_marathi.jpg", "channelType": "IND", "running_tvshows_url": "/zee-marathi/", "finished_tvshows_url": None}, "Star Utsav": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/ss/star_utsav.jpg", "channelType": "IND", "running_tvshows_url": "/star-utsav/", "finished_tvshows_url": None}, "9X": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/num/9x_in.jpg", "channelType": "IND", "running_tvshows_url": "/9x/", "finished_tvshows_url": "/9x-past-shows/"}, "ZEE Bangla": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/zz/zee_bangla.jpg", "channelType": "IND", "running_tvshows_url": "/zee-bangla/", "finished_tvshows_url": "/zee-bangla-past-shows/"}, "Mahuaa TV": {"iconimage":"http://www.lyngsat-logo.com/logo/tv/mm/mahuaa_bangla.jpg", "channelType": "IND", "running_tvshows_url": "/mahuaa-tv/", "finished_tvshows_url": "/mahuaa-tv-past-shows/"} } XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveChannelTVShows__'), tvChannels.values(), 'Retrieving channel TV Shows', 'Failed to retrieve video information, please try again later', line1='Takes about 5 minutes first time', line3='Refreshes data every month or on force refresh or on new add-on version') #save tvChannels in moving data request_obj.get_data()['tvChannels'] = tvChannels status = AddonUtils.saveObjToJsonFile(filepath, tvChannels) if status is not None: print 'Saved status = ' + str(status) AddonContext().addon.setSetting('drForceRefresh', 'false')
def addVideoInfo(request_obj, response_obj): items = response_obj.get_item_list() XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__addVideoInfo_in_item'), items, 'Retrieving video info', 'Video is either removed or not available. Use other links.')
def addEmbeddedVideoInfo(request_obj, response_obj): items = response_obj.get_item_list() XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__addEmbeddedVideoInfo_in_item__'), items, 'Retrieving video info', 'Failed to retrieve video information, please try again later')
def searchTVShows(request_obj, response_obj): search_text = XBMCInterfaceUtils.getUserInput(heading='Enter search text') newtvChannelUrl = request_obj.get_data()['tvChannelUrl'] + search_text request_obj.get_data()['tvChannelUrl'] = newtvChannelUrl response_obj.set_redirect_action_name('Search_Episodes')
def searchMovies(request_obj, response_obj): search_text = XBMCInterfaceUtils.getUserInput(heading="Enter search text") newtvChannelUrl = request_obj.get_data()["movieCategoryUrl"] + search_text request_obj.get_data()["movieCategoryUrl"] = newtvChannelUrl response_obj.set_redirect_action_name("Search_Movies")
def playHostedVideo(request_obj, response_obj): pbType = int(Container().getAddonContext().addon.getSetting('playbacktype')) Container().getAddonContext().addon.setSetting('ga_video_title', 'false') if 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() video_url = request_obj.get_data()['videoLink'] if video_url.startswith('http://goo.gl/'): Logger.logDebug('Found google short URL = ' + video_url) video_url = HttpUtils.getRedirectedUrl(video_url) Logger.logDebug('After finding out redirected URL = ' + video_url) request_obj.get_data()['videoLink'] = video_url if __is_valid_url(video_url): contentType = __check_media_url(video_url) if contentType is not None: if contentType == 'audio': response_obj.set_redirect_action_name('play_direct_audio') request_obj.get_data()['track_title'] = '' request_obj.get_data()['track_link'] = video_url request_obj.get_data()['track_artwork_url'] = '' else: response_obj.set_redirect_action_name('play_direct_video') else: if XBMCInterfaceUtils.isPlayingAudio(): response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "Stop active music!") response_obj.addServiceResponseParam("message", "Note: XBMC cannot play video when audio playback is in progress.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item) else: video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "URL not supported") response_obj.addServiceResponseParam("message", "Video URL is currently not supported by PlayIt. Please check if URL selected is correct.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item) else: Container().ga_client.reportContentUsage('hostedvideo', video_hosting_info.get_video_hosting_name()) response_obj.addServiceResponseParam("status", "success") if not XBMCInterfaceUtils.isPlaying(): XBMCInterfaceUtils.clearPlayList(list_type="video") response_obj.addServiceResponseParam("message", "Enjoy your video!") else: response_obj.addServiceResponseParam("title", "Request Enqueued!") response_obj.addServiceResponseParam("message", "Your request has been added to player queue.") response_obj.set_redirect_action_name('play_it') request_obj.get_data()['videoTitle'] = 'PlayIt Video' else: Logger.logError('video_url = ' + str(video_url)) response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "Invalid URL") response_obj.addServiceResponseParam("message", "Video URL is not valid one! Please check and try again.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item)
''' Created on Dec 27, 2011 @author: ajju ''' try: import TurtlePlugin from common import XBMCInterfaceUtils XBMCInterfaceUtils.setSuppressDialogMsg(True) except: import xbmcgui # @UnresolvedImport dialog = xbmcgui.Dialog() dialog.ok('[B][COLOR red]ALERT: [/COLOR][/B] RESTART XBMC', 'A new update has recently installed or add-on reconfigured.', 'Please restart XBMC to reflect the changes.', 'You will not be able to access until restart.') TurtlePlugin.start('plugin.playitx')
def __prepareVideoLink__(videoSourceLink): new_items = [] url = videoSourceLink if re.search('wp.me', url, re.I): url = HttpUtils.getRedirectedUrl(url) if not url.startswith('http://'): url = 'http://' + url Logger.logDebug(url) # contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'left_articles'}) # soup = BeautifulSoup.BeautifulSoup(html, contentDiv) if re.search('', videoSourceLink): video_hosting_info = SnapVideo.findVideoHostingInfo(videoSourceLink) if video_hosting_info is None: Logger.logDebug('Unrecognized video_url = ' + videoSourceLink) else: video_source_img = video_hosting_info.get_video_hosting_image() new_item = ListItem() new_item.add_request_data('videoTitle', 'Part #') new_item.add_request_data('videoLink', videoSourceLink) new_item.add_moving_data('videoSourceImg', video_source_img) new_item.add_moving_data( 'videoSourceName', video_hosting_info.get_video_hosting_name()) new_item.set_next_action_name('Play_Stream') xbmcListItem = xbmcgui.ListItem(label='Part #', iconImage=video_source_img, thumbnailImage=video_source_img) new_item.set_xbmc_list_item_obj(xbmcListItem) new_items.append(new_item) return new_items html = HttpUtils.HttpClient().getHtmlContent(url) dek = EnkDekoder.dekode(html) Logger.logDebug(dek) if dek is not None: html = dek html = html.replace('\n\r', '').replace('\r', '').replace('\n', '').replace('\\', '') children = [] if re.search('http://videos.stvflicks.com/', html): docId = re.compile('http://videos.stvflicks.com/(.+?).mp4"').findall( html)[0] children.append('src="http://videos.stvflicks.com/' + docId + '.mp4"') elif re.search('http://playcineflix.com/', html): docId = re.compile('http://playcineflix.com/(.+?).mp4"').findall( html)[0] children.append('src="http://playcineflix.com/' + docId + '.mp4"') elif re.search('https://video.google.com/get_player', html): docId = re.compile('docid=(.+?)"').findall(html)[0] children.append('src="https://docs.google.com/file/d/' + docId + '/preview"') elif re.search('http://videos.videopress.com/', html): docId = re.compile( 'type="video/mp4" href="http://videos.videopress.com/(.+?).mp4"' ).findall(html)[0] children.append('src="http://videos.videopress.com/' + docId + '.mp4"') elif re.search('http://videos.videopress.com/', html): docId = re.compile( 'type="video/mp4" href="http://videos.videopress.com/(.+?).mp4"' ).findall(html)[0] children.append('src="http://videos.videopress.com/' + docId + '.mp4"') elif re.search('video_alt_url=http://www.mediaplaybox.com', html): docId = re.compile('video_alt_url=http://www.mediaplaybox.com(.+?).mp4' ).findall(html)[0] children.append('src="http://www.mediaplaybox.com:81/' + docId + '.mp4"') elif re.search('video_url=http://www.mediaplaybox.com', html): docId = re.compile( 'video_url=http://www.mediaplaybox.com(.+?).mp4').findall(html)[0] children.append('src="http://www.mediaplaybox.com:81/' + docId + '.mp4"') else: children = re.compile('<embed(.+?)>').findall(html) if children is None or len(children) == 0: children = re.compile('<iframe(.+?)>').findall(html) Logger.logDebug(children) for child in children: video_url = re.compile('src="(.+?)"').findall(child)[0] if (re.search('http://ads', video_url, re.I) or re.search('http://ax-d', video_url, re.I)): continue if video_url.startswith('http://goo.gl/'): Logger.logDebug('Found google short URL = ' + video_url) video_url = HttpUtils.getRedirectedUrl(video_url) Logger.logDebug('After finding out redirected URL = ' + video_url) if re.search('videos.desionlinetheater.com', video_url): XBMCInterfaceUtils.displayDialogMessage( 'Unable to parse', 'A new HTML Guardian is used to protect the page', 'Sounds technical!! hmm, it means cannot find video.', 'Fix: Find me JavaScript Interpreter online service') video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: Logger.logDebug('Unrecognized video_url = ' + video_url) continue video_source_img = video_hosting_info.get_video_hosting_image() new_item = ListItem() new_item.add_request_data('videoTitle', 'Part #') new_item.add_request_data('videoLink', video_url) new_item.add_moving_data('videoSourceImg', video_source_img) new_item.add_moving_data('videoSourceName', video_hosting_info.get_video_hosting_name()) new_item.set_next_action_name('Play_Stream') xbmcListItem = xbmcgui.ListItem(label='Part #', iconImage=video_source_img, thumbnailImage=video_source_img) new_item.set_xbmc_list_item_obj(xbmcListItem) new_items.append(new_item) return new_items
def retieveMovieInfoAndAddItem(request_obj, response_obj): items = response_obj.get_item_list() XBMCInterfaceUtils.callBackDialogProgressBar( getattr(sys.modules[__name__], '__addMovieInfo_in_item'), items, 'Retrieving MOVIE info', 'Failed to retrieve movie information, please try again later')
def __prepareVideoLink__(videoSourceLink): new_items = [] url = videoSourceLink if re.search('wp.me', url, re.I): url = HttpUtils.getRedirectedUrl(url) if not url.startswith('http://'): url = 'http://' + url Logger.logDebug(url) # contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'left_articles'}) # soup = BeautifulSoup.BeautifulSoup(html, contentDiv) html = HttpUtils.HttpClient().getHtmlContent(url) dek = EnkDekoder.dekode(html) Logger.logDebug(dek) if dek is not None: html = dek html = html.replace('\n\r', '').replace('\r', '').replace('\n', '').replace('\\', '') children = [] if re.search('http://videos.stvflicks.com/', html): docId = re.compile('http://videos.stvflicks.com/(.+?).mp4"').findall(html)[0] children.append('src="http://videos.stvflicks.com/' + docId + '.mp4"') elif re.search('http://playcineflix.com/', html): docId = re.compile('http://playcineflix.com/(.+?).mp4"').findall(html)[0] children.append('src="http://playcineflix.com/' + docId + '.mp4"') elif re.search('https://video.google.com/get_player', html): docId = re.compile('docid=(.+?)"').findall(html)[0] children.append('src="https://docs.google.com/file/d/' + docId + '/preview"') elif re.search('http://videos.videopress.com/', html): docId = re.compile('type="video/mp4" href="http://videos.videopress.com/(.+?).mp4"').findall(html)[0] children.append('src="http://videos.videopress.com/' + docId + '.mp4"') else: children = re.compile('<embed(.+?)>').findall(html) if children is None or len(children) == 0: children = re.compile('<iframe(.+?)>').findall(html) Logger.logDebug(children) for child in children: video_url = re.compile('src="(.+?)"').findall(child)[0] if(re.search('http://ads', video_url, re.I) or re.search('http://ax-d', video_url, re.I)): continue if video_url.startswith('http://goo.gl/'): Logger.logDebug('Found google short URL = ' + video_url) video_url = HttpUtils.getRedirectedUrl(video_url) Logger.logDebug('After finding out redirected URL = ' + video_url) if re.search('videos.desionlinetheater.com', video_url): XBMCInterfaceUtils.displayDialogMessage('Unable to parse', 'A new HTML Guardian is used to protect the page', 'Sounds technical!! hmm, it means cannot find video.', 'Fix: Find me JavaScript Interpreter online service') video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: Logger.logDebug('Unrecognized video_url = ' + video_url) continue video_source_img = video_hosting_info.get_video_hosting_image() new_item = ListItem() new_item.add_request_data('videoTitle', 'Part #') new_item.add_request_data('videoLink', video_url) new_item.add_moving_data('videoSourceImg', video_source_img) new_item.add_moving_data('videoSourceName', video_hosting_info.get_video_hosting_name()) new_item.set_next_action_name('Play_Stream') xbmcListItem = xbmcgui.ListItem(label='Part #', iconImage=video_source_img, thumbnailImage=video_source_img) new_item.set_xbmc_list_item_obj(xbmcListItem) new_items.append(new_item) return new_items
def judgeTurtleNextAction(self, actionObj): ProgressDisplayer().displayMessage(80, line1='Preparing items for display or play', line2='Total items: ' + str(len(self.response_obj.get_item_list()))) if self.response_obj.get_redirect_action_name() is None: isAnyVideoItem = False for item in self.response_obj.get_item_list(): nextActionId = actionObj.get_next_action_map()[item.get_next_action_name()] if nextActionId == '__play__': if not isAnyVideoItem: XBMCInterfaceUtils.clearPlayList() #Clear playlist item only when at least one video item is found. XBMCInterfaceUtils.addPlayListItem(item) isAnyVideoItem = True elif nextActionId == '__service_response__': #Do Nothing , get response object from container for parameters to be returned pass else: is_Folder = self.addon_context.isNextActionFolder(actionObj.get_action_id(), item.get_next_action_name()) XBMCInterfaceUtils.addFolderItem(item, nextActionId, is_Folder) if isAnyVideoItem == True: ProgressDisplayer().end() XBMCInterfaceUtils.play() else: if self.response_obj.get_xbmc_sort_method() is not None: XBMCInterfaceUtils.sortItems(self.response_obj.get_xbmc_sort_method()) if self.response_obj.get_xbmc_content_type() is not None: XBMCInterfaceUtils.setContentType(self.response_obj.get_xbmc_content_type()) else: redirectActionId = actionObj.get_redirect_action_map()[self.response_obj.get_redirect_action_name()] self.response_obj.set_redirect_action_name(None) return redirectActionId