Beispiel #1
0
    def setBookmark(self):
        oInputParameterHandler = cInputParameterHandler()

        sCat = oInputParameterHandler.getValue('sCat') if oInputParameterHandler.exist('sCat') else xbmc.getInfoLabel('ListItem.Property(sCat)')
        if int(sCat) not in (1, 2, 5):
            self.DIALOG.VSinfo('Error', self.ADDON.VSlang(30038))
            return

        meta = {}
        
        sSiteUrl = oInputParameterHandler.getValue('siteUrl') if oInputParameterHandler.exist('siteUrl') else xbmc.getInfoLabel('ListItem.Property(siteUrl)')
        sTitle = oInputParameterHandler.getValue('sMovieTitle') if oInputParameterHandler.exist('sMovieTitle') else xbmc.getInfoLabel('ListItem.Property(sCleanTitle)')
        sSite = oInputParameterHandler.getValue('sId') if oInputParameterHandler.exist('sId') else xbmc.getInfoLabel('ListItem.Property(sId)')
        sFav = oInputParameterHandler.getValue('sFav') if oInputParameterHandler.exist('sFav') else xbmc.getInfoLabel('ListItem.Property(sFav)')

        meta['siteurl'] = sSiteUrl
        meta['title'] = sTitle
        meta['site'] = sSite
        meta['fav'] = sFav
        meta['cat'] = sCat

        meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)')
        meta['fanart'] = xbmc.getInfoLabel('ListItem.Art(fanart)')
        try:
            cDb().insert_bookmark(meta)
        except:
            pass
    def setFavorite(self):
        oInputParameterHandler = cInputParameterHandler()

        if oInputParameterHandler.getValue('sId') == 'kepliz_com':
            self.DIALOG.VSinfo('Error', 'Non possible pour ce site')
            return

        if int(oInputParameterHandler.getValue('sCat')) < 1:
            self.DIALOG.VSinfo('Error', 'Mise en Favoris non possible pour ce lien')
            return

        meta = {}
        meta['siteurl'] = oInputParameterHandler.getValue('siteUrl')
        meta['site'] = oInputParameterHandler.getValue('sId')
        meta['fav'] = oInputParameterHandler.getValue('sFav')
        meta['cat'] = oInputParameterHandler.getValue('sCat')

        #ListItem.title contient des code de couleurs, sMovieTitle le titre en plus "propre"
        #Inutile a la prochaine version, car plus de couleurs a la base.
        if oInputParameterHandler.getValue('sMovieTitle'):
            meta['title'] = oInputParameterHandler.getValue('sMovieTitle')
        else:
            meta['title'] = xbmc.getInfoLabel('ListItem.title')

        meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)')
        meta['fanart'] =  xbmc.getInfoLabel('ListItem.Art(fanart)')
        try:
            cDb().insert_favorite(meta)
        except:
            pass
    def setFavorite(self):
        oInputParameterHandler = cInputParameterHandler()

        if oInputParameterHandler.getValue('sId') == 'kepliz_com':
            self.DIALOG.VSinfo('Error','Non possible pour ce site')
            return

        if int(oInputParameterHandler.getValue('sCat')) < 1:
            self.DIALOG.VSinfo('Error','Mise en Favoris non possible pour ce lien')
            return

        meta = {}
        meta['siteurl'] = oInputParameterHandler.getValue('siteUrl')
        meta['site'] = oInputParameterHandler.getValue('sId')
        meta['fav'] = oInputParameterHandler.getValue('sFav')
        meta['cat'] = oInputParameterHandler.getValue('sCat')

        #ListItem.title contient des code de couleurs, sMovieTitle le titre en plus "propre"
        #Inutile a la prochaine version, car plus de couleurs a la base.
        if oInputParameterHandler.getValue('sMovieTitle'):
            meta['title'] = oInputParameterHandler.getValue('sMovieTitle')
        else:
            meta['title'] = xbmc.getInfoLabel('ListItem.title')

        meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)')
        meta['fanart'] =  xbmc.getInfoLabel('ListItem.Art(fanart)')
        try:
            cDb().insert_favorite(meta)
        except:
            pass
Beispiel #4
0
    def viewSimil(self):
        sPluginPath = cPluginHandler().getPluginPath()

        oInputParameterHandler = cInputParameterHandler()
        sCleanTitle = oInputParameterHandler.getValue(
            'sFileName') if oInputParameterHandler.exist(
                'sFileName') else xbmc.getInfoLabel(
                    'ListItem.Property(sCleanTitle)')
        sCat = oInputParameterHandler.getValue(
            'sCat') if oInputParameterHandler.exist(
                'sCat') else xbmc.getInfoLabel('ListItem.Property(sCat)')

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('searchtext', sCleanTitle)
        oOutputParameterHandler.addParameter('sCat', sCat)
        oOutputParameterHandler.addParameter('readdb', 'False')

        sParams = oOutputParameterHandler.getParameterAsUri()
        sTest = '%s?site=%s&function=%s&%s' % (sPluginPath, 'globalSearch',
                                               'globalSearch', sParams)

        # Si lancé depuis la page Home de Kodi, il faut d'abord en sortir pour lancer la recherche
        if xbmc.getCondVisibility('Window.IsVisible(home)'):
            xbmc.executebuiltin('ActivateWindow(%d)' % (10028))

        xbmc.executebuiltin('Container.Update(%s)' % sTest)

        return False
Beispiel #5
0
    def setBookmark(self):
        oInputParameterHandler = cInputParameterHandler()

        #         Pour quelle raison ? A expliquer en commentaire si cela est toujours vrai
        #         if oInputParameterHandler.getValue('sId') == 'kepliz_com':
        #             self.DIALOG.VSinfo('Error', self.ADDON.VSlang(30037))
        #             return

        if int(oInputParameterHandler.getValue('sCat')) < 1:
            self.DIALOG.VSinfo('Error', self.ADDON.VSlang(30038))
            return

        meta = {}
        meta['siteurl'] = oInputParameterHandler.getValue('siteUrl')
        meta['site'] = oInputParameterHandler.getValue('sId')
        meta['fav'] = oInputParameterHandler.getValue('sFav')
        meta['cat'] = oInputParameterHandler.getValue('sCat')

        # ListItem.title contient des code de couleurs, sMovieTitle le titre en plus "propre"
        # Inutile a la prochaine version, car plus de couleurs a la base.
        if oInputParameterHandler.getValue('sMovieTitle'):
            meta['title'] = oInputParameterHandler.getValue('sMovieTitle')
        else:
            meta['title'] = xbmc.getInfoLabel('ListItem.title')

        meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)')
        meta['fanart'] = xbmc.getInfoLabel('ListItem.Art(fanart)')
        try:
            cDb().insert_bookmark(meta)
        except:
            pass
    def delBookmarkMenu(self):
        if not self.DIALOG.VSyesno(self.ADDON.VSlang(30456)):
            return False

        sTitle = xbmc.getInfoLabel('ListItem.Property(sCleanTitle)')
        siteUrl = xbmc.getInfoLabel('ListItem.Property(siteUrl)')

        cDb().del_bookmark(siteUrl, sTitle)

        return True
Beispiel #7
0
    def delViewingMenu(self):
        sTitle = xbmc.getInfoLabel('ListItem.OriginalTitle')
        if not sTitle:  # confirmation if delete ALL
            if not self.DIALOG.VSyesno(self.ADDON.VSlang(30456)):
                return False
        sCat = xbmc.getInfoLabel('ListItem.Property(sCat)')
        meta = {}
        meta['titleWatched'] = sTitle
        meta['cat'] = sCat
        if cDb().del_viewing(meta):
            self.DIALOG.VSinfo(addon().VSlang(30072))
            cGui().updateDirectory()

        return True
Beispiel #8
0
    def viewInfo(self):
        from resources.lib.config import WindowsBoxes

        oInputParameterHandler = cInputParameterHandler()
        sCleanTitle = oInputParameterHandler.getValue(
            'sFileName') if oInputParameterHandler.exist(
                'sFileName') else xbmc.getInfoLabel(
                    'ListItem.Property(sCleanTitle)')
        sMeta = oInputParameterHandler.getValue(
            'sMeta') if oInputParameterHandler.exist(
                'sMeta') else xbmc.getInfoLabel('ListItem.Property(sMeta)')
        sYear = oInputParameterHandler.getValue(
            'sYear') if oInputParameterHandler.exist(
                'sYear') else xbmc.getInfoLabel('ListItem.Year')

        WindowsBoxes(sCleanTitle, sCleanTitle, sMeta, sYear)
Beispiel #9
0
    def setWatched(self):
        if (True):
            #Use database
            oInputParameterHandler = cInputParameterHandler()

            aParams = oInputParameterHandler.getAllParameter()

            sSite = oInputParameterHandler.getValue('siteUrl')
            sTitle = xbmc.getInfoLabel('ListItem.label')

            meta = {}
            meta['title'] = sTitle
            meta['site'] = sSite

            row = cDb().get_watched(meta)
            if row:
                cDb().del_watched(meta)
                cDb().del_resume(meta)
            else:
                cDb().insert_watched(meta)
                
            xbmc.executebuiltin( 'Action(ToggleWatched)' )
            
        else:
            # Use kodi buildin feature
            xbmc.executebuiltin( 'Action(ToggleWatched)' )
Beispiel #10
0
    def setWatched(self):
        if (True):
            #Use database
            oInputParameterHandler = cInputParameterHandler()

            aParams = oInputParameterHandler.getAllParameter()

            sSite = oInputParameterHandler.getValue('siteUrl')
            sTitle = xbmc.getInfoLabel('ListItem.label')

            meta = {}
            meta['title'] = sTitle
            meta['site'] = sSite

            row = cDb().get_watched(meta)
            if row:
                cDb().del_watched(meta)
                cDb().del_resume(meta)
            else:
                cDb().insert_watched(meta)

            xbmc.executebuiltin('Action(ToggleWatched)')

        else:
            # Use kodi buildin feature
            xbmc.executebuiltin('Action(ToggleWatched)')
