def AddtoDownloadListandview(self): oInputParameterHandler = cInputParameterHandler() sMediaUrl = oInputParameterHandler.getValue('sMediaUrl') sFileName = oInputParameterHandler.getValue('sFileName') # sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier') VSlog('Download ' + sMediaUrl) meta = {} meta['url'] = sMediaUrl meta['cat'] = oInputParameterHandler.getValue('sCat') meta['title'] = sFileName meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)') if (self.AddDownload(meta)): # Si pas de telechargement en cours on lance le notre if not self.isDownloading(): row = cDb().get_download(meta) if row: title = row[0][1] url = UnquotePlus(row[0][2]) path = row[0][3] # thumbnail = UnquotePlus(row[0][4]) # status = row[0][8] if (self.download(url, title, path, True) == True): # Download in fastmode # ok on attend un peu, et on lance le stream tempo = 100 progress_ = progress().VScreate('Bufferisation') while (tempo > 0): # if canceled do nothing if progress_.iscanceled(): break progress_.VSupdate(progress_, 100) tempo = tempo - 1 xbmc.sleep(500) progress_.VSclose(progress_) oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setMediaUrl(path) oGuiElement.setTitle(title) # oGuiElement.getInfoLabel() oPlayer = cPlayer() # if not (sys.argv[1] == '-1'): # oPlayer.run(oGuiElement, title, path) # else: oPlayer.clearPlayList() oPlayer.addItemToPlaylist(oGuiElement) oPlayer.startPlayer() else: self.DIALOG.VSinfo('Erreur', self.ADDON.VSlang(30085)) return
def getValue(self, sParamName): if self.exist(sParamName): sParamValue = self.__aParams[sParamName] if not sParamValue.startswith('http'): return UnquotePlus(sParamValue) else: return Unquote(sParamValue) return False
def StartDownload(self, data): if not (data): return title = data[1] url = UnquotePlus(data[2]) path = data[3] # thumbnail = UnquotePlus(data[4]) # status = data[8] self.download(url, title, path)
def getFav(self): oGui = cGui() oInputParameterHandler = cInputParameterHandler() row = cDb().get_bookmark() if (oInputParameterHandler.exist('sCat')): sCat = oInputParameterHandler.getValue('sCat') # Série, Animes, Saison et Episodes sont visibles dans les marques-page "Séries" catList = ('2', '3', '4', '8') if sCat in catList: sCat = 2 cGui.CONTENT = 'tvshows' else: catList = ('1', '7') # films, saga cGui.CONTENT = 'movies' if sCat in catList: sCat = 1 else: catList = sCat cGui.CONTENT = 'videos' gen = (x for x in row if x['cat'] in catList) else: oGui.setEndOfDirectory() return for data in gen: try: title = data['title'].encode('utf-8') except: title = data['title'] try: thumbnail = data['icon'].encode('utf-8') except: thumbnail = data['icon'] try: try: siteurl = data['siteurl'].encode('utf-8') except: siteurl = data['siteurl'] if isMatrix(): siteurl = UnquotePlus(siteurl.decode('utf-8')) title = str(title, 'utf-8') else: siteurl = UnquotePlus(siteurl) site = data['site'] function = data['fav'] cat = data['cat'] fanart = data['fanart'] if thumbnail == '': thumbnail = 'False' oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', siteurl) oOutputParameterHandler.addParameter('sMovieTitle', title) oOutputParameterHandler.addParameter('searchtext', title) oOutputParameterHandler.addParameter('sThumbnail', thumbnail) # Dans ajouter source c'est bien sThumb donc... oOutputParameterHandler.addParameter('sThumb', thumbnail) if (function == 'play'): oHoster = cHosterGui().checkHoster(siteurl) oOutputParameterHandler.addParameter( 'sHosterIdentifier', oHoster.getPluginIdentifier()) oOutputParameterHandler.addParameter( 'sFileName', oHoster.getFileName()) oOutputParameterHandler.addParameter('sMediaUrl', siteurl) oGuiElement = cGuiElement() oGuiElement.setSiteName(site) oGuiElement.setFunction(function) oGuiElement.setTitle(title) oGuiElement.setFileName(title) oGuiElement.setIcon("mark.png") if (cat == '1'): # Films oGuiElement.setMeta(1) oGuiElement.setCat(1) elif (cat == '2'): # Séries oGuiElement.setMeta(2) oGuiElement.setCat(2) elif (cat == '3'): # Anime oGuiElement.setMeta(4) oGuiElement.setCat(3) elif (cat == '4'): # Saisons oGuiElement.setMeta(5) oGuiElement.setCat(4) elif (cat == '5'): # Divers oGuiElement.setMeta(0) oGuiElement.setCat(5) elif (cat == '6'): # TV (Officiel) oGuiElement.setMeta(0) oGuiElement.setCat(6) elif (cat == '7'): # Saga oGuiElement.setMeta(3) oGuiElement.setCat(7) elif (cat == '8'): # Episodes oGuiElement.setMeta(6) oGuiElement.setCat(8) else: oGuiElement.setMeta(0) oGuiElement.setCat(cat) oGuiElement.setThumbnail(thumbnail) oGuiElement.setFanart(fanart) oGuiElement.addItemProperties('isBookmark', True) oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, 'cFav', 'cFav', 'delBookmark', self.ADDON.VSlang(30412)) if (function == 'play'): oGui.addHost(oGuiElement, oOutputParameterHandler) else: oGui.addFolder(oGuiElement, oOutputParameterHandler) except: oOutputParameterHandler = cOutputParameterHandler() oGui.addDir(SITE_IDENTIFIER, 'DoNothing', '[COLOR red]ERROR[/COLOR]', 'films.png', oOutputParameterHandler) # La suppression n'est pas accessible lors de l'utilisation en Widget if not xbmc.getCondVisibility('Window.IsActive(home)'): oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sCat', sCat) oGui.addDir(SITE_IDENTIFIER, 'delBookmark', self.ADDON.VSlang(30211), 'trash.png', oOutputParameterHandler) oGui.setEndOfDirectory() return
def nextEpisode(self, guiElement): if not self.use_up_next(): return # tester s'il s'agit d'une série tvShowTitle = guiElement.getItemValue('tvshowtitle') if not tvShowTitle: return oInputParameterHandler = cInputParameterHandler() # La source sSiteName = oInputParameterHandler.getValue('sourceName') if not sSiteName: return # La saison sSaison = oInputParameterHandler.getValue('sSeason') # Calcule l'épisode suivant à partir de l'épisode courant sEpisode = oInputParameterHandler.getValue('sEpisode') if not sEpisode: sEpisode = str(guiElement.getEpisode()) if not sEpisode: return # impossible de déterminer l'épisode courant sMovieTitle = tvShowTitle #if 'Saison' in tvShowTitle else tvShowTitle + ' S' + sSaison numEpisode = int(sEpisode) nextEpisode = numEpisode + 1 sNextEpisode = '%02d' % nextEpisode saisonUrl = oInputParameterHandler.getValue('saisonUrl') oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', saisonUrl) oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle) sParams = oOutputParameterHandler.getParameterAsUri() sHosterIdentifier = oInputParameterHandler.getValue( 'sHosterIdentifier') nextSaisonFunc = oInputParameterHandler.getValue('nextSaisonFunc') sLang = oInputParameterHandler.getValue('sLang') try: sHosterIdentifier, sMediaUrl, nextTitle, sDesc, sThumb = self.getMediaUrl( sSiteName, nextSaisonFunc, sParams, sSaison, nextEpisode, sLang, sHosterIdentifier) if not sMediaUrl: return sFileName = tvShowTitle.replace(' & ', ' and ') # interdit dans un titre sFileName += ' - ' if sSaison: sFileName += 'S%s' % sSaison sFileName += 'E%s' % sNextEpisode nextTitle = UnquotePlus(nextTitle) if sLang: nextTitle += ' (%s)' % sLang saisonUrl = oInputParameterHandler.getValue('saisonUrl') oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sHosterIdentifier', sHosterIdentifier) oOutputParameterHandler.addParameter('sourceName', sSiteName) oOutputParameterHandler.addParameter('sFileName', sFileName) oOutputParameterHandler.addParameter('sTitle', nextTitle) oOutputParameterHandler.addParameter('sCat', 8) # Catégorie épisode oOutputParameterHandler.addParameter('sFav', 'play') oOutputParameterHandler.addParameter('sMediaUrl', str(sMediaUrl)) oOutputParameterHandler.addParameter('saisonUrl', saisonUrl) oOutputParameterHandler.addParameter('nextSaisonFunc', nextSaisonFunc) oOutputParameterHandler.addParameter('sSeason', sSaison) oOutputParameterHandler.addParameter('sEpisode', sNextEpisode) oOutputParameterHandler.addParameter('sLang', sLang) sParams = oOutputParameterHandler.getParameterAsUri() url = 'plugin://plugin.video.vstream/?site=cHosterGui&function=play&%s' % sParams # sThumbnail = guiElement.getThumbnail() sThumbnail = sThumb nextInfo = dict( current_episode=dict( episodeid=numEpisode, tvshowid=0, showtitle=tvShowTitle, season=sSaison if sSaison else '', episode='%02d' % numEpisode, title='', plot='', art={ 'thumb': sThumbnail, 'tvshow.clearart': '', 'tvshow.clearlogo': '', 'tvshow.fanart': '', 'tvshow.landscape': '', 'tvshow.poster': '', }, ), next_episode=dict( episodeid=nextEpisode, tvshowid=0, showtitle=tvShowTitle, season=sSaison if sSaison else '', #déjà dans le titre episode=sNextEpisode, #déjà dans le titre title=nextTitle, # titre de l'épisode plot=sDesc, art={ 'thumb': sThumbnail, 'tvshow.clearart': '', 'tvshow.clearlogo': '', 'tvshow.fanart': sThumbnail, #guiElement.getFanart(), 'tvshow.landscape': guiElement.getPoster(), 'tvshow.poster': guiElement.getPoster(), }, ), play_url=url # provide either `play_info` or `play_url` ) self.notifyUpnext(nextInfo) except Exception as e: VSlog('UpNext : %s' % e)
def getMediaUrl(self, sSiteName, sFunction, sParams, sSaison, iEpisode, sLang, sHosterIdentifier, sTitle='', sDesc='', sThumb=''): try: sys.argv[2] = '?%s' % sParams plugins = __import__('resources.sites.%s' % sSiteName, fromlist=[sSiteName]) function = getattr(plugins, sFunction) function() except Exception as e: VSlog('could not load site: ' + sSiteName + ' error: ' + str(e)) return None, None, None, None, None sMediaUrl = '' for sUrl, listItem, isFolder in cGui().getEpisodeListing(): sParams = sUrl.split('?', 1)[1] aParams = dict(param.split('=') for param in sParams.split('&')) sFunction = aParams['function'] if sFunction == 'DoNothing': continue if sLang and 'sLang' in aParams and UnquotePlus( aParams['sLang']) != sLang: continue # La langue est connue mais ce n'est pas la bonne if sSaison and 'sSeason' in aParams and aParams['sSeason'] and int( aParams['sSeason']) != int(sSaison): continue # La saison est connue mais ce n'est pas la bonne if 'sEpisode' in aParams and aParams['sEpisode'] and int( aParams['sEpisode']) != iEpisode: continue # L'épisode est connue mais ce n'est pas le bon sMediaUrl = aParams['sMediaUrl'] if 'sMediaUrl' in aParams else None sTitle = UnquotePlus( aParams['sTitle']) if 'sTitle' in aParams else None if 'sHost' in aParams and aParams['sHost']: oHoster = cHosterGui().checkHoster(aParams['sHost']) if not oHoster: continue hostName = oHoster.getPluginIdentifier() if hostName != sHosterIdentifier: continue hostName = sHosterIdentifier if 'sHosterIdentifier' in aParams: hostName = aParams['sHosterIdentifier'] if hostName != sHosterIdentifier: continue if 'sThumb' in aParams and aParams['sThumb']: sThumb = UnquotePlus(aParams['sThumb']) if 'sDesc' in aParams and aParams['sDesc']: sDesc = UnquotePlus(aParams['sDesc']) if sMediaUrl: return hostName, sMediaUrl, sTitle, sDesc, sThumb # if sFunction != 'play': return self.getMediaUrl(sSiteName, sFunction, sParams, sSaison, iEpisode, sLang, sHosterIdentifier, sTitle, sDesc, sThumb) if sMediaUrl: # si on n'a pas trouvé le bon host on en retourne un autre, il pourrait fonctionner return hostName, sMediaUrl, sTitle, sDesc, sThumb return None, None, None, None, None
def getDownloadList(self): oGui = cGui() row = cDb().get_download() oOutputParameterHandler = cOutputParameterHandler() for data in row: title = data[1] url = UnquotePlus(data[2]) path = data[3] # cat = data[4] thumbnail = UnquotePlus(data[5]) # The url is unicode format ? Not managed yet try: thumbnail = str(thumbnail) except: thumbnail = '' size = data[6] totalsize = data[7] status = data[8] oOutputParameterHandler.addParameter('sUrl', url) oOutputParameterHandler.addParameter('sMovieTitle', title) oOutputParameterHandler.addParameter('sThumbnail', thumbnail) oOutputParameterHandler.addParameter('sPath', path) oOutputParameterHandler.addParameter('sStatus', status) if status == '0': sStatus = '' elif status == '1': sStatus = '[COLOR=red][En cours] [/COLOR]' elif status == '2': sStatus = '[COLOR=green][Fini] [/COLOR]' if size: if isMatrix(): try: title = title.decode() except: pass sTitle = sStatus + title + ' (' + self.__formatFileSize( size) + '/' + self.__formatFileSize(totalsize) + ')' else: sTitle = sStatus + title oGuiElement = cGuiElement() if not thumbnail or thumbnail == 'False': thumbnail = 'mark.png' oGuiElement.setSiteName(SITE_IDENTIFIER) if status == '2': oGuiElement.setFunction('ReadDownload') else: # oGuiElement.setFunction('StartDownloadOneFile') # marche pas a cause de fenetre xbmc oGuiElement.setFunction('ReadDownload') oGuiElement.setTitle(sTitle) oGuiElement.setIcon('download.png') oGuiElement.setMeta(0) oGuiElement.setThumbnail(thumbnail) oGui.createContexMenuDownload(oGuiElement, oOutputParameterHandler, status) oGui.addFolder(oGuiElement, oOutputParameterHandler) oGui.setEndOfDirectory() return
def getViewing(self): oGui = cGui() DB = cDb() # oInputParameterHandler = cInputParameterHandler() row = DB.get_viewing() if not row: oGui.setEndOfDirectory() return for data in row: try: title = data['title'].encode('utf-8') except: title = data['title'] try: try: siteurl = data['siteurl'].encode('utf-8') except: siteurl = data['siteurl'] if isMatrix(): siteurl = UnquotePlus(siteurl.decode('utf-8')) title = str(title, 'utf-8') else: siteurl = UnquotePlus(siteurl) sTitleWatched = data['title_id'] site = data['site'] function = data['fav'] cat = data['cat'] sSeason = data['season'] sTmdbId = data['tmdb_id'] # if 'tmdb_id' in data else None oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', siteurl) oOutputParameterHandler.addParameter('sMovieTitle', title) oOutputParameterHandler.addParameter('sTmdbId', sTmdbId) oOutputParameterHandler.addParameter('sTitleWatched', sTitleWatched) oOutputParameterHandler.addParameter('sSeason', sSeason) oOutputParameterHandler.addParameter('sCat', cat) oOutputParameterHandler.addParameter('isViewing', True) # pourcentage de lecture meta = {} meta['title'] = sTitleWatched resumetime, totaltime = DB.get_resume(meta) oOutputParameterHandler.addParameter('ResumeTime', resumetime) oOutputParameterHandler.addParameter('TotalTime', totaltime) if cat == '1': oListItem = oGui.addMovie(site, function, title, 'films.png', '', title, oOutputParameterHandler) elif cat == '5': oListItem = oGui.addMisc(site, function, title, 'films.png', '', title, oOutputParameterHandler) elif cat == '4': oListItem = oGui.addSeason(site, function, title, 'series.png', '', title, oOutputParameterHandler) else: oListItem = oGui.addTV(site, function, title, 'series.png', '', title, oOutputParameterHandler) oOutputParameterHandler.addParameter('sTitleWatched', sTitleWatched) oOutputParameterHandler.addParameter('sCat', cat) oListItem.addMenu(SITE_IDENTIFIER, 'delViewing', self.ADDON.VSlang(30412), oOutputParameterHandler) except Exception as e: pass # Vider toute la catégorie n'est pas accessible lors de l'utilisation en Widget if not xbmc.getCondVisibility('Window.IsActive(home)'): oOutputParameterHandler = cOutputParameterHandler() oGui.addDir(SITE_IDENTIFIER, 'delViewing', self.ADDON.VSlang(30211), 'trash.png', oOutputParameterHandler) oGui.setEndOfDirectory() return
def getFav(self): oGui = cGui() oInputParameterHandler = cInputParameterHandler() row = cDb().get_bookmark() if (oInputParameterHandler.exist('sCat')): sCat = oInputParameterHandler.getValue('sCat') gen = (x for x in row if x[5] in sCat) else: sCat = '5' gen = (x for x in row if x[5] not in ('1', '2', '6')) for data in gen: try: title = data[1].encode('utf-8') except: title = data[1] try: thumbnail = data[6].encode('utf-8') except: thumbnail = data[6] try: try: siteurl = data[2].encode('utf-8') except: siteurl = data[2] if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19': siteurl = UnquotePlus(siteurl.decode('utf-8')) title = str(title, 'utf-8') else: siteurl = UnquotePlus(siteurl) site = data[3] function = data[4] cat = data[5] fanart = data[7] if thumbnail == '': thumbnail = 'False' oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', siteurl) oOutputParameterHandler.addParameter('sMovieTitle', title) oOutputParameterHandler.addParameter('searchtext', title) oOutputParameterHandler.addParameter('sThumbnail', thumbnail) # Dans ajouter source c'est bien sThumb donc... oOutputParameterHandler.addParameter('sThumb', thumbnail) if (function == 'play'): oHoster = cHosterGui().checkHoster(siteurl) oOutputParameterHandler.addParameter( 'sHosterIdentifier', oHoster.getPluginIdentifier()) oOutputParameterHandler.addParameter( 'sFileName', oHoster.getFileName()) oOutputParameterHandler.addParameter('sMediaUrl', siteurl) oGuiElement = cGuiElement() oGuiElement.setSiteName(site) oGuiElement.setFunction(function) oGuiElement.setTitle(title) oGuiElement.setFileName(title) oGuiElement.setIcon("mark.png") if (cat == '1'): cGui.CONTENT = 'movies' oGuiElement.setMeta(1) oGuiElement.setCat(1) elif (cat == '2'): cGui.CONTENT = 'tvshows' oGuiElement.setMeta(2) oGuiElement.setCat(2) else: oGuiElement.setMeta(0) oGuiElement.setCat(cat) oGuiElement.setThumbnail(thumbnail) oGuiElement.setFanart(fanart) oGuiElement.addItemProperties('isBookmark', True) oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, 'cFav', 'cFav', 'delBookmark', self.ADDON.VSlang(30412)) if (function == 'play'): oGui.addHost(oGuiElement, oOutputParameterHandler) else: oGui.addFolder(oGuiElement, oOutputParameterHandler) except: oGui.addDir(SITE_IDENTIFIER, 'DoNothing', '[COLOR red]ERROR[/COLOR]', 'films.png', oOutputParameterHandler) # La suppression n'est pas accessible lors de l'utilisation en Widget if not xbmc.getCondVisibility('Window.IsActive(home)'): oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sCat', sCat) oGui.addDir(SITE_IDENTIFIER, 'delBookmark', self.ADDON.VSlang(30211), 'trash.png', oOutputParameterHandler) oGui.setEndOfDirectory() return
def getFav(self): oGui = cGui() oInputParameterHandler = cInputParameterHandler() row = cDb().get_bookmark() if (oInputParameterHandler.exist('sCat')): sCat = oInputParameterHandler.getValue('sCat') gen = (x for x in row if x[5] in sCat) else: sCat = '5' gen = (x for x in row if x[5] not in ('1', '2', '6')) for data in gen: try: title = data[1].encode('utf-8') except: title = data[1] try: thumbnail = data[6].encode('utf-8') except: thumbnail = data[6] try: siteurl = UnquotePlus(data[2]) site = data[3] function = data[4] cat = data[5] fanart = data[7] if thumbnail == '': thumbnail = 'False' oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', siteurl) oOutputParameterHandler.addParameter('sMovieTitle', title) oOutputParameterHandler.addParameter('searchtext', title) oOutputParameterHandler.addParameter('sThumbnail', thumbnail) # Dans ajouter source c'est bien sThumb donc... oOutputParameterHandler.addParameter('sThumb', thumbnail) if (function == 'play'): oHoster = cHosterGui().checkHoster(siteurl) oOutputParameterHandler.addParameter( 'sHosterIdentifier', oHoster.getPluginIdentifier()) oOutputParameterHandler.addParameter( 'sFileName', oHoster.getFileName()) oOutputParameterHandler.addParameter('sMediaUrl', siteurl) oGuiElement = cGuiElement() oGuiElement.setSiteName(site) oGuiElement.setFunction(function) oGuiElement.setTitle(title) oGuiElement.setFileName(title) oGuiElement.setIcon("mark.png") if (cat == '1'): cGui.CONTENT = 'movies' oGuiElement.setMeta(cat) oGuiElement.setCat(1) elif (cat == '2'): cGui.CONTENT = 'tvshows' oGuiElement.setMeta(cat) oGuiElement.setCat(2) else: oGuiElement.setMeta(0) oGuiElement.setCat(cat) oGuiElement.setThumbnail(thumbnail) oGuiElement.setFanart(fanart) oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, 'cFav', 'cFav', 'delBookmarksMenu', self.ADDON.VSlang(30412)) if (function == 'play'): oGui.addHost(oGuiElement, oOutputParameterHandler) else: oGui.addFolder(oGuiElement, oOutputParameterHandler) except: oGui.addDir(SITE_IDENTIFIER, 'DoNothing', '[COLOR red]ERROR[/COLOR]', 'films.png', oOutputParameterHandler) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('sCat', sCat) oGui.addDir(SITE_IDENTIFIER, 'delBookmarks', self.ADDON.VSlang(30211), 'trash.png', oOutputParameterHandler) oGui.setEndOfDirectory() return