def deleteAll(self): sql_delete = "DELETE FROM favorites" self.dbCursor.execute(sql_delete) try: self.db.commit() miscFunctions.displayNotification('Delete all favorites','info') xbmc.log("Delete success in db",xbmc.LOGINFO) except Exception, e: xbmc.log("Error during delete execution in db with query : "+sql_delete,xbmc.LOGERROR)
def createFavorite(self,type, jsonR): # ___ Insert value sql_insert = "INSERT INTO favorites VALUES ( '%s', '%s')" % (type, json.dumps(jsonR)) self.dbCursor.execute(sql_insert) try: self.db.commit() miscFunctions.displayNotification('Add to favorite success','info') xbmc.log("Insert success in db with sql "+sql_insert,xbmc.LOGINFO) except Exception, e: xbmc.log("Error during insertion execution in db with query : "+sql_insert,xbmc.LOGERROR)
def deleteHistory(self, jsonR): clause_value = "json = '%s'" % (json.dumps(jsonR)) sql_delete = "DELETE FROM favorites WHERE %s" % (clause_value) self.dbCursor.execute(sql_delete) try: self.db.commit() miscFunctions.displayNotification('Delete from favorite success','info') xbmc.log("Delete success in db",xbmc.LOGINFO) except Exception, e: xbmc.log("Error during delete execution in db with query : "+sql_delete,xbmc.LOGERROR)
def searchTrailer(self, title): """ Method to search a trailer @param title: the movie title @return the youtube id """ searchParam = strUtil.deleteAccent(title) + ' ' + str( constant.__addon__.getLocalizedString(70012)) href = 'https://www.youtube.com/results?q=' + webUtil.encodeStr( searchParam) self.__LOGGER__.log(href, xbmc.LOGDEBUG) request = urllib2.Request(href, headers=webUtil.HEADER_CFG) response = None try: response = self.urlOpener.open(request) except urllib2.HTTPError as e: response = e except: traceback.print_exc() miscFunctions.displayNotification( 'Error during searching trailer for ' + title) if response and response.getcode() == 200: # ___ Read the source content = response.read() # ___ Initialize BeautifulSoup soup = BeautifulSoup(content) link = soup.find( 'a', { 'class': re.compile( '(yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink)(.*)(spf-link)(.*)' ) }) patternIdYoutube = re.compile('(\/watch\?v=)(.*)') match = patternIdYoutube.match(link['href']) if match is not None: id = match.group(2) self.__LOGGER__.log('id = ' + id, xbmc.LOGDEBUG) return id return None
def changeSrcDialog(): listeSrc = [] for inst in MODULES_INSTANCES: listeSrc.append(inst.getName()) selectDialog = xbmcgui.Dialog() select = selectDialog.select(constant.__addon__.getLocalizedString(50090), listeSrc) id = -1 for inst in MODULES_INSTANCES: if listeSrc[select] == inst.getName(): id = inst.getId() if id > 0: constant.__addon__.setSetting('default_stream_src', str(id)) miscFunctions.displayNotification('Source : ' + listeSrc[select], 'info')
def displayVideoOptions(streamItem): """ Method to display video options @param streamItem: the selected StreamItem """ constant.__LOGGER__.log("Try to resolve url " + streamItem.getHref(), xbmc.LOGDEBUG) # ___ Resolve url playableUrl = False progress = xbmcgui.DialogProgress() progress.create(constant.__addon__.getLocalizedString(70006), constant.__addon__.getLocalizedString(70009)) # ___ Try to unshort link unshort = UnshortenUrl() href = unshort.unshortUrl(streamItem.getHref()) constant.__LOGGER__.log('Unshort url : ' + str(href)) streamItem.setHref(href) try: playableUrl = urlresolver.resolve(streamItem.getHref()) except: pass progress.close() constant.__LOGGER__.log("Resolved url : " + str(playableUrl), xbmc.LOGDEBUG) # ___If the url is resolved, play automatically if the setting is activated # ___ Remove " and isinstance(playableUrl,unicode)" if playableUrl != False and constant.__addon__.getSetting( 'play_auto') == 'true': streamItem.setPlayableUrl(playableUrl) playVideo(streamItem) # ___If the url is resolved, display the the list of possibilities (Open in web browser, Play, Download or Download & Play ) elif playableUrl != False and constant.__addon__.getSetting( 'play_auto') == 'false': streamItem.setPlayableUrl(playableUrl) if constant.__addon__.getSetting( 'downloader_module') == '0' and constant.__addon__.getSetting( 'activate_web_browser') == 'false': # ___ Do not display download choice if the downloader is not set. liste = [constant.__addon__.getLocalizedString(70001)] elif constant.__addon__.getSetting( 'downloader_module') == '0' and constant.__addon__.getSetting( 'activate_web_browser') == 'true': # ___ Do not display download choice if the downloader is not set. liste = [ constant.__addon__.getLocalizedString(70001), constant.__addon__.getLocalizedString(70002) ] elif constant.__addon__.getSetting( 'downloader_module') != '0' and constant.__addon__.getSetting( 'activate_web_browser') == 'false': # ___ Do not display download choice if the downloader is not set. liste = [ constant.__addon__.getLocalizedString(70001), constant.__addon__.getLocalizedString(70003) ] else: liste = [ constant.__addon__.getLocalizedString(70001), constant.__addon__.getLocalizedString(70002), constant.__addon__.getLocalizedString(70003) ] selectDialog = xbmcgui.Dialog() select = selectDialog.select( constant.__addon__.getLocalizedString(70000), liste) if select == 0: playVideo(streamItem) elif select == 1 and constant.__addon__.getSetting( 'activate_web_browser') == 'true': isRealDebrid = False # ___ If we use real-debrid, build the streaming page : # ___ https://real-debrid.com/streaming-<MEDIA ID FOR REALDEBRID> if 'rdb.so' in str(playableUrl) or 'rdeb.io' in str(playableUrl): urlToPlay = "https://real-debrid.com/streaming-" + playableUrl.split( "/")[4] streamItem.setPlayableUrl(playableUrl) isRealDebrid = True # ___ For real-debrid we use firefox if isRealDebrid: webUtil.openInWebbrowser( streamItem.getPlayableUrl(), constant.__addon__.getSetting('rd_web_browser')) else: webUtil.openInWebbrowser( streamItem.getPlayableUrl(), constant.__addon__.getSetting('android_web_browser')) # ___ Create or update the history history.createOrUpdateHistory(streamItem) elif select == 1 and constant.__addon__.getSetting( 'activate_web_browser') == 'false': miscFunctions.downloadFile(streamItem, False) elif select == 2: miscFunctions.downloadFile(streamItem, False) # __ Else display limited options elif constant.__addon__.getSetting('activate_web_browser') == 'true': constant.__LOGGER__.log( "Unable to resolve url " + streamItem.getHref(), xbmc.LOGWARNING) # ___ Only display the option : Open in web browser liste = [constant.__addon__.getLocalizedString(70002)] selectDialog = xbmcgui.Dialog() select = selectDialog.select( constant.__addon__.getLocalizedString(70000), liste) if select == 0: # ___ Open in web browser isRealDebrid = False # ___ If we use real-debrid, build the streaming page : # ___ https://real-debrid.com/streaming-<MEDIA ID FOR REALDEBRID> if 'rdb.so' in str(playableUrl) or 'rdeb.io' in str(playableUrl): urlToPlay = "https://real-debrid.com/streaming-" + playableUrl.split( "/")[4] isRealDebrid = True streamItem.setPlayableUrl(urlToPlay) # ___ For real-debrid we use the selected web browser in settings -- Only for Android if isRealDebrid: webUtil.openInWebbrowser( streamItem.getPlayableUrl(), constant.__addon__.getSetting('rd_web_browser')) else: webUtil.openInWebbrowser( streamItem.getPlayableUrl(), constant.__addon__.getSetting('android_web_browser')) # ___ Create or update the history history.createOrUpdateHistory(streamItem) # __ Else display notification for unavailable link else: miscFunctions.displayNotification( constant.__addon__.getLocalizedString(70014), 'info')