Beispiel #11
0
    def AddtoDownloadList(self):

        oInputParameterHandler = cInputParameterHandler()
        sMediaUrl = oInputParameterHandler.getValue('sMediaUrl')
        sFileName = oInputParameterHandler.getValue('sFileName')
        # sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier')
        #bGetRedirectUrl = oInputParameterHandler.getValue('bGetRedirectUrl')

        #if (bGetRedirectUrl == 'True'):
        #    sMediaUrl = self.__getRedirectUrl(sMediaUrl)

        VSlog('Téléchargement ' + sMediaUrl)

        meta = {}
        meta['url'] = sMediaUrl
        meta['cat'] = oInputParameterHandler.getValue('sCat')
        meta['title'] = sFileName
        meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)')

        if (self.AddDownload(meta)):
            #telechargement direct ou pas?
            if not self.isDownloading():
                row = cDb().get_Download(meta)
                if row:
                    self.StartDownloadOneFile(row[0])

        return
Beispiel #12
0
    def AddtoDownloadList(self):

        oInputParameterHandler = cInputParameterHandler()

        sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier')
        sMediaUrl = oInputParameterHandler.getValue('sMediaUrl')
        #bGetRedirectUrl = oInputParameterHandler.getValue('bGetRedirectUrl')
        sFileName = oInputParameterHandler.getValue('sFileName')

        #if (bGetRedirectUrl == 'True'):
        #    sMediaUrl = self.__getRedirectUrl(sMediaUrl)

        VSlog("Telechargement " + sMediaUrl)

        meta = {}
        meta['url'] = sMediaUrl
        meta['cat'] = oInputParameterHandler.getValue('sCat')
        meta['title'] = sFileName
        meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)')

        if (self.AddDownload(meta)):
            #telechargement direct ou pas ?
            if not self.isDownloading():
                row = cDb().get_Download(meta)
                if row:
                    self.StartDownloadOneFile(row[0])

        return
Beispiel #13
0
    def AddtoDownloadListandview(self):

        oInputParameterHandler = cInputParameterHandler()
        sMediaUrl = oInputParameterHandler.getValue('sMediaUrl')
        sFileName = oInputParameterHandler.getValue('sFileName')
        # sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier')

        VSlog('Téléchargement ' + 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 = urllib.unquote_plus(row[0][2])
                    path = row[0][3]
                    #thumbnail = urllib.unquote_plus(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('Echec du téléchargement', 'Erreur')
        return
Beispiel #14
0
    def showChangelog(self):

        sUrl = 'https://raw.githubusercontent.com/zombiB/zombi-addons/master/plugin.video.matrix/changelog.txt'
        oRequest = urllib2.Request(sUrl)
        oResponse = urllib2.urlopen(oRequest)
        DIALOG = dialog()

        # En python 3 on doit décoder la reponse
        if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
            sContent = oResponse.read().decode('utf-8')
        else:
            sContent = oResponse.read()

        ret = DIALOG.VStextView(sContent)
Beispiel #15
0
    def decode(self, elem, Unicode=False):
        if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
            return elem
        else:
            if Unicode == True:

                try:
                    elem = unicodedata.normalize('NFD', unicode(elem)).encode('ascii', 'ignore').decode('unicode_escape')
                except UnicodeDecodeError:
                    elem = elem.decode('utf-8')
                except:
                    pass

            return elem.encode('utf-8')
    def setTitle(self, sTitle):
        #Convertie les bytes en strs pour le replace.
        if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
            if isinstance(sTitle, bytes):
                sTitle = sTitle.decode('utf-8')

        self.__sCleanTitle = sTitle.replace('[]', '').replace('()', '').strip()
        try:
            sTitle = sTitle.strip().decode('utf-8')
        except:
            pass

        if not sTitle.startswith('[COLOR'):
            self.__sTitle = self.TraiteTitre(sTitle)
        else:
            self.__sTitle = sTitle
Beispiel #17
0
def play__():#Lancer les liens

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl').replace('P_L_U_S', '+')
    sTitle = oInputParameterHandler.getValue('sMovieTitle')
    sThumbnail = oInputParameterHandler.getValue('sThumbnail')

    #Special url with tag
    if '[' in sUrl and ']' in sUrl:
        sUrl = GetRealUrl(sUrl)
    elif not xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
        stype = ''
        if '.ts' in sUrl:
            stype = 'TSDOWNLOADER'
        elif '.m3u' in sUrl:
            pass
        if stype:
            from F4mProxy import f4mProxyHelper
            f4mp = f4mProxyHelper()
            xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc = True)
            f4mp.playF4mLink(sUrl, sTitle, proxy = None, use_proxy_for_chunks = False, maxbitrate = 0, simpleDownloader = True, auth = None, streamtype = stype, setResolved = True, swf = None, callbackpath = '', callbackparam = '', iconImage = sThumbnail)
            return

    if 'dailymotion' in sUrl:
        showDailymotionStream(sUrl, sTitle, sThumbnail)
        return

    if 'f4mTester' in sUrl:
        xbmc.executebuiltin('XBMC.RunPlugin(' + sUrl + ')')
        return
    else:
        oGuiElement = cGuiElement()
        oGuiElement.setSiteName(SITE_IDENTIFIER)
        oGuiElement.setTitle(sTitle)
        sUrl = sUrl.replace(' ', '%20')
        oGuiElement.setMediaUrl(sUrl)
        oGuiElement.setThumbnail(sThumbnail)

        oPlayer = cPlayer()
        oPlayer.clearPlayList()
        oPlayer.addItemToPlaylist(oGuiElement)
        oPlayer.startPlayer()
        return
Beispiel #18
0
    def CheckIfActive(self, html):
        try:
            html = html.decode("utf-8")
        except:
            pass

        try:
            html = html.encode("utf-8")
        except:
            pass

        if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
            try:
                html = str(html, "utf-8")
            except:
                pass

        if 'stormwall' in str(html):
            return True
        return False
                def onInit(self):

                    self.container = self.getControl(6)
                    self.button = self.getControl(5)
                    self.getControl(3).setVisible(False)
                    self.getControl(1).setLabel('ChangeLog')
                    self.button.setLabel('OK')

                    sUrl = 'https://api.github.com/repos/Kodi-vStream/venom-xbmc-addons/commits'
                    oRequest = urllib2.Request(sUrl)
                    oResponse = urllib2.urlopen(oRequest)

                    # En python 3 on doit décoder la reponse
                    if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                        sContent = oResponse.read().decode('utf-8')
                    else:
                        sContent = oResponse.read()

                    result = json.loads(sContent)
                    listitems = []

                    for item in result:
                        # autor
                        icon = item['author']['avatar_url']
                        login = item['author']['login']
                        # message
                        try:
                            desc = item['commit']['message'].encode("utf-8")
                        except:
                            desc = 'None'

                        listitem = xbmcgui.ListItem(label=login, label2=desc)
                        listitem.setArt({'icon': icon, 'thumb': icon})

                        listitems.append(listitem)

                    self.container.addItems(listitems)
                    self.setFocus(self.container)
Beispiel #20
0
    def setWatched(self):

        oInputParameterHandler = cInputParameterHandler()

        aParams = oInputParameterHandler.getAllParameter()
        # import xbmc
        # xbmc.log(str(aParams))

        sSite = oInputParameterHandler.getValue('siteUrl')
        sTitle = xbmc.getInfoLabel('ListItem.label')

        meta = {}
        meta['title'] = sTitle
        meta['site'] = sSite

        row = cDb().get_watched(meta)
        if row:
            cDb().del_watched(meta)
            cDb().del_resume(meta)
        else:
            cDb().insert_watched(meta)

        xbmc.executebuiltin( 'Container.Refresh' )
Beispiel #21
0
 def __init__(self, *args):
     
     sPlayerType = self.__getPlayerType()
     xbmc.Player.__init__(self,sPlayerType)
     
     self.Subtitles_file = []
     self.SubtitleActive = False
     
     oInputParameterHandler = cInputParameterHandler()
     #aParams = oInputParameterHandler.getAllParameter()
     #xbmc.log(str(aParams))
     
     self.sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier')
     self.sTitle = oInputParameterHandler.getValue('sTitle')
     #self.sSite = oInputParameterHandler.getValue('site')
     self.sSite = oInputParameterHandler.getValue('siteUrl')
     self.sThumbnail = xbmc.getInfoLabel('ListItem.Art(thumb)')
     
     self.playBackEventReceived = False
     self.playBackStoppedEventReceived = False
     self.forcestop = False        
     
     VSlog("player initialized")
Beispiel #22
0
 def __init__(self, *args):
     
     sPlayerType = self.__getPlayerType()
     xbmc.Player.__init__(self,sPlayerType)
     
     self.Subtitles_file = []
     self.SubtitleActive = False
     
     oInputParameterHandler = cInputParameterHandler()
     #aParams = oInputParameterHandler.getAllParameter()
     #xbmc.log(str(aParams))
     
     self.sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier')
     self.sTitle = oInputParameterHandler.getValue('sTitle')
     #self.sSite = oInputParameterHandler.getValue('site')
     self.sSite = oInputParameterHandler.getValue('siteUrl')
     self.sThumbnail = xbmc.getInfoLabel('ListItem.Art(thumb)')
     
     self.playBackEventReceived = False
     self.playBackStoppedEventReceived = False
     self.forcestop = False        
     
     VSlog("player initialized")
Beispiel #23
0
def showIptvSite():
    oGui = cGui()

    #test f4mTester
    sPath = 'special://home/addons/plugin.video.f4mTester/default.py'

    if not xbmcvfs.exists(sPath) and not xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
        oGui.addText(SITE_IDENTIFIER, "[COLOR red]plugin.video.f4mTester: L'addon n'est pas présent[/COLOR]")

    liste = []
    liste.append( ['IptvGratuit', 'iptv_gratuit'] )
    liste.append( ['IptvSource', 'iptv_source'] )
    liste.append( ['Iptv4Sat', 'iptv_four_sat'] )
    liste.append( ['Daily Iptv List', 'daily_iptv_list'])
    liste.append( ['Extinf', 'iptv'])
    liste.append( ['ChannelStream', 'channelstream'])

    for sTitle, Fname in liste:

        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('siteUrl', 'http://venom')
        oGui.addDir(Fname, 'load', sTitle, 'tv.png', oOutputParameterHandler)

    oGui.setEndOfDirectory()
Beispiel #24
0
    def getInfoLabel(self):
        meta = {
            'title': xbmc.getInfoLabel('ListItem.title'),
            #'label': xbmc.getInfoLabel('ListItem.title'),
            'originaltitle': xbmc.getInfoLabel('ListItem.originaltitle'),
            'year': xbmc.getInfoLabel('ListItem.year'),
            'genre': xbmc.getInfoLabel('ListItem.genre'),
            'director': xbmc.getInfoLabel('ListItem.director'),
            'country': xbmc.getInfoLabel('ListItem.country'),
            'rating': xbmc.getInfoLabel('ListItem.rating'),
            'votes': xbmc.getInfoLabel('ListItem.votes'),
            'mpaa': xbmc.getInfoLabel('ListItem.mpaa'),
            'duration': xbmc.getInfoLabel('ListItem.duration'),
            'trailer': xbmc.getInfoLabel('ListItem.trailer'),
            'writer': xbmc.getInfoLabel('ListItem.writer'),
            'studio': xbmc.getInfoLabel('ListItem.studio'),
            'tagline': xbmc.getInfoLabel('ListItem.tagline'),
            'plotoutline': xbmc.getInfoLabel('ListItem.plotoutline'),
            'plot': xbmc.getInfoLabel('ListItem.plot'),
            'cover_url': xbmc.getInfoLabel('ListItem.Art(thumb)'),
            'backdrop_url': xbmc.getInfoLabel('ListItem.Art(fanart)'),
            'imdb_id': xbmc.getInfoLabel('ListItem.IMDBNumber'),
            'season': xbmc.getInfoLabel('ListItem.season'),
            'episode': xbmc.getInfoLabel('ListItem.episode')
        }

        if meta['title']:
            meta['title'] = self.getTitle()

        for key, value in meta.items():
            self.addItemValues(key, value)

        if meta['backdrop_url']:
            self.addItemProperties('fanart_image', meta['backdrop_url'])
            self.__sFanart = meta['backdrop_url']
        if meta['trailer']:
            meta['trailer'] = meta['trailer'].replace(u'\u200e', '').replace(
                u'\u200f', '')
            self.__sTrailerUrl = meta['trailer']
        if meta['cover_url']:
            self.__sThumbnail = meta['cover_url']
            self.__sPoster = meta['cover_url']

        return
Beispiel #25
0
from resources.lib.comaddon import progress, xbmc, VSlog
from resources.lib.gui.gui import cGui
from resources.lib.gui.hoster import cHosterGui
from resources.lib.handler.inputParameterHandler import cInputParameterHandler
from resources.lib.handler.outputParameterHandler import cOutputParameterHandler
from resources.lib.handler.requestHandler import cRequestHandler
from resources.lib.parser import cParser
from resources.lib.util import cUtil, Unquote, QuotePlus, Noredirection

UA = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0'

# Make random url
s = 'azertyupqsdfghjkmwxcvbn23456789AZERTYUPQSDFGHJKMWXCVBN'
RandomKey = ''.join(random.choice(s) for i in range(32))

if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
    isPython3 = True
else:
    isPython3 = False

SITE_IDENTIFIER = 'ianime'
SITE_NAME = 'I anime'
SITE_DESC = 'Animés en streaming'

URL_MAIN = 'https://www.ianimes.org/'

MOVIE_MOVIE = (URL_MAIN + 'films.php?liste=' + RandomKey, 'ShowAlpha')
MOVIE_GENRES = (URL_MAIN, 'showGenresMovies')

SERIE_SERIES = (URL_MAIN + 'series.php?liste=' + RandomKey, 'ShowAlpha')
Beispiel #26
0
def WindowsBoxes(sTitle, sFileName, num,year = ''):

    ADDON = addon()
    DIALOG = dialog()

    #Presence de l'addon ExtendedInfo ?
    try:
        if (addon('script.extendedinfo') and ADDON.getSetting('extendedinfo-view') == 'true'):
            if num == "2":
                DIALOG.VSinfo('Lancement de ExtendInfo')
                xbmc.executebuiltin('XBMC.RunScript(script.extendedinfo, info=extendedtvinfo, name=%s)' % sFileName)
                return
            elif num == "1":
                DIALOG.VSinfo('Lancement de ExtendInfo')
                xbmc.executebuiltin('XBMC.RunScript(script.extendedinfo, info=extendedinfo, name=%s)' % sFileName)
                return
    except:
        pass

    #Sinon on gere par Vstream via la lib TMDB
    if num == "1":
        try:
            from resources.lib.tmdb import cTMDb
            grab = cTMDb()
            meta = grab.get_meta('movie', sFileName, '', xbmc.getInfoLabel('ListItem.Property(TmdbId)'))
        except:
            pass
    elif num == "2":
        try:
            from resources.lib.tmdb import cTMDb
            grab = cTMDb()
            meta = grab.get_meta('tvshow', sFileName, '', xbmc.getInfoLabel('ListItem.Property(TmdbId)'))
        except:
            pass

    #si rien ne marche
    if (not meta['imdb_id'] and not ['tmdb_id'] and not ['tvdb_id']):
        #dialog par defaut
        #xbmc.executebuiltin("Action(Info)")
        #fenetre d'erreur
        DIALOG.VSinfo(ADDON.VSlang(30204))

        return

    #affichage du dialog perso
    class XMLDialog(xbmcgui.WindowXMLDialog):

        ADDON = addon()
        """
        Dialog class that asks user about rating of movie.
        """
        def __init__(self, *args, **kwargs):
            xbmcgui.WindowXMLDialog.__init__( self )
            pass

        # def message(self, message):
            # """
            # Shows xbmc dialog with OK and message.
            # """
            # dialog = xbmcgui.Dialog()
            # dialog.ok(" My message title", message)
            # self.close()

        def onInit(self):
            #par default le resumer#
            color = ADDON.getSetting('deco_color')
            window(10000).setProperty('color', color)

            self.getControl(50).setVisible(False)
            self.getControl(5200).setVisible(False)
            #synopsis_first
            self.setFocusId(36)

            #self.getControl(50).reset()
            listitems = []
            cast = []

            try:
                for slabel, slabel2, sicon, sid in meta['cast']:
                    listitem_ = listitem(label = slabel, label2=slabel2, iconImage=sicon)
                #listitem.setInfo('video', {'Title': 'test', 'RatingAndVotes':'6.8'})
                    listitem_.setProperty('id', str(sid))
                    listitems.append(listitem_)
                    cast.append(slabel.encode('ascii', 'ignore'))
                self.getControl(50).addItems(listitems)
                window(10000).setProperty('ListItem.casting', str(cast))
            except: pass
            #title
            #self.getControl(1).setLabel(meta['title'])
            meta['title'] = sTitle

            #self.getControl(49).setVisible(True)
            #self.getControl(2).setImage(meta['cover_url'])
            #self.getControl(3).setLabel(meta['rating'])

            for e in meta:
                property = 'ListItem.%s' %(e)
                if isinstance(meta[e], unicode):
                    window(10000).setProperty(property, meta[e].encode('utf-8'))
                else:
                    window(10000).setProperty(property, str(meta[e]))


        def credit(self, meta=""):
            self.getControl(5200).reset()
            listitems = []

            try:
                for i in meta:
                    try:
                        sTitle = unicodedata.normalize('NFKD', i['title']).encode('ascii', 'ignore')
                    except: sTitle = "Aucune information"
                    try:
                        sThumbnail = 'https://image.tmdb.org/t/p/w342' + i['poster_path']
                    except:
                        sThumbnail = ''
                    sId = i['id']


                    listitem_ = listitem(label = sTitle, iconImage=sThumbnail)
                    try:
                        listitem_.setInfo('video', {'rating': i['vote_average'].encode('utf-8') })
                    except:
                        listitem_.setInfo('video', {'rating': str(i['vote_average'])})

                    #listitem.setProperty('id', str(sId))
                    listitems.append(listitem_)
                self.getControl(5200).addItems(listitems)

            except: pass
            self.getControl(5200).setVisible(True)
            self.setFocusId(5200)
            #self.setFocus(self.getControl(5200))


        def person(self, sid=""):
            from resources.lib.tmdb import cTMDb
            grab = cTMDb(lang='en')
            sUrl = 'person/' + str(sid)
            meta = grab.getUrl(sUrl)

            listitems = []

            try:
                try:
                    sTitle = unicodedata.normalize('NFKD', meta['name']).encode('ascii', 'ignore')
                except: sTitle = "Aucune information"
                #xbmcgui.Window(10000).setProperty('person_name', sTitle)
                try:
                    sThumbnail = 'https://image.tmdb.org/t/p/w396' + meta['profile_path']
                except:
                    sThumbnail = ''
                sId = meta['id']


                bio = meta['biography'].replace('\n\n', '[CR]').replace('\n', '[CR]')

                #self.getControl(5300).setLabel('[COLOR gold]test[/COLOR]')

                #window(10000).setProperty('biography', bio)
                window(10000).setProperty('birthday', meta['birthday'])
                window(10000).setProperty('place_of_birth', meta['place_of_birth'])
                window(10000).setProperty('deathday', meta['deathday'])

                #self.getControl(20).setVisible(True)
            except: pass


            #description
            #self.getControl(400).setText(meta['plot'])

        def onClick(self, controlId):
            print controlId
            if controlId == 5:
                self.getControl(400).setVisible(False)
                self.getControl(50).setVisible(True)
                self.setFocusId(20)
                return
            elif controlId == 20:
                self.getControl(50).setVisible(False)
                self.getControl(400).setVisible(True)
                self.setFocusId(5)
                return
            elif controlId == 7:
                self.getControl(50).setVisible(True)
                self.setFocusId(50)
                return
            elif controlId == 11:
                from resources.lib.ba import cShowBA
                cBA = cShowBA()
                cBA.SetSearch(sFileName)
                cBA.SearchBA()
                self.close()
                return
            elif controlId == 30:
                self.close()
                return
            elif controlId == 50:
                #print self.getControl(50).ListItem.Property('id')
                item = self.getControl(50).getSelectedItem()
                sid = item.getProperty('id')

                from resources.lib.tmdb import cTMDb
                grab = cTMDb()
                sUrl = 'person/' + str(sid) + '/movie_credits'
                try:
                    meta = grab.getUrl(sUrl)
                    meta = meta['cast']
                    self.credit(meta)
                except:
                    return
                #self.getControl(50).setVisible(True)
            #click sur similaire
            elif controlId == 9:
                #print self.getControl(9000).ListItem.tmdb_id
                sid = window(10000).getProperty("ListItem.tmdb_id")

                from resources.lib.tmdb import cTMDb
                grab = cTMDb()
                sUrl = 'movie/%s/similar' % str(sid)
                try:
                    meta = grab.getUrl(sUrl)
                    meta = meta['results']
                    if meta:
                        self.credit(meta)
                    else:
                        self.getControl(9).setLabel("Aucune Information")
                except: return
            #click sur recommendations
            elif controlId == 13:
                #print self.getControl(9000).ListItem.tmdb_id
                sid = window(10000).getProperty("ListItem.tmdb_id")

                from resources.lib.tmdb import cTMDb
                grab = cTMDb()
                sUrl = 'movie/%s/recommendations' % str(sid)
                try:
                    meta = grab.getUrl(sUrl)
                    meta = meta['results']
                    if meta:
                        self.credit(meta)
                    else:
                        self.getControl(13).setLabel("Aucune Information")

                except: return

            elif controlId == 5200:
            #click sur un film acteur
                import sys
                from resources.lib.util import cUtil
                item = self.getControl(5200).getSelectedItem()
                sTitle = item.getLabel()

                try:
                    sTitle = sTitle.encode("utf-8")
                    sTitle = cUtil().CleanName(sTitle)
                except: return

                sTest = '%s?site=globalSearch&searchtext=%s&sCat=1' % (sys.argv[0], sTitle)
                xbmc.executebuiltin('XBMC.Container.Update(%s)' % sTest )
                self.close()
                return

            #dans le futur permet de retourne le texte du film
            # elif controlId == 5200:
            #     item = self.getControl(5200).getSelectedItem()
            #     sid = item.getLabel()
            #     print sid
            #     return

        def onFocus(self, controlId):
            self.controlId = controlId
            if controlId != 5200:
                #self.getControl(5500).reset()
                self.getControl(5200).setVisible(False)
            if controlId != 50:
                self.getControl(50).setVisible(False)
            #if controlId == 50:
                #item = self.getControl(50).getSelectedItem()
                #sid = item.getProperty('id')
                #self.person(sid)

        def _close_dialog( self ):
            self.close()

        def onAction( self, action ):
            if action.getId() in ( 104, 105, 1, 2):
                # if self.controlId == 50:
                #     item = self.getControl(50).getSelectedItem()
                #     sid = item.getProperty('id')
                #     self.person(sid)
                return

            if action.getId() in ( 9, 10, 11, 30, 92, 216, 247, 257, 275, 61467, 61448, ):
                self.close()


    #path = xbmc.translatePath("special://home/addons/plugin.video.vstream").decode("utf-8")
    path = "special://home/addons/plugin.video.vstream"
    #self.__oPath.decode("utf-8")
    wd = XMLDialog('DialogInfo2.xml', path , 'default', '720p')
    wd.doModal()
    del wd
    def main(self, env):

        if (env == 'urlresolver'):
            addon('script.module.urlresolver').openSettings()
            return

        elif (env == 'metahandler'):
            addon('script.module.metahandler').openSettings()
            return

        elif (env == 'changelog_old'):
            try:
                sUrl = 'https://raw.githubusercontent.com/Kodi-vStream/venom-xbmc-addons/master/plugin.video.vstream/changelog.txt'
                oRequest = urllib2.Request(sUrl)
                oResponse = urllib2.urlopen(oRequest)

                # En python 3 on doit décoder la reponse
                if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                    sContent = oResponse.read().decode('utf-8')
                else:
                    sContent = oResponse.read()

                self.TextBoxes('vStream Changelog', sContent)
            except:
                self.DIALOG.VSerror("%s, %s" %
                                    (self.ADDON.VSlang(30205), sUrl))
            return

        elif (env == 'changelog'):

            class XMLDialog(xbmcgui.WindowXMLDialog):
                def __init__(self, *args, **kwargs):
                    xbmcgui.WindowXMLDialog.__init__(self)
                    pass

                def onInit(self):

                    self.container = self.getControl(6)
                    self.button = self.getControl(5)
                    self.getControl(3).setVisible(False)
                    self.getControl(1).setLabel('ChangeLog')
                    self.button.setLabel('OK')

                    sUrl = 'https://api.github.com/repos/Kodi-vStream/venom-xbmc-addons/commits'
                    oRequest = urllib2.Request(sUrl)
                    oResponse = urllib2.urlopen(oRequest)

                    # En python 3 on doit décoder la reponse
                    if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                        sContent = oResponse.read().decode('utf-8')
                    else:
                        sContent = oResponse.read()

                    result = json.loads(sContent)
                    listitems = []

                    for item in result:
                        # autor
                        icon = item['author']['avatar_url']
                        login = item['author']['login']
                        # message
                        try:
                            desc = item['commit']['message'].encode("utf-8")
                        except:
                            desc = 'None'

                        listitem = xbmcgui.ListItem(label=login, label2=desc)
                        listitem.setArt({'icon': icon, 'thumb': icon})

                        listitems.append(listitem)

                    self.container.addItems(listitems)
                    self.setFocus(self.container)

                def onClick(self, controlId):
                    self.close()
                    return

                def onFocus(self, controlId):
                    self.controlId = controlId

                def _close_dialog(self):
                    self.close()

            path = "special://home/addons/plugin.video.vstream"
            wd = XMLDialog('DialogSelect.xml', path, "Default")
            wd.doModal()
            del wd
            return

        elif (env == 'soutient'):
            try:
                sUrl = 'https://raw.githubusercontent.com/Kodi-vStream/venom-xbmc-addons/master/plugin.video.vstream/soutient.txt'
                oRequest = urllib2.Request(sUrl)
                oResponse = urllib2.urlopen(oRequest)

                # En python 3 on doit décoder la reponse
                if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                    sContent = oResponse.read().decode('utf-8')
                else:
                    sContent = oResponse.read()

                self.TextBoxes('vStream Soutient', sContent)
            except:
                self.DIALOG.VSerror("%s, %s" %
                                    (self.ADDON.VSlang(30205), sUrl))
            return

        elif (env == 'addon'):  # Vider le cache des métadonnées
            if self.DIALOG.VSyesno(self.ADDON.VSlang(30456)):
                cached_Cache = "special://home/userdata/addon_data/plugin.video.vstream/video_cache.db"
                # important seul xbmcvfs peux lire le special
                try:
                    cached_Cache = VSPath(cached_Cache).decode("utf-8")
                except AttributeError:
                    cached_Cache = VSPath(cached_Cache)

                try:
                    db = sqlite.connect(cached_Cache)
                    dbcur = db.cursor()
                    dbcur.execute('DELETE FROM movie')
                    dbcur.execute('DELETE FROM tvshow')
                    dbcur.execute('DELETE FROM season')
                    dbcur.execute('DELETE FROM episode')
                    db.commit()
                    dbcur.close()
                    db.close()
                    self.DIALOG.VSinfo(self.ADDON.VSlang(30090))
                except:
                    self.DIALOG.VSerror(self.ADDON.VSlang(30091))
            return

        elif (env == 'clean'):
            liste = [
                'Historiques', 'Lecture en cours', 'Marqués vues',
                'Marque-Pages', 'Téléchargements'
            ]
            ret = self.DIALOG.VSselect(liste, self.ADDON.VSlang(30110))
            cached_DB = "special://home/userdata/addon_data/plugin.video.vstream/vstream.db"
            # important seul xbmcvfs peux lire le special
            try:
                cached_DB = VSPath(cached_DB).decode("utf-8")
            except AttributeError:
                cached_DB = VSPath(cached_DB)

            sql_drop = ""

            if ret > -1:

                if ret == 0:
                    sql_drop = 'DELETE FROM history'
                elif ret == 1:
                    sql_drop = 'DELETE FROM resume'
                elif ret == 2:
                    sql_drop = 'DELETE FROM watched'
                elif ret == 3:
                    sql_drop = 'DELETE FROM favorite'
                elif ret == 4:
                    sql_drop = 'DELETE FROM download'

                try:
                    db = sqlite.connect(cached_DB)
                    dbcur = db.cursor()
                    dbcur.execute(sql_drop)
                    db.commit()
                    dbcur.close()
                    db.close()
                    self.DIALOG.VSok(self.ADDON.VSlang(30090))
                except:
                    self.DIALOG.VSerror(self.ADDON.VSlang(30091))
            return

        elif (env == 'xbmc'):
            if self.DIALOG.VSyesno(self.ADDON.VSlang(30456)):
                path = "special://temp/"
                try:
                    xbmcvfs.rmdir(path, True)
                    self.DIALOG.VSok(self.ADDON.VSlang(30092))
                except:
                    self.DIALOG.VSerror(self.ADDON.VSlang(30093))
            return

        elif (env == 'fi'):
            if self.DIALOG.VSyesno(self.ADDON.VSlang(30456)):
                path = "special://temp/archive_cache/"
                try:
                    xbmcvfs.rmdir(path, True)
                    self.DIALOG.VSok(self.ADDON.VSlang(30095))
                except:
                    self.DIALOG.VSerror(self.ADDON.VSlang(30096))
            return

        elif (env == 'uplog'):
            if self.DIALOG.VSyesno(self.ADDON.VSlang(30456)):
                path = "special://logpath/kodi.log"
                UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0'
                headers = {'User-Agent': UA}
                if xbmcvfs.exists(path):
                    post_data = {}
                    cUrl = 'http://slexy.org/index.php/submit'
                    logop = xbmcvfs.File(path, 'rb')
                    result = logop.read()
                    logop.close()

                    oRequestHandler = cRequestHandler(cUrl)
                    oRequestHandler.setRequestType(1)
                    oRequestHandler.addHeaderEntry('User-Agent', UA)
                    oRequestHandler.addParameters('raw_paste', result)
                    oRequestHandler.addParameters('author', "kodi.log")
                    oRequestHandler.addParameters('language', "text")
                    oRequestHandler.addParameters('permissions', 1)  # private
                    oRequestHandler.addParameters('expire', 259200)  # 3j
                    oRequestHandler.addParameters('submit', 'Submit+Paste')
                    sHtmlContent = oRequestHandler.request()
                    code = oRequestHandler.getRealUrl().replace(
                        'http://slexy.org/view/', '')

                    self.ADDON.setSetting('service_log', code)
                    self.DIALOG.VSok(self.ADDON.VSlang(30097) + '  ' + code)
            return

        elif (env == 'search'):

            from resources.lib.handler.pluginHandler import cPluginHandler
            valid = '[COLOR green][x][/COLOR]'

            class XMLDialog(xbmcgui.WindowXMLDialog):

                ADDON = addon()

                def __init__(self, *args, **kwargs):
                    xbmcgui.WindowXMLDialog.__init__(self)
                    pass

                def onInit(self):

                    self.container = self.getControl(6)
                    self.button = self.getControl(5)
                    self.getControl(3).setVisible(False)
                    self.getControl(1).setLabel(self.ADDON.VSlang(30094))
                    self.button.setLabel('OK')
                    listitems = []
                    oPluginHandler = cPluginHandler()
                    aPlugins = oPluginHandler.getAllPlugins()

                    for aPlugin in aPlugins:
                        # teste si deja dans le dsip
                        sPluginSettingsName = 'plugin_' + aPlugin[1]
                        bPlugin = self.ADDON.getSetting(sPluginSettingsName)

                        icon = "special://home/addons/plugin.video.vstream/resources/art/sites/%s.png" % aPlugin[
                            1]
                        stitle = aPlugin[0].replace('[COLOR violet]', '').replace('[COLOR orange]', '')\
                                           .replace('[/COLOR]', '').replace('[COLOR dodgerblue]', '')\
                                           .replace('[COLOR coral]', '')
                        if (bPlugin == 'true'):
                            stitle = ('%s %s') % (stitle, valid)
                        listitem = xbmcgui.ListItem(label=stitle,
                                                    label2=aPlugin[2])
                        listitem.setArt({'icon': icon, 'thumb': icon})
                        listitem.setProperty('Addon.Summary', aPlugin[2])
                        listitem.setProperty('sitename', aPlugin[1])
                        if (bPlugin == 'true'):
                            listitem.select(True)

                        listitems.append(listitem)

                    self.container.addItems(listitems)
                    self.setFocus(self.container)

                def onClick(self, controlId):
                    if controlId == 5:
                        self.close()
                        return
                    elif controlId == 99:
                        window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
                        del window
                        self.close()
                        return
                    elif controlId == 7:
                        window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
                        del window
                        self.close()
                        return
                    elif controlId == 6:
                        item = self.container.getSelectedItem()
                        if item.isSelected() == True:
                            label = item.getLabel().replace(valid, '')
                            item.setLabel(label)
                            item.select(False)
                            sPluginSettingsName = ('plugin_%s') % (
                                item.getProperty('sitename'))
                            self.ADDON.setSetting(sPluginSettingsName,
                                                  str('false'))
                        else:
                            label = ('%s %s') % (item.getLabel(), valid)
                            item.setLabel(label)
                            item.select(True)
                            sPluginSettingsName = ('plugin_%s') % (
                                item.getProperty('sitename'))
                            self.ADDON.setSetting(sPluginSettingsName,
                                                  str('true'))
                        return

                def onFocus(self, controlId):
                    self.controlId = controlId

                def _close_dialog(self):
                    self.close()

                # def onAction(self, action):
                # if action.getId() in (9, 10, 92, 216, 247, 257, 275, 61467, 61448):
                # self.close()

            path = "special://home/addons/plugin.video.vstream"
            wd = XMLDialog('DialogSelect.xml', path, "Default")
            wd.doModal()
            del wd
            return

        elif (env == 'thumb'):

            if self.DIALOG.VSyesno(self.ADDON.VSlang(30098)):

                text = False
                path = "special://userdata/Thumbnails/"
                path_DB = "special://userdata/Database"
                try:
                    xbmcvfs.rmdir(path, True)
                    text = 'Clear Thumbnail Folder, Successful[CR]'
                except:
                    text = 'Clear Thumbnail Folder, Error[CR]'

                folder, items = xbmcvfs.listdir(path_DB)
                items.sort()
                for sItemName in items:
                    if "extures" in sItemName:
                        cached_Cache = "/".join([path_DB, sItemName])
                        try:
                            xbmcvfs.delete(cached_Cache)
                            text += 'Clear Thumbnail DB, Successful[CR]'
                        except:
                            text += 'Clear Thumbnail DB, Error[CR]'

                if text:
                    text = "%s (Important relancer Kodi)" % text
                    self.DIALOG.VSok(text)
            return

        elif (env == 'sauv'):
            select = self.DIALOG.VSselect(['Import', 'Export'])
            DB = "special://home/userdata/addon_data/plugin.video.vstream/vstream.db"
            if select >= 0:
                new = self.DIALOG.browse(3, 'vStream', "files")
                if new:
                    try:
                        if select == 0:
                            xbmcvfs.delete(DB)
                            # copy(source, destination)--copy file to destination, returns true/false.
                            xbmcvfs.copy(new + 'vstream.db', DB)
                        elif select == 1:
                            # copy(source, destination)--copy file to destination, returns true/false.
                            xbmcvfs.copy(DB, new + 'vstream.db')
                        self.DIALOG.VSinfo(self.ADDON.VSlang(30099))
                    except:
                        self.DIALOG.VSerror(self.ADDON.VSlang(30100))

                return

        else:
            return

        return
Beispiel #28
0
def WindowsBoxes(sTitle, sFileName, num, year=''):

    ADDON = addon()
    DIALOG = dialog()

    # Presence de l'addon ExtendedInfo?
    try:
        if (addon('script.extendedinfo')
                and ADDON.getSetting('extendedinfo-view') == 'true'):
            if num == '2':
                DIALOG.VSinfo('Lancement de ExtendInfo')
                xbmc.executebuiltin(
                    'XBMC.RunScript(script.extendedinfo, info=extendedtvinfo, name=%s)'
                    % sFileName)
                return
            elif num == '1':
                DIALOG.VSinfo('Lancement de ExtendInfo')
                xbmc.executebuiltin(
                    'XBMC.RunScript(script.extendedinfo, info=extendedinfo, name=%s)'
                    % sFileName)
                return
    except:
        pass

    # Sinon on gere par vStream via la lib TMDB
    if num == '1':
        try:
            grab = cTMDb()
            meta = grab.get_meta(
                'movie', sFileName, '',
                xbmc.getInfoLabel('ListItem.Property(TmdbId)'))
        except:
            pass
    elif num == '2':
        try:
            grab = cTMDb()
            meta = grab.get_meta(
                'tvshow', sFileName, '',
                xbmc.getInfoLabel('ListItem.Property(TmdbId)'))
        except:
            pass

    # si rien ne marche
    if (not meta['imdb_id'] and not ['tmdb_id'] and not ['tvdb_id']):
        # dialog par defaut
        # xbmc.executebuiltin('Action(Info)')
        # fenetre d'erreur
        DIALOG.VSinfo(ADDON.VSlang(30204))

        return

    # affichage du dialog perso
    class XMLDialog(xbmcgui.WindowXMLDialog):

        ADDON = addon()
        """
        Dialog class that asks user about rating of movie.
        """
        def __init__(self, *args, **kwargs):
            xbmcgui.WindowXMLDialog.__init__(self)
            pass

        # def message(self, message):
        # """
        # Shows xbmc dialog with OK and message.
        # """
        # dialog = xbmcgui.Dialog()
        # dialog.ok(' My message title', message)
        # self.close()

        def onInit(self):
            # par default le resumer#
            color = ADDON.getSetting('deco_color')
            window(10000).setProperty('color', color)

            self.getControl(50).setVisible(False)
            self.getControl(5200).setVisible(False)
            # synopsis_first
            self.setFocusId(36)

            # self.getControl(50).reset()
            listitems = []
            cast = []

            try:
                for slabel, slabel2, sicon, sid in meta['cast']:
                    listitem_ = listitem(label=slabel,
                                         label2=slabel2,
                                         iconImage=sicon)
                    listitem_.setProperty('id', str(sid))
                    listitems.append(listitem_)
                    cast.append(slabel.encode('ascii', 'ignore'))
                self.getControl(50).addItems(listitems)
                window(10000).setProperty('ListItem.casting', str(cast))
            except:
                pass
            # title
            # self.getControl(1).setLabel(meta['title'])
            meta['title'] = sTitle

            # self.getControl(49).setVisible(True)
            # self.getControl(2).setImage(meta['cover_url'])
            # self.getControl(3).setLabel(meta['rating'])

            for e in meta:
                property = 'ListItem.%s' % (e)
                if isinstance(meta[e], unicode):
                    window(10000).setProperty(property,
                                              meta[e].encode('utf-8'))
                else:
                    window(10000).setProperty(property, str(meta[e]))

        def credit(self, meta=''):
            self.getControl(5200).reset()
            listitems = []

            try:
                for i in meta:
                    try:
                        sTitle = unicodedata.normalize('NFKD',
                                                       i['title']).encode(
                                                           'ascii', 'ignore')
                    except:
                        sTitle = 'Aucune information'
                    try:
                        sThumbnail = 'https://image.tmdb.org/t/p/w342' + i[
                            'poster_path']
                    except:
                        sThumbnail = ''
                    sId = i['id']

                    listitem_ = listitem(label=sTitle, iconImage=sThumbnail)
                    try:
                        listitem_.setInfo(
                            'video',
                            {'rating': i['vote_average'].encode('utf-8')})
                    except:
                        listitem_.setInfo('video',
                                          {'rating': str(i['vote_average'])})

                    listitems.append(listitem_)
                self.getControl(5200).addItems(listitems)

            except:
                pass
            self.getControl(5200).setVisible(True)
            self.setFocusId(5200)
            # self.setFocus(self.getControl(5200))

        def person(self, sid=''):
            grab = cTMDb(lang='en')
            sUrl = 'person/' + str(sid)
            meta = grab.getUrl(sUrl)

            try:
                try:
                    sTitle = unicodedata.normalize('NFKD',
                                                   meta['name']).encode(
                                                       'ascii', 'ignore')
                except:
                    sTitle = 'Aucune information'
                try:
                    sThumbnail = 'https://image.tmdb.org/t/p/w396' + meta[
                        'profile_path']
                except:
                    sThumbnail = ''

                sId = meta['id']
                # bio = meta['biography'].replace('\n\n', '[CR]').replace('\n', '[CR]')

                # self.getControl(5300).setLabel('[COLOR gold]test[/COLOR]')

                # window(10000).setProperty('biography', bio)
                window(10000).setProperty('birthday', meta['birthday'])
                window(10000).setProperty('place_of_birth',
                                          meta['place_of_birth'])
                window(10000).setProperty('deathday', meta['deathday'])
            except:
                pass

        def onClick(self, controlId):
            print(controlId)
            if controlId == 5:
                self.getControl(400).setVisible(False)
                self.getControl(50).setVisible(True)
                self.setFocusId(20)
                return
            elif controlId == 20:
                self.getControl(50).setVisible(False)
                self.getControl(400).setVisible(True)
                self.setFocusId(5)
                return
            elif controlId == 7:
                self.getControl(50).setVisible(True)
                self.setFocusId(50)
                return
            elif controlId == 11:
                from resources.lib.ba import cShowBA
                cBA = cShowBA()
                cBA.SetSearch(sFileName)
                cBA.SearchBA()
                self.close()
                return
            elif controlId == 30:
                self.close()
                return
            elif controlId == 50:
                # print(self.getControl(50).ListItem.Property('id'))
                item = self.getControl(50).getSelectedItem()
                sid = item.getProperty('id')

                grab = cTMDb()
                sUrl = 'person/' + str(sid) + '/movie_credits'
                try:
                    meta = grab.getUrl(sUrl)
                    meta = meta['cast']
                    self.credit(meta)
                except:
                    return
                # self.getControl(50).setVisible(True)
            # click sur similaire
            elif controlId == 9:
                # print(self.getControl(9000).ListItem.tmdb_id)
                sid = window(10000).getProperty('ListItem.tmdb_id')

                grab = cTMDb()
                sUrl = 'movie/%s/similar' % str(sid)
                try:
                    meta = grab.getUrl(sUrl)
                    meta = meta['results']
                    if meta:
                        self.credit(meta)
                    else:
                        self.getControl(9).setLabel('Aucune Information')
                except:
                    return
            # click sur recommendations
            elif controlId == 13:
                # print(self.getControl(9000).ListItem.tmdb_id)
                sid = window(10000).getProperty('ListItem.tmdb_id')

                grab = cTMDb()
                sUrl = 'movie/%s/recommendations' % str(sid)
                try:
                    meta = grab.getUrl(sUrl)
                    meta = meta['results']
                    if meta:
                        self.credit(meta)
                    else:
                        self.getControl(13).setLabel('Aucune Information')

                except:
                    return

            elif controlId == 5200:
                # click sur un film acteur
                import sys
                from resources.lib.util import cUtil
                item = self.getControl(5200).getSelectedItem()
                sTitle = item.getLabel()

                try:
                    sTitle = sTitle.encode('utf-8')
                    sTitle = cUtil().CleanName(sTitle)
                except:
                    return

                sTest = '%s?site=globalSearch&searchtext=%s&sCat=1' % (
                    sys.argv[0], sTitle)
                xbmc.executebuiltin('XBMC.Container.Update(%s)' % sTest)
                self.close()
                return

            # dans le futur permet de retourne le texte du film
            # elif controlId == 5200:
            #     item = self.getControl(5200).getSelectedItem()
            #     sid = item.getLabel()
            #     print(sid)
            #     return

        def onFocus(self, controlId):
            self.controlId = controlId
            if controlId != 5200:
                # self.getControl(5500).reset()
                self.getControl(5200).setVisible(False)
            if controlId != 50:
                self.getControl(50).setVisible(False)
            # if controlId == 50:
            # item = self.getControl(50).getSelectedItem()
            # sid = item.getProperty('id')
            # self.person(sid)

        def _close_dialog(self):
            self.close()

        def onAction(self, action):
            if action.getId() in (104, 105, 1, 2):
                # if self.controlId == 50:
                #     item = self.getControl(50).getSelectedItem()
                #     sid = item.getProperty('id')
                #     self.person(sid)
                return

            if action.getId() in (9, 10, 11, 30, 92, 216, 247, 257, 275, 61467,
                                  61448):
                self.close()

    path = 'special://home/addons/plugin.video.vstream'
    # self.__oPath.decode('utf-8')
    wd = XMLDialog('DialogInfo2.xml', path, 'default', '720p')
    wd.doModal()
    del wd
Beispiel #29
0
def showMovies(sSearch=''):
    oGui = cGui()

    if sSearch:
        sUrl = URL_MAIN + 'search.php'
        oRequestHandler = cRequestHandler(sUrl)
        oRequestHandler.setRequestType(cRequestHandler.REQUEST_TYPE_POST)
        oRequestHandler.addParameters('q', Unquote(sSearch))
    else:
        oInputParameterHandler = cInputParameterHandler()
        sUrl = oInputParameterHandler.getValue('siteUrl')
        oRequestHandler = cRequestHandler(sUrl)

    oRequestHandler.addHeaderEntry('Referer', URL_MAIN)
    sHtmlContent = oRequestHandler.request()

    if sSearch:
        sPattern = '<a href="([^"]+)".+?url\((.+?)\).+?<div class="title"> (.+?) </div>'
    elif 'Annee/' in sUrl or '/ABC' in sUrl:
        sPattern = '<div class="table-movies-content.+?href="([^"]+)".+?url\((.+?)\).+?<.i>.([^<]+)'
    elif 'genre/' in sUrl:
        sPattern = 'film-uno.+?href="([^"]+)".+?data-src="([^"]+)".+?alt="([^"]+)'
    else:
        sPattern = '<a href="([^"]+)".+?data-src="([^"]+)".+?alt="([^"]+)".+?min.+?·([^<]+).+?short-story">([^<]+)'

    oParser = cParser()
    aResult = oParser.parse(sHtmlContent, sPattern)

    if (aResult[0] == False):
        oGui.addText(SITE_IDENTIFIER)

    if (aResult[0] == True):
        total = len(aResult[1])
        progress_ = progress().VScreate(SITE_NAME)
        for aEntry in aResult[1]:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sUrl = aEntry[0]
            sThumb = aEntry[1]
            sTitle = aEntry[2]
            sDesc = ''
            if len(aEntry) > 3:
                if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                    sQual = aEntry[3].split('·')[1].replace('Â', '').strip()
                    sLang = aEntry[3].split('·')[2].strip()
                else:
                    sQual = aEntry[3].split('·')[1].strip()
                    sLang = aEntry[3].split('·')[2].strip()

                sDesc = aEntry[4]

                sDisplayTitle = ('%s [%s] (%s)') % (sTitle, sQual, sLang)

            else:
                sDisplayTitle = sTitle

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sDesc', sDesc)
            oGui.addMovie(SITE_IDENTIFIER, 'showHoster', sDisplayTitle, '',
                          sThumb, sDesc, oOutputParameterHandler)
        progress_.VSclose(progress_)

    if not sSearch:
        sNextPage = __checkForNextPage(sHtmlContent)
        if (sNextPage != False):
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sNextPage)
            number = re.search('(page|genre).*?[-=\/]([0-9]+)',
                               sNextPage).group(
                                   2)  # ou replace'.html',''; '([0-9]+)$'
            oGui.addNext(SITE_IDENTIFIER, 'showMovies',
                         '[COLOR teal]Page ' + number + ' >>>[/COLOR]',
                         oOutputParameterHandler)

        oGui.setEndOfDirectory()
Beispiel #30
0
def parseM3U(sUrl=None, infile=None):#Traite les m3u local
    oGui = cGui()
    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    if infile == None:
        if 'iptv4sat' in sUrl or '.zip' in sUrl:
            sHtmlContent = getHtml(sUrl)
            zip_files = ZipFile(io.BytesIO(sHtmlContent))
            files = zip_files.namelist()

            for Title in files:
                oOutputParameterHandler = cOutputParameterHandler()
                oOutputParameterHandler.addParameter('sMovieTitle', Title)
                oOutputParameterHandler.addParameter('siteUrl', sUrl)

                oGui.addDir(SITE_IDENTIFIER, 'unZip', Title, 'tv.png', oOutputParameterHandler)

            oGui.setEndOfDirectory()
            return

        elif not '#EXTM3U' in sUrl:
            site = infile
            headers = {'User-Agent': UA}

            oRequestHandler = cRequestHandler(sUrl)
            oRequestHandler.addHeaderEntry('User-Agent', UA)
            inf = oRequestHandler.request()

            if 'drive.google' in inf:
                inf = unGoogleDrive(inf)

            inf = inf.split('\n')
        else:
            inf = infile

    else:
        inf = infile

    try:
        line = inf.readline()
    except:
        pass

    playlist = []
    song = track(None, None, None, None)
    ValidEntry = False

    for line in inf:
        if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
            try:
                line = line.decode('utf-8')
            except AttributeError:
                pass

        line = line.strip()
        if line.startswith('#EXTINF:'):
            length, title = line.split('#EXTINF:')[1].split(',', 1)
            try:
                licon = line.split('#EXTINF:')[1].partition('tvg-logo=')[2]
                icon = licon.split('"')[1]
            except:
                icon = 'tv.png'
            ValidEntry = True
            song = track(length, title, None, icon)

        elif (len(line) != 0):
            if (ValidEntry) and (not (line.startswith('!') or line.startswith('#'))):
                ValidEntry = False
                song.path = line
                playlist.append(song)
                #VSlog(playlist)
                song=track(None, None, None, None)

    try:
        inf.close()
    except:
        pass

    return playlist
Beispiel #31
0
 def RefreshDownloadList(self):
     #print xbmc.getInfoLabel('Container.FolderPath')
     if 'function=getDownload' in xbmc.getInfoLabel('Container.FolderPath'):
         VSupdate()
Beispiel #32
0
def showWeb(infile = None):#Code qui s'occupe de liens TV du Web
    oGui = cGui()
    oInputParameterHandler = cInputParameterHandler()

    if infile == None:
        sUrl = oInputParameterHandler.getValue('siteUrl')

        playlist = parseM3U(sUrl=sUrl)
    else:
        playlist = parseM3U(infile=infile)

    if (oInputParameterHandler.exist('AZ')):
        sAZ = oInputParameterHandler.getValue('AZ')
        string = filter(lambda t: t.title.strip().capitalize().startswith(sAZ), playlist)
        playlist = sorted(string, key = lambda t: t.title.strip().capitalize())
    else :
        playlist = sorted(playlist, key = lambda t: t.title.strip().capitalize())

    if not playlist:
        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('siteUrl', 'http://')
        oGui.addText(SITE_IDENTIFIER, '[COLOR red]Problème de lecture avec la playlist[/COLOR]')

    else:
        total = len(playlist)
        progress_ = progress().VScreate(SITE_NAME)
        for track in playlist:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break
            sThumb = track.icon
            if not sThumb:
                sThumb = 'tv.png'

            #les + ne peuvent pas passer
            url2 = track.path.replace('+', 'P_L_U_S')
            if not xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
                if not '[' in url2 and not ']' in url2 and not '.m3u8' in url2 and not 'dailymotion' in url2:
                    url2 = 'plugin://plugin.video.f4mTester/?url=' + QuotePlus(url2) + '&amp;streamtype=TSDOWNLOADER&name=' + Quote(track.title)

            thumb = '/'.join([sRootArt, sThumb])

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', url2)
            oOutputParameterHandler.addParameter('sMovieTitle', track.title)
            oOutputParameterHandler.addParameter('sThumbnail', thumb)

            #oGui.addDirectTV(SITE_IDENTIFIER, 'play__', track.title, 'tv.png' , sRootArt + '/tv/' + sThumb, oOutputParameterHandler)

            oGuiElement = cGuiElement()
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('play__')
            oGuiElement.setTitle(track.title)
            oGuiElement.setFileName(track.title)
            oGuiElement.setIcon('tv.png')
            oGuiElement.setMeta(0)
            oGuiElement.setThumbnail(thumb)
            oGuiElement.setDirectTvFanart()
            oGuiElement.setCat(6)

            oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, SITE_IDENTIFIER, SITE_IDENTIFIER, 'direct_epg', 'Guide tv Direct')
            oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, SITE_IDENTIFIER, SITE_IDENTIFIER, 'soir_epg', 'Guide tv Soir')
            oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, SITE_IDENTIFIER, SITE_IDENTIFIER, 'enregistrement', 'Enregistrement')
            oGui.createContexMenuFav(oGuiElement, oOutputParameterHandler)
            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    oGui.setEndOfDirectory()
Beispiel #33
0
def WindowsBoxes(sTitle, sFileName, metaType, year=''):

    ADDON = addon()
    DIALOG = dialog()

    # Presence de l'addon ExtendedInfo?
    try:
        if (addon('script.extendedinfo') and ADDON.getSetting('extendedinfo-view') == 'true'):

            if metaType == '2':
                DIALOG.VSinfo('Lancement de ExtendInfo')
                xbmc.executebuiltin('RunScript(script.extendedinfo, info=extendedtvinfo, name=%s)' % sFileName)
                return
            elif metaType == '1':
                DIALOG.VSinfo('Lancement de ExtendInfo')
                xbmc.executebuiltin('RunScript(script.extendedinfo, info=extendedinfo, name=%s)' % sFileName)
                return
    except:
        pass
    

    # Sinon on gere par matrix via la lib TMDB



    sType = str(metaType).replace('1', 'movie').replace('2', 'tvshow').replace('3', 'collection').replace('4', 'anime')

    try:
        meta = cTMDb().get_meta(sType, sFileName, tmdb_id = xbmc.getInfoLabel('ListItem.Property(TmdbId)'), year = year)



        try:


            meta['plot'] = str(meta['plot'].encode('latin-1'), 'utf-8')
        except:
            pass
    except:
        DIALOG.VSok("Veuillez vider le cache des métadonnées Paramètre - outils - 'vider le cache de matrix'")
        pass
        

    # si rien ne marche
    if (not meta['imdb_id'] and not meta['tmdb_id'] and not meta['tvdb_id']):
        # dialog par defaut
        # xbmc.executebuiltin('Action(Info)')
        # fenetre d'erreur
        DIALOG.VSinfo(ADDON.VSlang(30204))

        return

    # convertion de la date au format JJ/MM/AAAA
    if 'premiered' in meta and meta['premiered']:
        releaseDate = datetime(*(time.strptime(meta['premiered'], '%Y-%m-%d')[0:6]))
        meta['releaseDate'] = releaseDate.strftime('%d/%m/%Y')
    else:
        meta['releaseDate'] = '-'
         
    # convertion de la durée en secondes -> heure:minutes
    if 'duration' in meta and meta['duration']:
        duration = meta['duration']/60  # En minutes
        durationH = duration/60 # Nombre d'heures
        meta['durationH'] = durationH
        #Le resultat doit obligatoirement etre un int sous Py3.
        meta['durationM'] = '{:02d}'.format(int(duration - 60*durationH))
    else:
        meta['durationH'] = 0
        meta['durationM'] = 0


    # affichage du dialog perso
    class XMLDialog(xbmcgui.WindowXMLDialog):

        ADDON = addon()
        """
        Dialog class that asks user about rating of movie.
        """
        def __init__(self, *args, **kwargs):
            xbmcgui.WindowXMLDialog.__init__(self)
            pass

        # def message(self, message):
            # """
            # Shows xbmc dialog with OK and message.
            # """
            # dialog = xbmcgui.Dialog()
            # dialog.ok(' My message title', message)
            # self.close()

        def onInit(self):
            # par default le resumer#
            color = ADDON.getSetting('deco_color')
            self.setProperty('color', color)





            self.poster = 'https://image.tmdb.org/t/p/%s' % self.ADDON.getSetting('poster_tmdb')
            self.none_poster = 'https://eu.ui-avatars.com/api/?background=000&size=512&name=%s&color=FFF&font-size=0.33'

            #self.getControl(50).setVisible(False)


            #self.getControl(90).setVisible(False)
            #self.getControl(5200).setVisible(False)
            #self.getControl(52100).setVisible(False)
            #self.getControl(52200).setVisible(False)
            # synopsis_first
            self.setFocusId(9000)















#            self.getControl(50).reset()
            
            if 'credits' in meta and meta['credits']:
                cast = []
                crew = []



                #Decodage python 3
                try:
                    data = eval(str(meta['credits'].encode('latin-1'), 'utf-8'))
                except:
                    data = eval(str(meta['credits']))
    
                try:
                    listitems = []
                    for i in data['cast']:
                        slabel = i['name']
                        slabel2 = i['character']
                        if i['profile_path']:
                            sicon = self.poster+str(i['profile_path'])
                        else :
                            sicon = self.none_poster % slabel
                        sid = i['id']
                        listitem_ = listitem(label=slabel, label2=slabel2)
                        listitem_.setProperty('id', str(sid))
                        listitem_.setArt({'icon':sicon})
                        listitems.append(listitem_)
                        cast.append(slabel.encode('ascii', 'ignore'))
                    self.getControl(50).addItems(listitems)
                except:
                    pass
                
                try:
                    listitems2 = []
                    for i in data['crew']:
                        slabel = i['name']
                        slabel2 = i['job']
                        if i['profile_path']:
                            sicon = self.poster+str(i['profile_path'])
                        else :
                            sicon = self.none_poster % slabel
                        sid = i['id']
                        listitem_ = listitem(label=slabel, label2=slabel2)
                        listitem_.setProperty('id', str(sid))
                        listitem_.setArt({'icon':sicon})
                        listitems2.append(listitem_)
                        crew.append(slabel.encode('ascii', 'ignore'))
                    self.getControl(5200).addItems(listitems2)
                except:
                    pass

            # try:
            #     for slabel, slabel2, sicon, sid in meta['cast']:





            #         listitem_ = listitem(label=slabel, label2=slabel2, iconImage=sicon)
            #         listitem_.setProperty('id', str(sid))
            #         listitems.append(listitem_)
            #         cast.append(slabel.encode('ascii', 'ignore'))
            #     self.getControl(50).addItems(listitems)
            #     #self.setProperty('ListItem.casting', str(cast))
            # except:
            #     pass
            
            # title
            # self.getControl(1).setLabel(meta['title'])
            meta['title'] = sTitle
            
            # self.getControl(49).setVisible(True)
            # self.getControl(2).setImage(meta['cover_url'])
            # self.getControl(3).setLabel(meta['rating'])
            
            if 'rating' not in meta or meta['rating'] == 0:
                meta['rating'] = '-'
            if 'votes' not in meta or meta['votes'] == '0':
                meta['votes'] = '-'
 

            for prop in meta:
                #Py3 unicode == str.
                try:
                    if isinstance(meta[prop], unicode):
                        self.setProperty(prop, meta[prop].encode('utf-8'))
                    else:
                        self.setProperty(prop, str(meta[prop]))
                except:
                    if isinstance(meta[prop], str):
                        self.setProperty(prop, meta[prop].encode('utf-8'))
                    else:
                        self.setProperty(prop, str(meta[prop]))                    
                   
        def credit(self, meta='', control=''):
            #self.getControl(control).reset()
            listitems = []
            
            if not meta:
                meta = [{u'id': 0, u'title': u'Aucune information', u'poster_path': u'', u'vote_average':0}]

            try:
                for i in meta:
                    try:
                        sTitle = unicodedata.normalize('NFKD', i['title']).encode('ascii', 'ignore')



                    except:


                        sTitle = 'Aucune information'
                        
                    if i['poster_path']:
                        sThumbnail = self.poster+str(i['poster_path'])
                    else :
                        sThumbnail = self.none_poster % sTitle
                    
                    # sId = i['id']

                    listitem_ = listitem(label=sTitle)
                    try:
                        listitem_.setInfo('video', {'rating': i['vote_average'].encode('utf-8') })
                    except:
                        listitem_.setInfo('video', {'rating': str(i['vote_average'])})


                    listitem_.setArt({'icon':sThumbnail})
                    listitems.append(listitem_)
                self.getControl(control).addItems(listitems)



































            except:
                pass



            
            #self.getControl(52100).setVisible(False)
            #self.getControl(52200).setVisible(True)
            #self.setFocusId(5205)
            # self.setFocus(self.getControl(5200))

        def onClick(self, controlId):


            if controlId == 11:














                from resources.lib.ba import cShowBA
                cBA = cShowBA()
                cBA.SetSearch(sFileName)


                cBA.SetYear(year)
                cBA.SetTrailerUrl(self.getProperty('trailer'))
                cBA.SearchBA(True)
                return

            elif controlId == 30:
                self.close()
                return

            elif controlId == 50 or controlId == 5200 :
                # print(self.getControl(50).ListItem.Property('id'))
                item = self.getControl(controlId).getSelectedItem()
                sid = item.getProperty('id')
                

                grab = cTMDb()
                sUrl = 'person/' + str(sid)
                
                
                try:
                    meta = grab.getUrl(sUrl, '', "append_to_response=movie_credits,tv_credits")
                    meta_credits = meta['movie_credits']['cast']
                    self.credit(meta_credits, 5215)
                    
         
                    try:
                        sTitle = unicodedata.normalize('NFKD', meta['name']).encode('ascii', 'ignore')
                    except:
                        sTitle = 'Aucune information'
                    
                    if not meta['deathday']:
                        today = date.today()
                        try:
                            birthday = datetime(*(time.strptime(meta['birthday'], '%Y-%m-%d')[0:6]))
                            age = today.year - birthday.year - ((today.month, today.day) < (birthday.month, birthday.day))
                            age = '%s Ans' % age
                        except:
                            age = ''
                    else:
                        age = meta['deathday']
                        
                  
                    self.setProperty('Person_name', sTitle)
                    self.setProperty('Person_birthday', meta['birthday'])
                    self.setProperty('Person_place_of_birth', meta['place_of_birth'])
                    self.setProperty('Person_deathday', str(age))
                    self.setProperty('Person_biography', meta['biography']) 
                    self.setFocusId(9000)                   
       
                except:
                    return
                # self.getControl(50).setVisible(True)
                self.setProperty('matrix_menu', 'Person')
            
            # click sur similaire
            elif controlId == 9:
                # print(self.getControl(9000).ListItem.tmdb_id)
                sid = self.getProperty('tmdb_id')

                grab = cTMDb()
                sUrl_simil = 'movie/%s/similar' % str(sid)
                sUrl_recom = 'movie/%s/recommendations' % str(sid)
                
                try:
                    meta = grab.getUrl(sUrl_simil)
                    meta = meta['results']

                    self.credit(meta, 5205)


                except:








                    pass
                try:
                    meta = grab.getUrl(sUrl_recom)
                    meta = meta['results']

                    self.credit(meta, 5210)



                except:
                    return

            # click pour recherche
            elif controlId == 5215 or controlId == 5205 or controlId == 5210:


                import sys
                from resources.lib.util import cUtil
                item = self.getControl(controlId).getSelectedItem()
                sTitle = item.getLabel()

                try:
                    sTitle = sTitle.encode('utf-8')
                    sTitle = cUtil().CleanName(sTitle)
                except:
                    return



                self.close()



                # Si lancé depuis la page Home de Kodi, il faut d'abord en sortir pour lancer la recherche
                if xbmc.getCondVisibility('Window.IsVisible(home)'):
                    xbmc.executebuiltin('ActivateWindow(%d)' % (10028))

                sTest = '%s?site=globalSearch&searchtext=%s&sCat=1' % (sys.argv[0], sTitle)
                xbmc.executebuiltin('Container.Update(%s)' % sTest)
                return
            # elif controlId == 2:



            #     print("paseeeee")
            #     xbmc.executebuiltin('Dialog.Close(all, force)')
            #     xbmc.executebuiltin('ActivateWindow(12005)')
            #     return

        def onFocus(self, controlId):
            self.controlId = controlId
            #fullscreen end return focus menu
            if controlId == 40:


                while xbmc.Player().isPlaying():
                    xbmc.sleep(500)
                    if not xbmc.Player().isPlaying():
                        self.setFocusId(9000)
                    
            #if controlId != 5200:
                # self.getControl(5500).reset()
            #  self.getControl(5200).setVisible(False)
            # if controlId == 50:
                # item = self.getControl(50).getSelectedItem()
                # sid = item.getProperty('id')


        def _close_dialog(self):
            self.close()

        def onAction(self, action):
            if action.getId() in (104, 105, 1, 2):




                return

            if action.getId() in (9, 10, 11, 30, 92, 216, 247, 257, 275, 61467, 61448):
                self.close()



    path = 'special://home/addons/plugin.video.matrix'
    # self.__oPath.decode('utf-8')
    wd = XMLDialog('DialogInfo4.xml', path, 'default', '720p')
    wd.doModal()
    del wd
    def getInfoLabel(self):
        meta = {
        'title': xbmc.getInfoLabel('ListItem.title'),
        #'label': xbmc.getInfoLabel('ListItem.title'),
        'originaltitle': xbmc.getInfoLabel('ListItem.originaltitle'),
        'year': xbmc.getInfoLabel('ListItem.year'),
        'genre': xbmc.getInfoLabel('ListItem.genre'),
        'director': xbmc.getInfoLabel('ListItem.director'),
        'country': xbmc.getInfoLabel('ListItem.country'),
        'rating': xbmc.getInfoLabel('ListItem.rating'),
        'votes': xbmc.getInfoLabel('ListItem.votes'),
        'mpaa': xbmc.getInfoLabel('ListItem.mpaa'),
        'duration': xbmc.getInfoLabel('ListItem.duration'),
        'trailer': xbmc.getInfoLabel('ListItem.trailer'),
        'writer': xbmc.getInfoLabel('ListItem.writer'),
        'studio': xbmc.getInfoLabel('ListItem.studio'),
        'tagline': xbmc.getInfoLabel('ListItem.tagline'),
        'plotoutline': xbmc.getInfoLabel('ListItem.plotoutline'),
        'plot': xbmc.getInfoLabel('ListItem.plot'),
        'cover_url': xbmc.getInfoLabel('ListItem.Art(thumb)'),
        'backdrop_url': xbmc.getInfoLabel('ListItem.Art(fanart)'),
        'imdb_id': xbmc.getInfoLabel('ListItem.IMDBNumber'),
        'season': xbmc.getInfoLabel('ListItem.season'),
        'episode': xbmc.getInfoLabel('ListItem.episode')
        }

        if meta['title']:
            meta['title'] = self.getTitle()

        for key, value in meta.items():
            self.addItemValues(key, value)

        if meta['backdrop_url']:
            self.addItemProperties('fanart_image', meta['backdrop_url'])
            self.__sFanart = meta['backdrop_url']
        if meta['trailer']:
            meta['trailer'] = meta['trailer'].replace(u'\u200e', '').replace(u'\u200f', '')
            self.__sTrailerUrl = meta['trailer']
        if meta['cover_url']:
            self.__sThumbnail = meta['cover_url']
            self.__sPoster = meta['cover_url']

        return
Beispiel #35
0
    def run(self, oGuiElement, sTitle, sUrl):

        self.totalTime = 0
        self.currentTime = 0

        sPluginHandle = cPluginHandler().getPluginHandle()

        oGui = cGui()
        item = oGui.createListItem(oGuiElement)
        item.setPath(oGuiElement.getMediaUrl())

        #meta = {'label': oGuiElement.getTitle(), 'title': oGuiElement.getTitle()}
        #item = xbmcgui.ListItem(path=sUrl, iconImage='DefaultVideo.png', thumbnailImage=self.sThumbnail)
        #item.setInfo(type='Video', infoLabels=meta)

        #Sous titres
        if (self.Subtitles_file):
            try:
                item.setSubtitles(self.Subtitles_file)
                VSlog('Load SubTitle :' + str(self.Subtitles_file))
                self.SubtitleActive = True
            except:
                VSlog("Can't load subtitle:" + str(self.Subtitles_file))

        player_conf = self.ADDON.getSetting('playerPlay')

        #Si lien dash, methode prioritaire
        if sUrl.endswith('.mpd'):
            if isKrypton() == True:
                self.enable_addon('inputstream.adaptive')
                item.setProperty('inputstreamaddon', 'inputstream.adaptive')
                item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
                xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item)
                VSlog('Player use inputstream addon')
            else:
                dialog().VSerror('Nécessite kodi 17 minimum')
                return
        #1 er mode de lecture
        elif (player_conf == '0'):
            self.play(sUrl, item)
            VSlog('Player use Play() method')
        #2 eme mode non utilise
        elif (player_conf == 'neverused'):
            xbmc.executebuiltin('PlayMedia(' + sUrl + ')')
            VSlog('Player use PlayMedia() method')
        #3 eme mode (defaut)
        else:
            xbmcplugin.setResolvedUrl(sPluginHandle, True, item)
            VSlog('Player use setResolvedUrl() method')

        #Attend que le lecteur demarre, avec un max de 20s
        if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19':
            for _ in range(20):
                if self.playBackEventReceived:
                    break
                xbmc.sleep(1000)
        else:
            for _ in xrange(20):
                if self.playBackEventReceived:
                    break
                xbmc.sleep(1000)

        #active/desactive les sous titres suivant l'option choisie dans la config
        if (self.SubtitleActive):
            if (self.ADDON.getSetting('srt-view') == 'true'):
                self.showSubtitles(True)
                dialog().VSinfo('Sous-titres chargés', 'Sous-Titres', 5)
            else:
                self.showSubtitles(False)
                dialog().VSinfo('Sous-titres chargés, vous pouvez les activer',
                                'Sous-Titres', 15)

        while self.isPlaying() and not self.forcestop:
            #while not xbmc.abortRequested:
            try:
                self.currentTime = self.getTime()
                self.totalTime = self.getTotalTime()

                #xbmc.log(str(self.currentTime))

            except:
                pass
                #break
            xbmc.sleep(1000)

        if not self.playBackStoppedEventReceived:
            self.onPlayBackStopped()

        #Uniquement avec la lecture avec play()
        if (player_conf == '0'):
            r = xbmcplugin.addDirectoryItem(handle=sPluginHandle,
                                            url=sUrl,
                                            listitem=item,
                                            isFolder=False)
            #xbmcplugin.endOfDirectory(sPluginHandle, True, False, False)
            return r

        VSlog('Closing player')
Beispiel #36
0
 def RefreshDownloadList(self):
     #print xbmc.getInfoLabel('Container.FolderPath')
     if 'function=getDownload' in xbmc.getInfoLabel('Container.FolderPath'):
         VSupdate()
    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
Beispiel #38
0
    def AddtoDownloadListandview(self):

        oInputParameterHandler = cInputParameterHandler()

        sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier')
        sMediaUrl = oInputParameterHandler.getValue('sMediaUrl')
        sFileName = oInputParameterHandler.getValue('sFileName')

        VSlog("Telechargement " + 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 = urllib.unquote_plus(row[0][2])
                    path = row[0][3]
                    #thumbnail = urllib.unquote_plus(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('Creation buffer')

                        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('Echec du telechargement', 'Erreur')
        return