Esempio n. 1
0
        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
def showUserLists():
    oGui = cGui()
    grab = cTMDb()

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    term = ''
    if (oInputParameterHandler.exist('session_id')):
        term += 'session_id=' +  oInputParameterHandler.getValue('session_id')

    sUrl = oInputParameterHandler.getValue('siteUrl')
    result = grab.getUrl(sUrl, iPage, term)

    total = len(result)
    if (total > 0):
        for i in result['results']:
            sId, sTitle = i['id'], i['name']

            #sUrl = API_URL + '/genre/' + str(sId) + '/tv'
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sId)
            oGui.addDir(SITE_IDENTIFIER, 'showLists', sTitle, 'genres.png', oOutputParameterHandler)

    oGui.setEndOfDirectory()
def getAction():
    grab = cTMDb()
    dialogs = dialog()

    oInputParameterHandler = cInputParameterHandler()

    sAction= ''
    if not sAction:
        sAction, sFow, sYn = getContext()
    if not sAction:
        return

    sCat = oInputParameterHandler.getValue('sCat')
    if not sCat:
        sCat = getCat()
    if not sCat:
        return

    #dans le doute si meta active
    sTMDB = oInputParameterHandler.getValue('sTmdbId')
    sSeason = oInputParameterHandler.getValue('sSeason')
    sEpisode = oInputParameterHandler.getValue('sEpisode')

    sCat = sCat.replace('1', 'movie').replace('2', 'tv')

    if not sTMDB:
        sTMDB = grab.get_idbyname(oInputParameterHandler.getValue('sFileName'), '', sCat)
    if not sTMDB:
        return


    if sAction == 'vote':
        #vote /movie/{movie_id}/rating
        #/tv/{tv_id}/rating
        numboard = dialogs.numeric(0, 'Min 0.5 - Max 10')
        if numboard != None:
            sAction = '%s/%s/rating' % (sCat, sTMDB)
            sPost = {"value": numboard}
        else :
            return

    else:

        sPost = {"media_type": sCat, "media_id": sTMDB, sFow: sYn}


    data = grab.getPostUrl(sAction, sPost)

    if len(data) > 0:
        dialogs.VSinfo(data['status_message'])

    return
def getWatchlist():
    grab = cTMDb()
    addons = addon()

    tmdb_session = addons.getSetting('tmdb_session')
    tmdb_account = addons.getSetting('tmdb_account')

    if not tmdb_session:
        return

    if not tmdb_account:
        return

    oInputParameterHandler = cInputParameterHandler()


    sCat = oInputParameterHandler.getValue('sCat')
    if not sCat:
        return

    #dans le doute si meta active
    sTMDB = oInputParameterHandler.getValue('sTmdbId')
    sSeason = oInputParameterHandler.getValue('sSeason')
    sEpisode = oInputParameterHandler.getValue('sEpisode')

    sCat = sCat.replace('1', 'movie').replace('2', 'tv')
 
    if not sTMDB:
        sTMDB = grab.get_idbyname(oInputParameterHandler.getValue('sFileName'), '', sCat)
    if not sTMDB:
        return

    sPost = {"media_type": sCat, "media_id": sTMDB, 'watchlist': True}
    sAction = 'account/%s/watchlist' % tmdb_account

    data = grab.getPostUrl(sAction, sPost)

    if len(data) > 0:
        dialog().VSinfo(data['status_message'])

    return
def showGenreMovie():
    oGui = cGui()
    grab = cTMDb()

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    result = grab.getUrl(sUrl)

    total = len(result)
    if (total > 0):
        for i in result['genres']:
            sId, sTitle = i['id'], i['name']

            sTitle = sTitle.encode("utf-8")
            sUrl = 'genre/' + str(sId) + '/movies'
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', str(sTitle), 'genres.png', oOutputParameterHandler)

    oGui.setEndOfDirectory()
def showSeriesEpisode():
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')
    sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
    sFanart = oInputParameterHandler.getValue('sFanart')
    sTmdbId = oInputParameterHandler.getValue('sTmdbId')

    sSeason = oInputParameterHandler.getValue('sSeason')
    #sId = oInputParameterHandler.getValue('sId')
    if sSeason == False:
        sSeason = sUrl.split('/')[-1]

    if sFanart == False:
        sFanart = ''

    oGui = cGui()

    #recherche saison complete
    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', sMovieTitle)
    #oOutputParameterHandler.addParameter('type', 'serie')
    search = '%s S%02d' % (sMovieTitle, int(sSeason))
    #oOutputParameterHandler.addParameter('searchtext', search)
    oOutputParameterHandler.addParameter('searchtext', cUtil().CleanName(search))


    oGuiElement = cGuiElement()
    oGuiElement.setSiteName('globalSearch')
    oGuiElement.setFunction('searchMovie')
    oGuiElement.setTitle(addons.VSlang(30415))
    oGuiElement.setCat(2)
    oGuiElement.setIcon("searchtmdb.png")
    oGui.addFolder(oGuiElement, oOutputParameterHandler)

    #oGui.addDir('cHome', 'showSearch', addons.VSlang(30415), 'searchtmdb.png', oOutputParameterHandler)
    #fin

    result = grab.getUrl(sUrl)

    total = len(result)
    dialog = progress()
    dialog.VScreate(SITE_NAME)
    if (total > 0):
        total = len(result['episodes'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['episodes']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            #sId, sTitle, sOtitle, sThumb, sFanart = i['id'], i['name'], i['original_name'], i['poster_path'], i['backdrop_path']
            sdate, sIdEp, sEpNumber, sName, sThumb, SResume = i['air_date'], i['id'], i['episode_number'], i['name'], i['still_path'], i['overview']

            sName = sName.encode("utf-8")
            if sName == '':
                sName = sMovieTitle

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            #sTitle = '[COLOR coral]S' + sSeason + 'E' + str(sEpNumber) + '[/COLOR] - ' + sName
            sTitle = 'S%s E%s %s' % (sSeason, str(sEpNumber) , sName)

            sExtraTitle = ' S' + "%02d" % int(sSeason) + 'E' + "%02d" % int(sEpNumber)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sMovieTitle + '|' + sExtraTitle) #Pour compatibilite Favoris
            oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)
            oOutputParameterHandler.addParameter('sSeason', sSeason)
            oOutputParameterHandler.addParameter('sEpisode', sEpNumber)
            oOutputParameterHandler.addParameter('type', 'serie')
            oOutputParameterHandler.addParameter('searchtext', cUtil().CleanName(sMovieTitle))

            #oGui.addTVDB('globalSearch', 'showHosters', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sTmdbId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sMovieTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(2)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)
    
    #tchnagement mode
    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
Esempio n. 7
0
        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
Esempio n. 8
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 showSeries(sSearch=''):
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    term = ''
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    if (oInputParameterHandler.exist('sSearch')):
        sSearch = oInputParameterHandler.getValue('sSearch')

    if sSearch:
        result = grab.getUrl('search/tv', iPage, 'query=' + sSearch)
        sUrl = ''

    else:
        sUrl = oInputParameterHandler.getValue('siteUrl')

        if (oInputParameterHandler.exist('genre')):
            term = 'with_genres=' + oInputParameterHandler.getValue('genre')

        if (oInputParameterHandler.exist('session_id')):
            term += 'session_id=' + oInputParameterHandler.getValue(
                'session_id')

        result = grab.getUrl(sUrl, iPage, term)

    oGui = cGui()

    total = len(result)

    if (total > 0):
        total = len(result['results'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['results']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            # Mise en forme des infos (au format meta imdb)
            i = grab._format(i, '')
            sId, sTitle, sGenre, sThumb, sFanart, sDesc, sYear = i[
                'tmdb_id'], i['title'], i['genre'], i['cover_url'], i[
                    'backdrop_url'], i['plot'], i['year']

            sTitle = sTitle.encode("utf-8")

            sSiteUrl = 'tv/' + str(sId)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sSiteUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            oOutputParameterHandler.addParameter('searchtext',
                                                 cUtil().CleanName(sTitle))

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName(SITE_IDENTIFIER)  # a activer pour  saisons
            oGuiElement.setFunction('showSeriesSaison')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(2)
            oGuiElement.setDescription(sDesc)
            oGuiElement.setYear(sYear)
            oGuiElement.setGenre(sGenre)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

        if (iPage > 0):
            iNextPage = int(iPage) + 1
            oOutputParameterHandler = cOutputParameterHandler()
            if sSearch:
                oOutputParameterHandler.addParameter('sSearch', sSearch)
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('page', iNextPage)
            if (oInputParameterHandler.exist('genre')):
                oOutputParameterHandler.addParameter(
                    'genre', oInputParameterHandler.getValue('genre'))
            oGui.addNext(SITE_IDENTIFIER, 'showSeries',
                         '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]',
                         oOutputParameterHandler)

    # changement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
def showSeriesEpisode():
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')
    sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
    sFanart = oInputParameterHandler.getValue('sFanart')
    sTmdbId = oInputParameterHandler.getValue('sTmdbId')

    sSeason = oInputParameterHandler.getValue('sSeason')
    # sId = oInputParameterHandler.getValue('sId')
    if sSeason == False:
        sSeason = sUrl.split('/')[-1]

    if sFanart == False:
        sFanart = ''

    oGui = cGui()

    # recherche saison complete
    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', sMovieTitle)
    # oOutputParameterHandler.addParameter('type', 'serie')
    search = '%s S%02d' % (sMovieTitle, int(sSeason))
    # oOutputParameterHandler.addParameter('searchtext', search)
    oOutputParameterHandler.addParameter('searchtext',
                                         cUtil().CleanName(search))

    oGuiElement = cGuiElement()
    oGuiElement.setSiteName('globalSearch')
    oGuiElement.setFunction('searchMovie')
    oGuiElement.setTitle(addons.VSlang(30415))
    oGuiElement.setCat(2)
    oGuiElement.setIcon("searchtmdb.png")
    oGui.addFolder(oGuiElement, oOutputParameterHandler)

    result = grab.getUrl(sUrl)

    total = len(result)
    if (total > 0 and 'episodes' in result):
        total = len(result['episodes'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['episodes']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            # sId, sTitle, sOtitle, sThumb, sFanart = i['id'], i['name'], i['original_name'], i['poster_path'], i['backdrop_path']
            sEpNumber = i['episode_number']

            # Mise en forme des infos (au format meta imdb)
            i = grab._format(i, '')
            sTitle, sGenre, sThumb, sFanart, sDesc, sYear = i['title'], i[
                'genre'], i['cover_url'], i['backdrop_url'], i['plot'], i[
                    'year']

            sTitle = sTitle.encode("utf-8")

            sTitle = 'S%s E%s %s' % (sSeason, str(sEpNumber), sTitle)

            sExtraTitle = ' S' + "%02d" % int(sSeason) + 'E' + "%02d" % int(
                sEpNumber)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter(
                'siteUrl',
                sMovieTitle + '|' + sExtraTitle)  #Pour compatibilite Favoris
            oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)
            oOutputParameterHandler.addParameter('sSeason', sSeason)
            oOutputParameterHandler.addParameter('sEpisode', sEpNumber)
            oOutputParameterHandler.addParameter('type', 'serie')
            oOutputParameterHandler.addParameter(
                'searchtext',
                cUtil().CleanName(sMovieTitle))

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sTmdbId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sMovieTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(2)
            oGuiElement.setDescription(sDesc)
            oGuiElement.setYear(sYear)
            oGuiElement.setGenre(sGenre)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    # tchnagement mode
    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
Esempio n. 11
0
    def getMetadonne(self):

        #sTitle = self.__sTitle.decode('latin-1').encode("utf-8")
        #sTitle=re.sub(r'\[.*\]|\(.*\)',r'',str(self.__sFileName))
        #sTitle=sTitle.replace('VF','').replace('VOSTFR','').replace('FR','')

        #get_meta(self, media_type, name, imdb_id='', tmdb_id='', year='', overlay=6, update=False):
        sType = '1'
        sType = str(self.getMeta()).replace('1',
                                            'movie').replace('2', 'tvshow')

        if sType:
            from resources.lib.tmdb import cTMDb
            grab = cTMDb(api_key=cConfig().getSetting('api_tmdb'))
            args = (sType, self.__sFileName)
            kwargs = {}
            if (self.__ImdbId):
                kwargs['imdb_id'] = self.__ImdbId
            if (self.__TmdbId):
                kwargs['tmdb_id'] = self.__TmdbId
            if (self.__Year):
                kwargs['year'] = self.__Year
            if (self.__Season):
                kwargs['season'] = self.__Season
            if (self.__Episode):
                kwargs['episode'] = self.__Episode
            meta = grab.get_meta(*args, **kwargs)

        else:
            return

        #Pour les films
        # if self.getMeta() == 1:
        # try:
        # from metahandler import metahandlers
        # grab = metahandlers.MetaData(preparezip=False,  tmdb_api_key=cConfig().getSetting('api_tmdb'))
        # args = ("movie", self.__sFileName)
        # kwargs = {}
        # if (self.__TmdbId) or (self.__Year):
        # if (self.__ImdbId):
        # kwargs['imdb_id'] = self.__ImdbId
        # if (self.__TmdbId):
        # kwargs['tmdb_id'] = self.__TmdbId
        # if (self.__Year):
        # kwargs['year'] =  self.__Year
        # meta = grab.get_meta(*args, **kwargs)
        # except:
        # return

        #Pour les series
        # elif self.getMeta() == 2:
        # try:
        # from metahandler import metahandlers
        # grab = metahandlers.MetaData(preparezip=False, tmdb_api_key=cConfig().getSetting('api_tmdb'))
        # Nom a nettoyer ?
        #attention l'annee peut mettre le bordel a cause des differences de sortie
        # args = ("tvshow", self.__sFileName)
        # kwargs = {}
        # if (self.__TmdbId) or (self.__Year):
        # dict = {}
        # if (self.__ImdbId):
        # kwargs['imdb_id'] = self.__ImdbId
        # if (self.__TmdbId):
        # kwargs['tmdb_id'] = self.__TmdbId
        # if (self.__Year):
        # kwargs['year'] =  self.__Year
        # meta = grab.get_meta(*args, **kwargs)
        # except:
        # return
        # else:
        # return

        del meta['playcount']
        del meta['trailer']

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

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

        if meta['imdb_id']:
            self.__ImdbId = meta['imdb_id']

        try:
            if meta['tmdb_id']:
                self.__TmdbId = meta['tmdb_id']
        except:
            pass

        try:
            if meta['tvdb_id']:
                self.__TmdbId = meta['tvdb_id']
        except:
            pass

        if meta['backdrop_url']:
            self.addItemProperties('fanart_image', meta['backdrop_url'])
            self.__sFanart = meta['backdrop_url']
        # if meta['trailer_url']:
        # 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
def showMyTmdb():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    tmdb_session = addons.getSetting('tmdb_session')
    if tmdb_session == '':
        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('siteUrl', 'https://')
        oGui.addDir(SITE_IDENTIFIER, 'getToken', addons.VSlang(30305),
                    'trakt.png', oOutputParameterHandler)
    else:
        # pas de deco possible avec l'api donc on test l'username sinon ont supprime tous
        result = grab.getUrl('account', '1', 'session_id=' + tmdb_session)

        if 'username' in result and result['username']:

            # pas de menu sans ID user c'est con
            addons.setSetting('tmdb_account', str(result['id']))

            sUsername = result['username']
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', 'https://')
            oGui.addText(SITE_IDENTIFIER, (addons.VSlang(30306)) % (sUsername))

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/favorite/movies
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/favorite/movies' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', addons.VSlang(30434),
                        'films.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/rated/movies
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/rated/movies' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', addons.VSlang(30435),
                        'notes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/watchlist/movies
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/watchlist/movies' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', addons.VSlang(30436),
                        'views.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/favorite/tv
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/favorite/tv' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30437),
                        'series.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/rated/tv
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/rated/tv' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30438),
                        'notes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/watchlist/tv
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/watchlist/tv' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30440),
                        'views.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/rated/tv/episodes
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/rated/tv/episodes' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30439),
                        'notes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            # /account/{account_id}/lists
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter(
                'siteUrl', 'account/%s/lists' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showUserLists', addons.VSlang(30441),
                        'listes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', 'http://')
            oGui.addDir(SITE_IDENTIFIER, 'ouTMyTmdb', addons.VSlang(30309),
                        'listes.png', oOutputParameterHandler)

        else:
            ouTMyTmdb()

    oGui.setEndOfDirectory()
def showLists():
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    sUrl = oInputParameterHandler.getValue('siteUrl')

    result = grab.getUrl('list/' + sUrl, iPage, '')

    oGui = cGui()

    total = len(result)

    if (total > 0):
        total = len(result['items'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['items']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sId, sType, sThumb, sFanart, sVote, sDesc = i['id'], i[
                'media_type'], i['poster_path'], i['backdrop_path'], i[
                    'vote_average'], i['overview']

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            if sFanart:
                sFanart = FANART_URL + sFanart
            else:
                sFanart = ''

            sTitle = "None"

            if 'name' in i:
                sTitle = i['name'].encode("utf-8")
            if 'title' in i:
                sTitle = i['title'].encode("utf-8")

            sDisplayTitle = "%s (%s)" % (sTitle, sVote)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl',
                                                 'http://tmdb/%s' % sId)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            #oOutputParameterHandler.addParameter('searchtext', sTitle)
            oOutputParameterHandler.addParameter('searchtext',
                                                 cUtil().CleanName(sTitle))

            #oGui.addTVDB(SITE_IDENTIFIER, 'showSeriesSaison', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "movies"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sDisplayTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('series.png')
            if sType == 'movie':
                oGuiElement.setMeta(1)
                oGuiElement.setCat(1)
            elif sType == 'tv':
                oGuiElement.setMeta(2)
                oGuiElement.setCat(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setDescription(sDesc)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
def showSeries(sSearch=''):
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    term = ''
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    if (oInputParameterHandler.exist('sSearch')):
        sSearch = oInputParameterHandler.getValue('sSearch')

    if sSearch:
        result = grab.getUrl('search/tv', iPage, 'query=' + sSearch)
        sUrl = ''

    else:
        sUrl = oInputParameterHandler.getValue('siteUrl')

        if (oInputParameterHandler.exist('genre')):
            term = 'with_genres=' + oInputParameterHandler.getValue('genre')

        if (oInputParameterHandler.exist('session_id')):
            term += 'session_id=' + oInputParameterHandler.getValue(
                'session_id')

        result = grab.getUrl(sUrl, iPage, term)

    oGui = cGui()

    total = len(result)

    if (total > 0):
        total = len(result['results'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['results']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sId, sTitle, sOtitle, sThumb, sFanart, sDesc = i['id'], i[
                'name'], i['original_name'], i['poster_path'], i[
                    'backdrop_path'], i['overview']
            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            if sFanart:
                sFanart = FANART_URL + sFanart
            else:
                sFanart = ''

            sTitle = sTitle.encode("utf-8")

            sSiteUrl = 'tv/' + str(sId)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sSiteUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            #oOutputParameterHandler.addParameter('searchtext', sTitle)
            oOutputParameterHandler.addParameter('searchtext',
                                                 cUtil().CleanName(sTitle))

            #oGui.addTVDB(SITE_IDENTIFIER, 'showSeriesSaison', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName(SITE_IDENTIFIER)  # a activer pour  saisons
            #oGuiElement.setSiteName('globalSearch') # a desactiver pour saison
            oGuiElement.setFunction('showSeriesSaison')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(2)
            #oGuiElement.setDescription(sDesc)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

        if (iPage > 0):
            iNextPage = int(iPage) + 1
            oOutputParameterHandler = cOutputParameterHandler()
            if sSearch:
                oOutputParameterHandler.addParameter('sSearch', sSearch)
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('page', iNextPage)
            if (oInputParameterHandler.exist('genre')):
                oOutputParameterHandler.addParameter(
                    'genre', oInputParameterHandler.getValue('genre'))
            oGui.addNext(SITE_IDENTIFIER, 'showSeries',
                         '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]',
                         oOutputParameterHandler)

    #chnagement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
Esempio n. 15
0
    def getMetadonne(self):

        sTitle = self.__sFileName

        #sTitle = self.__sTitle.decode('latin-1').encode("utf-8")
        #sTitle = re.sub(r'\[.*\]|\(.*\)', r'', str(self.__sFileName))
        #sTitle = sTitle.replace('VF', '').replace('VOSTFR', '').replace('FR', '')

        #get_meta(self, media_type, name, imdb_id='', tmdb_id='', year='', overlay=6, update=False):
        metaType = self.getMeta()

        # non media -> pas de fanart
        if metaType == 0:
            self.addItemProperties('fanart_image', '')
            return

        # Integrale de films, on nettoie le titre pour la recherche
        if metaType == 3 :
            sTitle=sTitle.replace('integrale', '')
            sTitle=sTitle.replace('2 films', '')
            sTitle=sTitle.replace('6 films', '')
            sTitle=sTitle.replace('7 films', '')
            sTitle=sTitle.replace('trilogie', '')
            sTitle=sTitle.replace('trilogy', '')
            sTitle=sTitle.replace('quadrilogie', '')
            sTitle=sTitle.replace('pentalogie', '')
            sTitle=sTitle.replace('octalogie', '')
            sTitle=sTitle.replace('hexalogie', '')
            sTitle=sTitle.replace('tetralogie', '')

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

        if sType:
            from resources.lib.tmdb import cTMDb
            grab = cTMDb()
            args = (sType, sTitle)
            kwargs = {}
            if (self.__ImdbId):
                kwargs['imdb_id'] = self.__ImdbId
            if (self.__TmdbId):
                kwargs['tmdb_id'] = self.__TmdbId
            if (self.__Year):
                kwargs['year'] =  self.__Year
            if (self.__Season):
                kwargs['season'] =  self.__Season
            if (self.__Episode):
                kwargs['episode'] =  self.__Episode
            meta = grab.get_meta(*args, **kwargs)

        else :
            return

        #Pour les films
        # if self.getMeta() == 1:
            # try:
                # from metahandler import metahandlers
                # grab = metahandlers.MetaData(preparezip=False, tmdb_api_key=cConfig().getSetting('api_tmdb'))
                # args = ("movie", self.__sFileName)
                # kwargs = {}
                # if (self.__TmdbId) or (self.__Year):
                    # if (self.__ImdbId):
                        # kwargs['imdb_id'] = self.__ImdbId
                    # if (self.__TmdbId):
                        # kwargs['tmdb_id'] = self.__TmdbId
                    # if (self.__Year):
                        # kwargs['year'] =  self.__Year
                # meta = grab.get_meta(*args, **kwargs)
            # except:
                # return

        #Pour les series
        # elif self.getMeta() == 2:
            # try:
                # from metahandler import metahandlers
                # grab = metahandlers.MetaData(preparezip=False, tmdb_api_key=cConfig().getSetting('api_tmdb'))
                # Nom a nettoyer ?
                #attention l'annee peut mettre le bordel a cause des differences de sortie
                # args = ("tvshow", self.__sFileName)
                # kwargs = {}
                # if (self.__TmdbId) or (self.__Year):
                    # dict = {}
                    # if (self.__ImdbId):
                        # kwargs['imdb_id'] = self.__ImdbId
                    # if (self.__TmdbId):
                        # kwargs['tmdb_id'] = self.__TmdbId
                    # if (self.__Year):
                        # kwargs['year'] =  self.__Year
                # meta = grab.get_meta(*args, **kwargs)
            # except:
                # return
        # else:
            # return

        del meta['playcount']
        del meta['trailer']

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

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

        if meta['imdb_id']:
            self.__ImdbId = meta['imdb_id']

        try:
            if meta['tmdb_id']:
                self.__TmdbId = meta['tmdb_id']
        except: pass

        try:
            if meta['tvdb_id']:
                self.__TmdbId = meta['tvdb_id']
        except: pass

        # Si fanart trouvé dans les meta alors on l'utilise, sinon on n'en met pas
        if meta['backdrop_url']:
            self.addItemProperties('fanart_image', meta['backdrop_url'])
            self.__sFanart = meta['backdrop_url']
        else:
            self.addItemProperties('fanart_image', '')

        # if meta['trailer_url']:
            # meta['trailer'] = meta['trailer'].replace(u'\u200e', '').replace(u'\u200f', '')
            # self.__sTrailerUrl = meta['trailer']

        # Pas de changement de cover pour les coffrets de films
        if metaType != 3:
            if 'cover_url' in meta and meta['cover_url']:
                self.__sThumbnail = meta['cover_url']
                self.__sPoster = meta['cover_url']
        return
def showFilmActor():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    result = grab.getUrl(sUrl, iPage)

    total = len(result)
    if (total > 0):
        total = len(result['cast'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['cast']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sId, sTitle, sThumb, sFanart, sDesc = i['id'], i['title'], i[
                'poster_path'], i['backdrop_path'], i['overview']

            try:
                #sTitle = unicodedata.normalize('NFKD', sTitle).encode('ascii', 'ignore')
                sTitle = sTitle.encode("utf-8")

            except:
                sTitle = "Aucune information"

            try:
                sThumb = POSTER_URL + sThumb
            except:
                sThumb = ''

            try:
                sFanart = FANART_URL + sFanart
            except:
                sFanart = ''

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl',
                                                 'http://tmdb/%s' % sId)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('type', 'film')
            oOutputParameterHandler.addParameter('searchtext',
                                                 cUtil().CleanName(sTitle))

            #oGui.addMovieDB('globalSearch', 'showHosters', sTitle, '', sThumb, '', oOutputParameterHandler)
            cGui.CONTENT = "movies"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('actors.png')
            oGuiElement.setMeta(1)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(1)
            #oGuiElement.setDescription(sDesc)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)
        #pas de paramettre de page
        # if (iPage > 0):
        # iNextPage = int(iPage) + 1
        # oOutputParameterHandler = cOutputParameterHandler()
        # oOutputParameterHandler.addParameter('siteUrl', sUrl)
        # oOutputParameterHandler.addParameter('page', iNextPage)
        # oGui.addDir(SITE_IDENTIFIER, 'showFilmActor', '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]', 'next.png', oOutputParameterHandler)

    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
Esempio n. 17
0
            def onClick(self, 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:
                    return
                elif controlId == 11:
                    from resources.lib import util
                    util.VS_show_busy_dialog()
                    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')
                    xbmcgui.Window(10000).setProperty('nav', '1')
                    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 = xbmcgui.Window(10000).getProperty("ListItem.tmdb_id")
                    xbmcgui.Window(10000).setProperty('nav', '2')

                    from resources.lib.tmdb import cTMDb
                    grab = cTMDb()
                    sUrl = 'movie/%s/similar' % str(sid)
                    try:
                        meta = grab.getUrl(sUrl)
                        meta = meta['results']
                        self.credit(meta)
                    except:
                        return
                #click sur recommendations
                elif controlId == 13:
                    #print self.getControl(9000).ListItem.tmdb_id
                    sid = xbmcgui.Window(10000).getProperty("ListItem.tmdb_id")
                    xbmcgui.Window(10000).setProperty('nav', '3')

                    from resources.lib.tmdb import cTMDb
                    grab = cTMDb()
                    sUrl = 'movie/%s/recommendations' % str(sid)
                    try:
                        meta = grab.getUrl(sUrl)
                        meta = meta['results']
                        self.credit(meta)
                    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
Esempio n. 18
0
    def WindowsBoxes(self, sTitle, sFileName, num, year=''):

        # API = self.getSetting('api_tmdb')

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

        #Sinon on gere par TvWatch via la lib TMDB
        if num == "1":
            try:
                from resources.lib.tmdb import cTMDb
                # grab = cTMDb(api_key = self.getSetting('api_tmdb'))
                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(api_key=self.getSetting('api_tmdb'))
                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
            self.showInfo('TvWatch', self.getlanguage(30204))

            return

        #affichage du dialog perso
        class XMLDialog(xbmcgui.WindowXMLDialog):
            """
            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 = cConfig().getSetting('deco_color')
                xbmcgui.Window(10000).setProperty('color', color)

                self.getControl(50).setVisible(False)
                self.getControl(50).reset()
                self.getControl(5500).setVisible(False)
                listitems = []
                try:
                    for slabel, slabel2, sicon, sid in meta['cast']:
                        listitem = xbmcgui.ListItem(label=slabel,
                                                    label2=slabel2,
                                                    iconImage=sicon)
                        #listitem.setInfo('video', {'Title': 'test', 'RatingAndVotes':'6.8'})
                        listitem.setProperty('id', str(sid))
                        listitems.append(listitem)
                    self.getControl(50).addItems(listitems)
                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):
                        xbmcgui.Window(10000).setProperty(
                            property, meta[e].encode('utf-8'))
                    else:
                        xbmcgui.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/w396' + i[
                                'poster_path']
                        except:
                            sThumbnail = ''
                        sId = i['id']

                        listitem = xbmcgui.ListItem(label=sTitle,
                                                    iconImage=sThumbnail)
                        #listitem.setInfo('video', {'Title': 'test', 'RatingAndVotes':'6.8'})
                        #listitem.setProperty('id', str(sId))
                        listitems.append(listitem)
                    self.getControl(5200).addItems(listitems)
                except:
                    pass
                self.getControl(5500).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]')
                    #print meta

                    xbmcgui.Window(10000).setProperty('biography', bio)
                    xbmcgui.Window(10000).setProperty('birthday',
                                                      meta['birthday'])
                    xbmcgui.Window(10000).setProperty('place_of_birth',
                                                      meta['place_of_birth'])
                    xbmcgui.Window(10000).setProperty('deathday',
                                                      meta['deathday'])

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

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

            def onClick(self, 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:
                    return
                elif controlId == 11:
                    from resources.lib import util
                    util.VS_show_busy_dialog()
                    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')
                    xbmcgui.Window(10000).setProperty('nav', '1')
                    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 = xbmcgui.Window(10000).getProperty("ListItem.tmdb_id")
                    xbmcgui.Window(10000).setProperty('nav', '2')

                    from resources.lib.tmdb import cTMDb
                    grab = cTMDb()
                    sUrl = 'movie/%s/similar' % str(sid)
                    try:
                        meta = grab.getUrl(sUrl)
                        meta = meta['results']
                        self.credit(meta)
                    except:
                        return
                #click sur recommendations
                elif controlId == 13:
                    #print self.getControl(9000).ListItem.tmdb_id
                    sid = xbmcgui.Window(10000).getProperty("ListItem.tmdb_id")
                    xbmcgui.Window(10000).setProperty('nav', '3')

                    from resources.lib.tmdb import cTMDb
                    grab = cTMDb()
                    sUrl = 'movie/%s/recommendations' % str(sid)
                    try:
                        meta = grab.getUrl(sUrl)
                        meta = meta['results']
                        self.credit(meta)
                    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(5500).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)

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

        wd = XMLDialog('DialogInfo.xml', self.__oPath.decode("utf-8"),
                       'default', '720p')
        wd.doModal()
        del wd
Esempio n. 19
0
    def WindowsBoxes(self, sTitle, sFileName, num, year=''):

        extendedinfo = False
        try:
            if (xbmcaddon.Addon('script.extendedinfo')
                    and self.getSetting('extendedinfo-view') == 'true'):
                extendedinfo = True
        except:
            pass

        if (extendedinfo):
            if num == "2":
                self.showInfo('vStream', 'Lancement de ExtendInfo')
                xbmc.executebuiltin(
                    'XBMC.RunScript(script.extendedinfo, info=extendedtvinfo, name=%s)'
                    % sFileName)
            elif num == "1":
                self.showInfo('vStream', 'Lancement de ExtendInfo')
                xbmc.executebuiltin(
                    'XBMC.RunScript(script.extendedinfo, info=extendedinfo, name=%s)'
                    % sFileName)
            else:
                xbmc.executebuiltin("Action(Info)")
            return

        if num == "1":
            try:
                from resources.lib.tmdb import cTMDb
                grab = cTMDb(api_key=self.getSetting('api_tmdb'))
                meta = grab.get_meta('movie', sFileName)
            except:
                xbmc.executebuiltin("Action(Info)")
                return
        elif num == "2":
            try:
                from resources.lib.tmdb import cTMDb
                grab = cTMDb(api_key=self.getSetting('api_tmdb'))
                meta = grab.get_meta('tvshow', sFileName)
            except:
                xbmc.executebuiltin("Action(Info)")
                return
        else:
            xbmc.executebuiltin("Action(Info)")
            return

        if (not meta['imdb_id']):
            xbmc.executebuiltin("Action(Info)")
            return

        class XMLDialog(xbmcgui.WindowXMLDialog):
            """
            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#
                self.getControl(50).setVisible(False)
                self.getControl(50).reset()
                listitems = []
                try:
                    for a, r, i in meta['cast']:
                        listitem = xbmcgui.ListItem(label=a,
                                                    label2=r,
                                                    iconImage=i)
                        #listitem.setInfo('video', {'Title': 'test', 'RatingAndVotes':'6.8'})
                        #listitem.setProperty('RatingAndVotes', '6.2')
                        listitems.append(listitem)
                    self.getControl(50).addItems(listitems)
                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):
                        xbmcgui.Window(10000).setProperty(
                            property, meta[e].encode('utf-8'))
                    else:
                        xbmcgui.Window(10000).setProperty(
                            property, str(meta[e]))

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

            def onClick(self, controlId):
                if controlId == 5:
                    self.getControl(400).setVisible(False)
                    self.getControl(50).setVisible(True)
                    return
                elif controlId == 20:
                    self.getControl(50).setVisible(False)
                    self.getControl(400).setVisible(True)
                    return
                elif controlId == 11:
                    self.close()
                    return
                elif controlId == 30:
                    self.close()
                    return
                #self.close()

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

            def _close_dialog(self):
                self.close()

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

        wd = XMLDialog('DialogInfo.xml', self.__oPath, 'default', '720p')
        wd.doModal()
        del wd
Esempio n. 20
0
    def getMetadonne(self):
        metaType = self.getMeta()
        if metaType == 0:  # non media -> on sort, et on enleve le fanart
            self.addItemProperties('fanart_image', '')
            return

        from resources.lib.tmdb import cTMDb
        TMDb = cTMDb()

        sTitle = self.__sFileName

        # sTitle = self.__sTitle.decode('latin-1').encode('utf-8')
        # sTitle = re.sub(r'\[.*\]|\(.*\)', r'', str(self.__sFileName))
        # sTitle = sTitle.replace('VF', '').replace('VOSTFR', '').replace('FR', '')

        # On nettoie le titre pour la recherche
        sTitle = sTitle.replace('version longue', '')

        # Integrale de films, on nettoie le titre pour la recherche
        if metaType == 3:
            sTitle = sTitle.replace('integrales', '')
            sTitle = sTitle.replace('integrale', '')
            sTitle = sTitle.replace('2 films', '')
            sTitle = sTitle.replace('6 films', '')
            sTitle = sTitle.replace('7 films', '')
            sTitle = sTitle.replace('trilogie', '')
            sTitle = sTitle.replace('trilogy', '')
            sTitle = sTitle.replace('quadrilogie', '')
            sTitle = sTitle.replace('pentalogie', '')
            sTitle = sTitle.replace('octalogie', '')
            sTitle = sTitle.replace('hexalogie', '')
            sTitle = sTitle.replace('tetralogie', '')
            sTitle = sTitle.strip()
            if sTitle.endswith(' les'):
                sTitle = sTitle[:-4]
            if sTitle.endswith(' la') or sTitle.endswith(' l'):
                sTitle = sTitle[:-3]
            sTitle = sTitle.strip()

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

        meta = {}
        if sType:
            args = (sType, sTitle)
            kwargs = {}
            if (self.__ImdbId):
                kwargs['imdb_id'] = self.__ImdbId
            if (self.__TmdbId):
                kwargs['tmdb_id'] = self.__TmdbId
            if (self.__Year):
                kwargs['year'] = self.__Year
            if (self.__Season):
                kwargs['season'] = self.__Season
            if (self.__Episode):
                kwargs['episode'] = self.__Episode

            try:
                meta = TMDb.get_meta(*args, **kwargs)
            except:
                pass

        else:
            return

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

        if 'media_type' in meta:
            meta.pop('media_type')

        if 'imdb_id' in meta:
            imdb_id = meta.pop('imdb_id')
            if imdb_id:
                self.__ImdbId = imdb_id

        if 'tmdb_id' in meta:
            tmdb_id = meta.pop('tmdb_id')
            if tmdb_id:
                self.__TmdbId = tmdb_id

        if 'tvdb_id' in meta:
            #            if meta['tvdb_id']:
            #             self.__TvdbId = meta['tvdb_id']
            meta.pop('tvdb_id')

        # Si fanart trouvé dans les meta alors on l'utilise, sinon on n'en met pas
        if 'backdrop_url' in meta:
            url = meta.pop('backdrop_url')
            if url:
                self.addItemProperties('fanart_image', url)
                self.__sFanart = url
            else:
                self.addItemProperties('fanart_image', '')

        if 'backdrop_path' in meta:
            meta.pop('backdrop_path')

        if 'poster_path' in meta:
            meta.pop('poster_path')

        if 'cover_url' in meta:
            cover = meta.pop('cover_url')
            if cover:
                self.__sThumbnail = cover
                self.__sPoster = cover

        if 'trailer' in meta and meta['trailer']:
            self.__sTrailer = meta['trailer']

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

        return
def showSeriesSaison():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()

    sUrl = oInputParameterHandler.getValue('siteUrl')
    sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
    sFanart = oInputParameterHandler.getValue('sFanart')
    sTmdbId = oInputParameterHandler.getValue('sTmdbId')

    sId = oInputParameterHandler.getValue('sId')
    if sId == False:
        sId = sUrl.split('/')[-1]

    if sFanart == False:
        sFanart = ''

    #recherche la serie complete
    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', sMovieTitle)
    #oOutputParameterHandler.addParameter('type', 'serie')
    #oOutputParameterHandler.addParameter('searchtext', sMovieTitle)
    oOutputParameterHandler.addParameter('searchtext',
                                         cUtil().CleanName(sMovieTitle))

    oGuiElement = cGuiElement()
    oGuiElement.setSiteName('globalSearch')
    oGuiElement.setFunction('searchMovie')
    oGuiElement.setTitle(addons.VSlang(30414))
    oGuiElement.setCat(2)
    oGuiElement.setIcon("searchtmdb.png")
    oGui.addFolder(oGuiElement, oOutputParameterHandler)

    #oGui.addDir('cHome', 'showSearch', addons.VSlang(30414), 'searchtmdb.png', oOutputParameterHandler)
    #fin

    result = grab.getUrl(sUrl)

    total = len(result)

    if (total > 0):

        total = len(result['seasons'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['seasons']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sdate, sNbreEp, sIdSeason, sThumb, SSeasonNum = i['air_date'], i[
                'episode_count'], i['id'], i['poster_path'], i['season_number']

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            sTitle = 'Saison ' + str(SSeasonNum) + ' (' + str(sNbreEp) + ')'

            sUrl = 'tv/' + sId + '/season/' + str(SSeasonNum)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sSeason', SSeasonNum)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)

            #oGui.addTVDB(SITE_IDENTIFIER, 'showSeriesEpisode', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sTmdbId)
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('showSeriesEpisode')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sMovieTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(7)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    #chnagement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
Esempio n. 22
0
#doc de l'api http://docs.themoviedb.apiary.io/

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

API_KEY = '92ab39516970ab9d86396866456ec9b6'
API_VERS = '3'
API_URL = URL_MAIN + API_VERS

POSTER_URL = 'https://image.tmdb.org/t/p/w396'
#FANART_URL = 'https://image.tmdb.org/t/p/w780/'
FANART_URL = 'https://image.tmdb.org/t/p/w1280'
#FANART_URL = 'https://image.tmdb.org/t/p/original/'

#https://api.themoviedb.org/3/movie/popular?api_key=92ab39516970ab9d86396866456ec9b6

grab = cTMDb(api_key=cConfig().getSetting('api_tmdb'))
view = '500'
view = cConfig().getSetting('visuel-view')
tmdb_session = cConfig().getSetting('tmdb_session')
tmdb_account = cConfig().getSetting('tmdb_account')

xbmcgui.Window(10101).clearProperty('search_disp')


def load():
    oGui = cGui()

    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', 'search/movie')
    oGui.addDir(SITE_IDENTIFIER, 'showSearchMovie', 'Recherche de Film',
                'search.png', oOutputParameterHandler)
def showSeriesEpisode():
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')
    sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
    sFanart = oInputParameterHandler.getValue('sFanart')
    sTmdbId = oInputParameterHandler.getValue('sTmdbId')

    sSeason = oInputParameterHandler.getValue('sSeason')
    #sId = oInputParameterHandler.getValue('sId')
    if sSeason == False:
        sSeason = sUrl.split('/')[-1]

    if sFanart == False:
        sFanart = ''

    oGui = cGui()

    #recherche saison complete
    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', sMovieTitle)
    #oOutputParameterHandler.addParameter('type', 'serie')
    search = '%s S%02d' % (sMovieTitle, int(sSeason))
    #oOutputParameterHandler.addParameter('searchtext', search)
    oOutputParameterHandler.addParameter('searchtext',
                                         cUtil().CleanName(search))

    oGuiElement = cGuiElement()
    oGuiElement.setSiteName('globalSearch')
    oGuiElement.setFunction('searchMovie')
    oGuiElement.setTitle(addons.VSlang(30415))
    oGuiElement.setCat(2)
    oGuiElement.setIcon("searchtmdb.png")
    oGui.addFolder(oGuiElement, oOutputParameterHandler)

    #oGui.addDir('cHome', 'showSearch', addons.VSlang(30415), 'searchtmdb.png', oOutputParameterHandler)
    #fin

    result = grab.getUrl(sUrl)

    total = len(result)
    dialog = progress()
    dialog.VScreate(SITE_NAME)
    if (total > 0):
        total = len(result['episodes'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['episodes']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            #sId, sTitle, sOtitle, sThumb, sFanart = i['id'], i['name'], i['original_name'], i['poster_path'], i['backdrop_path']
            sdate, sIdEp, sEpNumber, sName, sThumb, SResume = i['air_date'], i[
                'id'], i['episode_number'], i['name'], i['still_path'], i[
                    'overview']

            sName = sName.encode("utf-8")
            if sName == '':
                sName = sMovieTitle

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            #sTitle = '[COLOR coral]S' + sSeason + 'E' + str(sEpNumber) + '[/COLOR] - ' + sName
            sTitle = 'S%s E%s %s' % (sSeason, str(sEpNumber), sName)

            sExtraTitle = ' S' + "%02d" % int(sSeason) + 'E' + "%02d" % int(
                sEpNumber)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter(
                'siteUrl',
                sMovieTitle + '|' + sExtraTitle)  #Pour compatibilite Favoris
            oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)
            oOutputParameterHandler.addParameter('sSeason', sSeason)
            oOutputParameterHandler.addParameter('sEpisode', sEpNumber)
            oOutputParameterHandler.addParameter('type', 'serie')
            oOutputParameterHandler.addParameter(
                'searchtext',
                cUtil().CleanName(sMovieTitle))

            #oGui.addTVDB('globalSearch', 'showHosters', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sTmdbId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sMovieTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(2)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    #tchnagement mode
    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
def showLists():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    sUrl = oInputParameterHandler.getValue('siteUrl')
    result = grab.getUrl('list/' + sUrl, iPage, '')
    total = len(result)
    if (total > 0):
        total = len(result['items'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['items']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            # Mise en forme des infos (au format meta imdb)
            i = grab._format(i, '')

            sId, sTitle, sType, sThumb, sFanart, sVote, sDesc, sYear = i[
                'tmdb_id'], i['title'], i['media_type'], i['cover_url'], i[
                    'backdrop_url'], i['rating'], i['plot'], i['year']

            sTitle = sTitle.encode("utf-8")
            sDisplayTitle = "%s (%s)" % (sTitle, sVote)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl',
                                                 'http://tmdb/%s' % sId)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            oOutputParameterHandler.addParameter('searchtext',
                                                 cUtil().CleanName(sTitle))

            cGui.CONTENT = "movies"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sDisplayTitle)
            oGuiElement.setFileName(sTitle)
            if sType == 'movie':
                oGuiElement.setIcon('films.png')
                oGuiElement.setMeta(1)
                oGuiElement.setCat(1)
            elif sType == 'tv':
                oGuiElement.setIcon('series.png')
                oGuiElement.setMeta(2)
                oGuiElement.setCat(2)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setFanart(sFanart)
            oGuiElement.setDescription(sDesc)
            oGuiElement.setYear(sYear)
            if 'genre' in i:
                oGuiElement.setGenre(i['genre'])

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
def showActors():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (
        addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    result = grab.getUrl(sUrl, iPage)

    total = len(result)
    dialog = progress()
    dialog.VScreate(SITE_NAME)

    if (total > 0):
        total = len(result['results'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['results']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sName, sThumb = i['name'], i['profile_path']

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sThumb', sThumb)

            sName = sName.encode('utf-8')

            oOutputParameterHandler.addParameter(
                'siteUrl', 'person/' + str(i['id']) + '/movie_credits')
            #oGui.addMovieDB(SITE_IDENTIFIER, 'showFilmActor', '[COLOR red]'+str(sName)+'[/COLOR]', '', sThumb, '', oOutputParameterHandler)
            sTitle = '[COLOR red]' + str(sName) + '[/COLOR]'

            oGuiElement = cGuiElement()
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('showFilmActor')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sName)
            oGuiElement.setIcon('actors.png')
            oGuiElement.setMeta(0)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setCat(7)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

        if (iPage > 0):
            iNextPage = int(iPage) + 1
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('page', iNextPage)
            oGui.addNext(SITE_IDENTIFIER, 'showActors',
                         '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]',
                         oOutputParameterHandler)

    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
def getToken():
    grab = cTMDb()
    return grab.getToken()
def showFilmActor():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    result = grab.getUrl(sUrl, iPage)

    total = len(result)
    if (total > 0):
        total = len(result['cast'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['cast']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break


            sId, sTitle, sThumb, sFanart, sDesc = i['id'], i['title'], i['poster_path'], i['backdrop_path'], i['overview']


            try:
                #sTitle = unicodedata.normalize('NFKD', sTitle).encode('ascii', 'ignore')
                sTitle = sTitle.encode("utf-8")

            except: sTitle = "Aucune information"

            try:
                sThumb = POSTER_URL + sThumb
            except:
                sThumb = ''

            try:
                sFanart = FANART_URL + sFanart
            except :
                sFanart = ''

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', 'http://tmdb/%s' % sId)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('type', 'film')
            oOutputParameterHandler.addParameter('searchtext', cUtil().CleanName(sTitle))

            #oGui.addMovieDB('globalSearch', 'showHosters', sTitle, '', sThumb, '', oOutputParameterHandler)
            cGui.CONTENT = "movies"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('actors.png')
            oGuiElement.setMeta(1)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(1)
            #oGuiElement.setDescription(sDesc)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)
         #pas de paramettre de page
        # if (iPage > 0):
            # iNextPage = int(iPage) + 1
            # oOutputParameterHandler = cOutputParameterHandler()
            # oOutputParameterHandler.addParameter('siteUrl', sUrl)
            # oOutputParameterHandler.addParameter('page', iNextPage)
            # oGui.addDir(SITE_IDENTIFIER, 'showFilmActor', '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]', 'next.png', oOutputParameterHandler)

    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
def showSeriesSaison():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()

    sUrl = oInputParameterHandler.getValue('siteUrl')
    sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
    sFanart = oInputParameterHandler.getValue('sFanart')
    sTmdbId = oInputParameterHandler.getValue('sTmdbId')
    sId = oInputParameterHandler.getValue('sId')

    if sId == False:
        sId = sUrl.split('/')[-1]

    if sFanart == False:
        sFanart = ''

    # recherche la serie complete
    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', sMovieTitle)
    # oOutputParameterHandler.addParameter('type', 'serie')
    # oOutputParameterHandler.addParameter('searchtext', sMovieTitle)
    oOutputParameterHandler.addParameter('searchtext',
                                         cUtil().CleanName(sMovieTitle))

    oGuiElement = cGuiElement()
    oGuiElement.setSiteName('globalSearch')
    oGuiElement.setFunction('searchMovie')
    oGuiElement.setTitle(addons.VSlang(30414))
    oGuiElement.setCat(2)
    oGuiElement.setIcon("searchtmdb.png")
    oGui.addFolder(oGuiElement, oOutputParameterHandler)

    result = grab.getUrl(sUrl)
    total = len(result)
    if (total > 0):
        total = len(result['seasons'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['seasons']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sNbreEp, SSeasonNum = i['episode_count'], i['season_number']

            # Mise en forme des infos (au format meta imdb)
            i = grab._format(i, '')
            sId, sTitle, sGenre, sThumb, sFanart, sDesc, sYear = i[
                'tmdb_id'], i['title'], i['genre'], i['cover_url'], i[
                    'backdrop_url'], i['plot'], i['year']

            sTitle = 'Saison ' + str(SSeasonNum) + ' (' + str(sNbreEp) + ')'

            sUrl = 'tv/' + str(sId) + '/season/' + str(SSeasonNum)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sSeason', SSeasonNum)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sTmdbId)
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('showSeriesEpisode')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sMovieTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(7)
            oGuiElement.setDescription(sDesc)
            oGuiElement.setYear(sYear)
            oGuiElement.setGenre(sGenre)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    # changement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
def showMyTmdb():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    tmdb_session = addons.getSetting('tmdb_session')

    if tmdb_session == '':
        oOutputParameterHandler = cOutputParameterHandler()
        oOutputParameterHandler.addParameter('siteUrl', 'https://')
        oGui.addDir(SITE_IDENTIFIER, 'getToken', addons.VSlang(30305), 'trakt.png', oOutputParameterHandler)
    else :

        #pas de deco possible avec l'api donc on test l'username sinon ont supprime tous
        result = grab.getUrl('account', '1', 'session_id=' + tmdb_session)

        if 'username' in result and result['username']:

            #pas de menu sans ID user c'est con
            addons.setSetting('tmdb_account', str(result['id']))

            sUsername = result['username']
            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', 'https://')
            oGui.addText(SITE_IDENTIFIER, (addons.VSlang(30306)) % (sUsername))

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/favorite/movies
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/favorite/movies' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', addons.VSlang(30434), 'films.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/rated/movies
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/rated/movies' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', addons.VSlang(30435), 'notes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/watchlist/movies
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/watchlist/movies' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showMovies', addons.VSlang(30436), 'views.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/favorite/tv
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/favorite/tv' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30437), 'series.png', oOutputParameterHandler)


            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/rated/tv
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/rated/tv' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30438), 'notes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/watchlist/tv
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/watchlist/tv' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30440), 'views.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/rated/tv/episodes
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/rated/tv/episodes' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showSeries', addons.VSlang(30439), 'notes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            #/account/{account_id}/lists
            oOutputParameterHandler.addParameter('session_id', tmdb_session)
            oOutputParameterHandler.addParameter('siteUrl', 'account/%s/lists' % int(result['id']))
            oGui.addDir(SITE_IDENTIFIER, 'showUserLists', addons.VSlang(30441), 'listes.png', oOutputParameterHandler)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', 'http://')
            oGui.addDir(SITE_IDENTIFIER, 'ouTMyTmdb', addons.VSlang(30309), 'listes.png', oOutputParameterHandler)

        else :

            ouTMyTmdb()

    oGui.setEndOfDirectory()
def showActors(sSearch=''):
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    if (oInputParameterHandler.exist('sSearch')):
        sSearch = oInputParameterHandler.getValue('sSearch')

    if sSearch:
        #format obligatoire evite de modif le format de l'url dans la lib >> _call
        #a cause d'un ? pas ou il faut pour ça >> invalid api key
        result = grab.getUrl(sUrl, iPage, 'query=' + sSearch)

    else:
        result = grab.getUrl(sUrl, iPage)

    total = len(result)

    if (total > 0):
        total = len(result['results'])
        progress_ = progress().VScreate(SITE_NAME)

        # récup le nombre de page pour NextPage
        nbrpage = result['total_pages']

        for i in result['results']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sName, sThumb = i['name'], i['profile_path']

            if sThumb:
                POSTER_URL = grab.poster
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sThumb', sThumb)

            sName = sName.encode('utf-8')

            oOutputParameterHandler.addParameter(
                'siteUrl', 'person/' + str(i['id']) + '/movie_credits')
            # oGui.addMovieDB(SITE_IDENTIFIER, 'showFilmActor', '[COLOR red]'+str(sName)+'[/COLOR]', '', sThumb, '', oOutputParameterHandler)
            sTitle = '[COLOR red]' + str(sName) + '[/COLOR]'

            oGuiElement = cGuiElement()
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('showFilmActor')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sName)
            oGuiElement.setIcon('actors.png')
            oGuiElement.setMeta(0)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setCat(7)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

        if (int(iPage) < int(nbrpage)):
            iNextPage = int(iPage) + 1
            oOutputParameterHandler = cOutputParameterHandler()

            # ajoute param sSearch pour garder le bon format d'url avec grab url
            if sSearch:
                oOutputParameterHandler.addParameter('sSearch', sSearch)

            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('page', iNextPage)
            oGui.addNext(SITE_IDENTIFIER, 'showActors',
                         '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]',
                         oOutputParameterHandler)

    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
Esempio n. 31
0
def showFilmActor():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    result = grab.getUrl(sUrl, iPage)

    total = len(result)
    if (total > 0):
        total = len(result['cast'])
        progress_ = progress().VScreate(SITE_NAME)
        oOutputParameterHandler = cOutputParameterHandler()

        for i in result['cast']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            # Mise en forme des infos (au format meta imdb)
            i = grab._format(i, '', "person")

            sId, sTitle, sGenre, sThumb, sFanart, sDesc, sYear = i[
                'tmdb_id'], i['title'], i['genre'], i['poster_path'], i[
                    'backdrop_path'], i['plot'], i['year']

            if not isMatrix():
                sTitle = sTitle.encode("utf-8")

            oOutputParameterHandler.addParameter('siteUrl',
                                                 'http://tmdb/%s' % sId)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            oOutputParameterHandler.addParameter('type', 'film')

            if not isMatrix():
                oOutputParameterHandler.addParameter('searchtext',
                                                     cUtil().CleanName(sTitle))
            else:
                oOutputParameterHandler.addParameter('searchtext', sTitle)

            cGui.CONTENT = "movies"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('films.png')
            oGuiElement.setMeta(1)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(1)
            oGuiElement.setDescription(sDesc)
            oGuiElement.setYear(sYear)
            oGuiElement.setGenre(sGenre)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    # changement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
def showLists():
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    sUrl = oInputParameterHandler.getValue('siteUrl')


    result = grab.getUrl('list/' + sUrl, iPage, '')

    oGui = cGui()

    total = len(result)

    if (total > 0):
        total = len(result['items'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['items']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sId, sType, sThumb, sFanart, sVote, sDesc = i['id'], i['media_type'], i['poster_path'], i['backdrop_path'], i['vote_average'], i['overview']

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            if sFanart:
                sFanart = FANART_URL + sFanart
            else :
                sFanart = ''

            sTitle = "None"

            if 'name' in i:
                sTitle = i['name'].encode("utf-8")
            if 'title' in i:
                sTitle = i['title'].encode("utf-8")

            sDisplayTitle = "%s (%s)" % (sTitle, sVote)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', 'http://tmdb/%s' % sId)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            #oOutputParameterHandler.addParameter('searchtext', sTitle)
            oOutputParameterHandler.addParameter('searchtext', cUtil().CleanName(sTitle))

            #oGui.addTVDB(SITE_IDENTIFIER, 'showSeriesSaison', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "movies"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName('globalSearch')
            oGuiElement.setFunction('showSearch')
            oGuiElement.setTitle(sDisplayTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('series.png')
            if sType == 'movie':
                oGuiElement.setMeta(1)
                oGuiElement.setCat(1)
            elif sType == 'tv':
                oGuiElement.setMeta(2)
                oGuiElement.setCat(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setDescription(sDesc)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
def showSeries(sSearch=''):
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('backdrop_tmdb'))
    
    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    term = ''
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    if (oInputParameterHandler.exist('sSearch')):
        sSearch = oInputParameterHandler.getValue('sSearch')

    if sSearch:
        result = grab.getUrl('search/tv', iPage, 'query=' + sSearch)
        sUrl = ''

    else:
        sUrl = oInputParameterHandler.getValue('siteUrl')

        if (oInputParameterHandler.exist('genre')):
            term = 'with_genres=' +  oInputParameterHandler.getValue('genre')

        if (oInputParameterHandler.exist('session_id')):
            term += 'session_id=' +  oInputParameterHandler.getValue('session_id')

        result = grab.getUrl(sUrl, iPage, term)

    oGui = cGui()

    total = len(result)

    if (total > 0):
        total = len(result['results'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['results']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sId, sTitle, sOtitle, sThumb, sFanart, sDesc = i['id'], i['name'], i['original_name'], i['poster_path'], i['backdrop_path'], i['overview']
            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            if sFanart:
                sFanart = FANART_URL + sFanart
            else :
                sFanart = ''

            sTitle = sTitle.encode("utf-8")

            sSiteUrl = 'tv/' + str(sId)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sSiteUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sId)
            #oOutputParameterHandler.addParameter('searchtext', sTitle)
            oOutputParameterHandler.addParameter('searchtext', cUtil().CleanName(sTitle))


            #oGui.addTVDB(SITE_IDENTIFIER, 'showSeriesSaison', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sId)
            oGuiElement.setSiteName(SITE_IDENTIFIER) # a activer pour  saisons
            #oGuiElement.setSiteName('globalSearch') # a desactiver pour saison
            oGuiElement.setFunction('showSeriesSaison')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(2)
            #oGuiElement.setDescription(sDesc)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

        if (iPage > 0):
            iNextPage = int(iPage) + 1
            oOutputParameterHandler = cOutputParameterHandler()
            if sSearch:
                oOutputParameterHandler.addParameter('sSearch', sSearch)
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('page', iNextPage)
            if (oInputParameterHandler.exist('genre')):
                oOutputParameterHandler.addParameter('genre', oInputParameterHandler.getValue('genre'))
            oGui.addNext(SITE_IDENTIFIER, 'showSeries', '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]', oOutputParameterHandler)

    #chnagement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
Esempio n. 34
0
    def getMetadonne(self):

        metaType = self.getMeta()
        if metaType == 0:  # non media -> on sort, et on enleve le fanart
            self.addItemProperties('fanart_image', '')
            return

        sTitle = self.__sFileName

        # sTitle = self.__sTitle.decode('latin-1').encode('utf-8')
        # sTitle = re.sub(r'\[.*\]|\(.*\)', r'', str(self.__sFileName))
        # sTitle = sTitle.replace('VF', '').replace('VOSTFR', '').replace('FR', '')

        # On nettoie le titre pour la recherche
        sTitle = sTitle.replace('version longue', '')

        # Integrale de films, on nettoie le titre pour la recherche
        if metaType == 3:
            sTitle = sTitle.replace('integrale', '')
            sTitle = sTitle.replace('2 films', '')
            sTitle = sTitle.replace('6 films', '')
            sTitle = sTitle.replace('7 films', '')
            sTitle = sTitle.replace('trilogie', '')
            sTitle = sTitle.replace('trilogy', '')
            sTitle = sTitle.replace('quadrilogie', '')
            sTitle = sTitle.replace('pentalogie', '')
            sTitle = sTitle.replace('octalogie', '')
            sTitle = sTitle.replace('hexalogie', '')
            sTitle = sTitle.replace('tetralogie', '')

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

        if sType:
            from resources.lib.tmdb import cTMDb
            grab = cTMDb()
            args = (sType, sTitle)
            kwargs = {}
            if (self.__ImdbId):
                kwargs['imdb_id'] = self.__ImdbId
            if (self.__TmdbId):
                kwargs['tmdb_id'] = self.__TmdbId
            if (self.__Year):
                kwargs['year'] = self.__Year
            if (self.__Season):
                kwargs['season'] = self.__Season
            if (self.__Episode):
                kwargs['episode'] = self.__Episode
            meta = grab.get_meta(*args, **kwargs)

        else:
            return

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

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

        if 'imdb_id' in meta and meta['imdb_id']:
            self.__ImdbId = meta['imdb_id']

        if 'tmdb_id' in meta and meta['tmdb_id']:
            self.__TmdbId = meta['tmdb_id']

        # if 'tvdb_id' in meta and meta['tvdb_id']:
        # self.__TvdbId = meta['tvdb_id']

        # Si fanart trouvé dans les meta alors on l'utilise, sinon on n'en met pas
        if 'backdrop_url' in meta and meta['backdrop_url']:
            self.addItemProperties('fanart_image', meta['backdrop_url'])
            self.__sFanart = meta['backdrop_url']
        else:
            self.addItemProperties('fanart_image', '')

        if 'trailer' in meta and meta['trailer']:
            # meta['trailer'] = meta['trailer'].replace(u'\u200e', '').replace(u'\u200f', '')
            self.__sTrailer = meta['trailer']

        # Pas de changement de cover pour les coffrets de films
        if metaType != 3:
            if 'cover_url' in meta and meta['cover_url']:
                self.__sThumbnail = meta['cover_url']
                self.__sPoster = meta['cover_url']
        return
Esempio n. 35
0
def showMovies(sSearch=''):
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    oInputParameterHandler = cInputParameterHandler()

    iPage = 1
    term = ''
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    if (oInputParameterHandler.exist('sSearch')):
        sSearch = oInputParameterHandler.getValue('sSearch')

    if sSearch:
        result = grab.getUrl('search/movie', iPage, 'query=' + sSearch)
        sUrl = ''

    else:
        if (oInputParameterHandler.exist('session_id')):
            term += 'session_id=' + oInputParameterHandler.getValue(
                'session_id')

        sUrl = oInputParameterHandler.getValue('siteUrl')
        result = grab.getUrl(sUrl, iPage, term)

    try:
        total = len(result)
        if (total > 0):
            total = len(result['results'])
            progress_ = progress().VScreate(SITE_NAME)

            for i in result['results']:
                progress_.VSupdate(progress_, total)
                if progress_.iscanceled():
                    break

                # Mise en forme des infos (au format meta imdb)
                i = grab._format(i, '', "movie")

                sId, sTitle, sGenre, sThumb, sFanart, sDesc, sYear = i[
                    'tmdb_id'], i['title'], i['genre'], i['poster_path'], i[
                        'backdrop_path'], i['plot'], i['year']

                if not isMatrix():
                    sTitle = sTitle.encode("utf-8")

                oOutputParameterHandler = cOutputParameterHandler()
                oOutputParameterHandler.addParameter('siteUrl',
                                                     'http://tmdb/%s' % sId)
                oOutputParameterHandler.addParameter('sMovieTitle', sTitle)
                oOutputParameterHandler.addParameter('sThumb', sThumb)
                oOutputParameterHandler.addParameter('sTmdbId', sId)
                oOutputParameterHandler.addParameter('type', 'film')

                if isMatrix():
                    oOutputParameterHandler.addParameter('searchtext', sTitle)
                else:
                    oOutputParameterHandler.addParameter(
                        'searchtext',
                        cUtil().CleanName(sTitle))

                cGui.CONTENT = "movies"
                oGuiElement = cGuiElement()
                oGuiElement.setTmdbId(sId)
                oGuiElement.setSiteName('globalSearch')
                oGuiElement.setFunction('showSearch')
                oGuiElement.setTitle(sTitle)
                oGuiElement.setFileName(sTitle)
                oGuiElement.setIcon('films.png')
                oGuiElement.setMeta(1)
                oGuiElement.setThumbnail(sThumb)
                oGuiElement.setPoster(sThumb)
                oGuiElement.setFanart(sFanart)
                oGuiElement.setCat(1)
                oGuiElement.setDescription(sDesc)
                oGuiElement.setYear(sYear)
                oGuiElement.setGenre(sGenre)

                oGui.addFolder(oGuiElement, oOutputParameterHandler)

            progress_.VSclose(progress_)

            if (int(iPage) > 0):
                iNextPage = int(iPage) + 1
                oOutputParameterHandler = cOutputParameterHandler()
                if sSearch:
                    oOutputParameterHandler.addParameter('sSearch', sSearch)

                oOutputParameterHandler.addParameter('siteUrl', sUrl)
                oOutputParameterHandler.addParameter('page', iNextPage)
                oGui.addNext(SITE_IDENTIFIER, 'showMovies',
                             'Page ' + str(iNextPage), oOutputParameterHandler)

    except TypeError as e:
        oGui.addText(SITE_IDENTIFIER,
                     '[COLOR red]Aucun résultat n\'a été trouvé.[/COLOR]')

    # changement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
def getToken():
    grab = cTMDb()
    return grab.getToken()
Esempio n. 37
0
    def SearchBA(self, window=False):

        sTitle = self.search + ' - Bande Annonce'

        # Le lien sur la BA est déjà connu
        urlTrailer = self.sTrailerUrl

        # Sinon recherche de la BA officielle dans TMDB
        if not urlTrailer:
            meta = cTMDb().get_meta(self.metaType, self.search, year=self.year)
            if 'trailer' in meta and meta['trailer']:
                self.SetTrailerUrl(meta['trailer'])
                urlTrailer = self.sTrailerUrl

        # Sinon recherche dans youtube
        if not urlTrailer:
            headers = {
                'User-Agent':
                'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'
            }

            url = 'https://www.youtube.com/results'

            sHtmlContent = requests.get(
                url,
                params={
                    'search_query': sTitle
                },
                cookies={
                    'CONSENT': GestionCookie().Readcookie("youtube")
                },
                headers=headers).text

            if "Proposer des services et s'assurer" in sHtmlContent:
                data = re.search('<form action=(.+?)Accepter',
                                 sHtmlContent).group(1)
                post_data = re.findall(
                    '<input type="hidden" name="(.+?)" value="(.+?)"', data)
                d = {}
                for data in post_data:
                    d.update({data[0]: data[1]})
                cook = requests.post("https://consent.youtube.com/s",
                                     params=d,
                                     headers=headers,
                                     allow_redirects=False).cookies

                GestionCookie().SaveCookie('youtube',
                                           str(dict(cook)["CONSENT"]))

                sHtmlContent = requests.get(url,
                                            params={
                                                'search_query': sTitle
                                            },
                                            cookies={
                                                'CONSENT':
                                                str(dict(cook)["CONSENT"])
                                            },
                                            headers=headers).text

            try:
                result = re.search(
                    '"contents":\[{"videoRenderer":{"videoId":"([^"]+)',
                    str(sHtmlContent)).group(1)
            except:
                result = re.search(
                    '"contents":\[{"videoRenderer":{"videoId":"([^"]+)',
                    sHtmlContent.encode('utf-8')).group(1)

            if result:
                # Premiere video trouvée
                urlTrailer = 'https://www.youtube.com/watch?v=' + result

        # BA trouvée
        if urlTrailer:
            hote = cHoster()
            hote.setUrl(urlTrailer)
            hote.setResolution('720p')
            api_call = hote.getMediaLink()[1]

            if not api_call:
                return

            oGuiElement = cGuiElement()
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setTitle(sTitle)
            oGuiElement.setMediaUrl(api_call)
            oGuiElement.setThumbnail(oGuiElement.getIcon())

            oPlayer = cPlayer()
            oPlayer.clearPlayList()
            oPlayer.addItemToPlaylist(oGuiElement)
            oPlayer.startPlayer(window)

        return
Esempio n. 38
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 vStream 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 vStream'"
        )
        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('vstream_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.mando'
    # self.__oPath.decode('utf-8')
    wd = XMLDialog('DialogInfo4.xml', path, 'default', '720p')
    wd.doModal()
    del wd
Esempio n. 39
0
        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('vstream_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
def showSeriesSaison():
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()

    sUrl = oInputParameterHandler.getValue('siteUrl')
    sMovieTitle = oInputParameterHandler.getValue('sMovieTitle')
    sFanart = oInputParameterHandler.getValue('sFanart')
    sTmdbId = oInputParameterHandler.getValue('sTmdbId')

    sId = oInputParameterHandler.getValue('sId')
    if sId == False:
        sId = sUrl.split('/')[-1]

    if sFanart == False:
        sFanart = ''


    #recherche la serie complete
    oOutputParameterHandler = cOutputParameterHandler()
    oOutputParameterHandler.addParameter('siteUrl', sMovieTitle)
    #oOutputParameterHandler.addParameter('type', 'serie')
    #oOutputParameterHandler.addParameter('searchtext', sMovieTitle)
    oOutputParameterHandler.addParameter('searchtext', cUtil().CleanName(sMovieTitle))

    oGuiElement = cGuiElement()
    oGuiElement.setSiteName('globalSearch')
    oGuiElement.setFunction('searchMovie')
    oGuiElement.setTitle(addons.VSlang(30414))
    oGuiElement.setCat(2)
    oGuiElement.setIcon("searchtmdb.png")
    oGui.addFolder(oGuiElement, oOutputParameterHandler)

    #oGui.addDir('cHome', 'showSearch', addons.VSlang(30414), 'searchtmdb.png', oOutputParameterHandler)
    #fin

    result = grab.getUrl(sUrl)

    total = len(result)

    if (total > 0):

        total = len(result['seasons'])
        progress_ = progress().VScreate(SITE_NAME)

        for i in result['seasons']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sdate, sNbreEp, sIdSeason, sThumb, SSeasonNum = i['air_date'], i['episode_count'], i['id'], i['poster_path'], i['season_number']

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            sTitle = 'Saison ' + str(SSeasonNum) + ' (' + str(sNbreEp) + ')'

            sUrl = 'tv/' + sId + '/season/' + str(SSeasonNum)

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle)
            oOutputParameterHandler.addParameter('sThumb', sThumb)
            oOutputParameterHandler.addParameter('sId', sId)
            oOutputParameterHandler.addParameter('sSeason', SSeasonNum)
            oOutputParameterHandler.addParameter('sFanart', sFanart)
            oOutputParameterHandler.addParameter('sTmdbId', sTmdbId)


            #oGui.addTVDB(SITE_IDENTIFIER, 'showSeriesEpisode', sTitle, 'series.png', sThumb, sFanart, oOutputParameterHandler)

            cGui.CONTENT = "tvshows"
            oGuiElement = cGuiElement()
            oGuiElement.setTmdbId(sTmdbId)
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('showSeriesEpisode')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sMovieTitle)
            oGuiElement.setIcon('series.png')
            oGuiElement.setMeta(2)
            oGuiElement.setMetaAddon('true')
            #oGuiElement.setThumbnail(sThumb)
            #oGuiElement.setPoster(sThumb)
            #oGuiElement.setFanart(sFanart)
            oGuiElement.setCat(7)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

    #chnagement mode
    view = addons.getSetting('visuel-view')

    oGui.setEndOfDirectory(view)
Esempio n. 41
0
    def getMetadonne(self):

        sTitle = self.__sFileName

        #sTitle = self.__sTitle.decode('latin-1').encode("utf-8")
        #sTitle = re.sub(r'\[.*\]|\(.*\)', r'', str(self.__sFileName))
        #sTitle = sTitle.replace('VF', '').replace('VOSTFR', '').replace('FR', '')

        #get_meta(self, media_type, name, imdb_id='', tmdb_id='', year='', overlay=6, update=False):
        metaType = self.getMeta()

        # non media -> pas de fanart
        if metaType == 0:
            self.addItemProperties('fanart_image', '')
            return

        # Integrale de films, on nettoie le titre pour la recherche
        if metaType == 3 :
            sTitle=self.__sFileName.replace('integrale', '')
            sTitle=sTitle.replace('2 films', '')
            sTitle=sTitle.replace('6 films', '')
            sTitle=sTitle.replace('7 films', '')
            sTitle=sTitle.replace('trilogie', '')
            sTitle=sTitle.replace('trilogy', '')
            sTitle=sTitle.replace('quadrilogie', '')
            sTitle=sTitle.replace('pentalogie', '')
            sTitle=sTitle.replace('octalogie', '')
            sTitle=sTitle.replace('hexalogie', '')
            sTitle=sTitle.replace('tetralogie', '')

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

        if sType:
            from resources.lib.tmdb import cTMDb
            grab = cTMDb()
            args = (sType, sTitle)
            kwargs = {}
            if (self.__ImdbId):
                kwargs['imdb_id'] = self.__ImdbId
            if (self.__TmdbId):
                kwargs['tmdb_id'] = self.__TmdbId
            if (self.__Year):
                kwargs['year'] =  self.__Year
            if (self.__Season):
                kwargs['season'] =  self.__Season
            if (self.__Episode):
                kwargs['episode'] =  self.__Episode
            meta = grab.get_meta(*args, **kwargs)

        else :
            return

        #Pour les films
        # if self.getMeta() == 1:
            # try:
                # from metahandler import metahandlers
                # grab = metahandlers.MetaData(preparezip=False, tmdb_api_key=cConfig().getSetting('api_tmdb'))
                # args = ("movie", self.__sFileName)
                # kwargs = {}
                # if (self.__TmdbId) or (self.__Year):
                    # if (self.__ImdbId):
                        # kwargs['imdb_id'] = self.__ImdbId
                    # if (self.__TmdbId):
                        # kwargs['tmdb_id'] = self.__TmdbId
                    # if (self.__Year):
                        # kwargs['year'] =  self.__Year
                # meta = grab.get_meta(*args, **kwargs)
            # except:
                # return

        #Pour les series
        # elif self.getMeta() == 2:
            # try:
                # from metahandler import metahandlers
                # grab = metahandlers.MetaData(preparezip=False, tmdb_api_key=cConfig().getSetting('api_tmdb'))
               # Nom a nettoyer ?
                #attention l'annee peut mettre le bordel a cause des differences de sortie
                # args = ("tvshow", self.__sFileName)
                # kwargs = {}
                # if (self.__TmdbId) or (self.__Year):
                    # dict = {}
                    # if (self.__ImdbId):
                        # kwargs['imdb_id'] = self.__ImdbId
                    # if (self.__TmdbId):
                        # kwargs['tmdb_id'] = self.__TmdbId
                    # if (self.__Year):
                        # kwargs['year'] =  self.__Year
                # meta = grab.get_meta(*args, **kwargs)
            # except:
                # return
        # else:
            # return

        del meta['playcount']
        del meta['trailer']

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

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

        if meta['imdb_id']:
            self.__ImdbId = meta['imdb_id']

        try:
            if meta['tmdb_id']:
                self.__TmdbId = meta['tmdb_id']
        except: pass

        try:
            if meta['tvdb_id']:
                self.__TmdbId = meta['tvdb_id']
        except: pass

        # Si fanart trouvé dans les meta alors on l'utilise, sinon on n'en met pas
        if meta['backdrop_url']:
            self.addItemProperties('fanart_image', meta['backdrop_url'])
            self.__sFanart = meta['backdrop_url']
        else:
            self.addItemProperties('fanart_image', '')

        # if meta['trailer_url']:
            # meta['trailer'] = meta['trailer'].replace(u'\u200e', '').replace(u'\u200f', '')
            # self.__sTrailerUrl = meta['trailer']

        # Pas de changement de cover pour les coffrets de films
        if metaType != 3:
            if meta['cover_url']:
                self.__sThumbnail = meta['cover_url']
                self.__sPoster = meta['cover_url']
        return
def showActors(sSearch = ''):
    oGui = cGui()
    grab = cTMDb()
    addons = addon()

    POSTER_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('poster_tmdb'))
    FANART_URL = ('https://image.tmdb.org/t/p/%s') % (addons.getSetting('backdrop_tmdb'))

    oInputParameterHandler = cInputParameterHandler()
    sUrl = oInputParameterHandler.getValue('siteUrl')

    iPage = 1
    if (oInputParameterHandler.exist('page')):
        iPage = oInputParameterHandler.getValue('page')

    if (oInputParameterHandler.exist('sSearch')):
        sSearch = oInputParameterHandler.getValue('sSearch')

    if sSearch:
        #format obligatoire evite de modif le format de l'url dans la lib >> _call
        #a cause d'un ? pas ou il faut pour ça >> invalid api key
        result = grab.getUrl(sUrl,iPage,'query=' + sSearch) 

    else:
        result = grab.getUrl(sUrl, iPage)

    total = len(result)
    dialog = progress()
    dialog.VScreate(SITE_NAME)

    if (total > 0):
        total = len(result['results'])
        progress_ = progress().VScreate(SITE_NAME)
        
        #récup le nombre de page pour NextPage
        nbrpage = result['total_pages']

        for i in result['results']:
            progress_.VSupdate(progress_, total)
            if progress_.iscanceled():
                break

            sName, sThumb = i['name'], i['profile_path']

            if sThumb:
                sThumb = POSTER_URL + sThumb
            else:
                sThumb = ''

            oOutputParameterHandler = cOutputParameterHandler()
            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('sThumb', sThumb)

            sName = sName.encode('utf-8')

            oOutputParameterHandler.addParameter('siteUrl', 'person/' + str(i['id']) + '/movie_credits')
            #oGui.addMovieDB(SITE_IDENTIFIER, 'showFilmActor', '[COLOR red]'+str(sName)+'[/COLOR]', '', sThumb, '', oOutputParameterHandler)
            sTitle = '[COLOR red]' + str(sName) + '[/COLOR]'

            oGuiElement = cGuiElement()
            oGuiElement.setSiteName(SITE_IDENTIFIER)
            oGuiElement.setFunction('showFilmActor')
            oGuiElement.setTitle(sTitle)
            oGuiElement.setFileName(sName)
            oGuiElement.setIcon('actors.png')
            oGuiElement.setMeta(0)
            oGuiElement.setThumbnail(sThumb)
            oGuiElement.setPoster(sThumb)
            oGuiElement.setCat(7)

            oGui.addFolder(oGuiElement, oOutputParameterHandler)

        progress_.VSclose(progress_)

        if (int(iPage) < int(nbrpage)):
            iNextPage = int(iPage) + 1
            oOutputParameterHandler = cOutputParameterHandler()
            
            #ajoute param sSearch pour garder le bon format d'url avec grab url
            if sSearch:
                oOutputParameterHandler.addParameter('sSearch', sSearch)

            oOutputParameterHandler.addParameter('siteUrl', sUrl)
            oOutputParameterHandler.addParameter('page', iNextPage)
            oGui.addNext(SITE_IDENTIFIER, 'showActors', '[COLOR teal]Page ' + str(iNextPage) + ' >>>[/COLOR]', oOutputParameterHandler)

    view = addons.getSetting('visuel-view')
    oGui.setEndOfDirectory(view)
Esempio n. 43
0
    def getMetadonne(self):
        metaType = self.getMeta()
        if metaType == 0:  # non media -> on sort, et on enleve le fanart
            self.addItemProperties('fanart_image', '')
            return

        from resources.lib.tmdb import cTMDb
        TMDb = cTMDb()

        sTitle = self.__sFileName

        # sTitle = self.__sTitle.decode('latin-1').encode('utf-8')
        # sTitle = re.sub(r'\[.*\]|\(.*\)', r'', str(self.__sFileName))
        # sTitle = sTitle.replace('VF', '').replace('VOSTFR', '').replace('FR', '')

        # On nettoie le titre pour la recherche
        sTitle = sTitle.replace('version longue', '')

        # Integrale de films, on nettoie le titre pour la recherche
        if metaType == 3:
            sTitle = sTitle.replace('integrales', '')
            sTitle = sTitle.replace('integrale', '')
            sTitle = sTitle.replace('2 films', '')
            sTitle = sTitle.replace('6 films', '')
            sTitle = sTitle.replace('7 films', '')
            sTitle = sTitle.replace('trilogie', '')
            sTitle = sTitle.replace('trilogy', '')
            sTitle = sTitle.replace('quadrilogie', '')
            sTitle = sTitle.replace('pentalogie', '')
            sTitle = sTitle.replace('octalogie', '')
            sTitle = sTitle.replace('hexalogie', '')
            sTitle = sTitle.replace('tetralogie', '')
            sTitle = sTitle.strip()
            if sTitle.endswith(' les'):
                sTitle = sTitle[:-4]
            elif sTitle.endswith(' la') :
                sTitle = sTitle[:-3]
            elif sTitle.endswith(' l') :
                sTitle = sTitle[:-2]
            sTitle = sTitle.strip()

        # tvshow
        if metaType in (2, 4, 5, 6):
            tvshowtitle = self.getItemValue('tvshowtitle')
            if tvshowtitle:
                sTitle =  tvshowtitle
                   
        sType = str(metaType).replace('1', 'movie').replace('2', 'tvshow').replace('3', 'collection').replace('4', 'anime').replace('5', 'season').replace('6', 'episode').replace('7', 'person').replace('8', 'network')

        meta = {}
        try:
            if sType:
                args = (sType, sTitle)
                kwargs = {}
                if (self.__ImdbId):
                    kwargs['imdb_id'] = self.__ImdbId
                if (self.__TmdbId):
                    kwargs['tmdb_id'] = self.__TmdbId
                if (self.__Year):
                    kwargs['year'] = self.__Year
                if (self.__Season):
                    kwargs['season'] = self.__Season
                if (self.__Episode):
                    kwargs['episode'] = self.__Episode

                meta = TMDb.get_meta(*args, **kwargs)
                if not meta:
                    return
            else:
                return
        except:
            return

        if 'media_type' in meta:
            meta.pop('media_type')

        if 'imdb_id' in meta:
            imdb_id = meta.pop('imdb_id')
            if imdb_id:
                self.__ImdbId = imdb_id

        if 'tmdb_id' in meta:
            tmdb_id = meta.pop('tmdb_id')
            if tmdb_id:
                self.__TmdbId = tmdb_id

        if 'tvdb_id' in meta:
            meta.pop('tvdb_id')

        if 'backdrop_path' in meta:
            url = meta.pop('backdrop_path')
            if url:
                self.addItemProperties('fanart_image', url)
                self.__sFanart = url
            else:
                self.addItemProperties('fanart_image', '')

        if 'poster_path' in meta:
            url = meta.pop('poster_path')
            if url:
                self.__sThumbnail = url
                self.__sPoster = url

        if 'trailer' in meta and meta['trailer']:
            self.__sTrailer = meta['trailer']
        
        if 'guest_stars' in meta:
            meta.pop('guest_stars')
        
        if 'nbseasons' in meta:
            meta['season'] = meta.pop('nbseasons')

        # Retrait des tags intermédiaires
        if 'vote' in meta:
            meta.pop('vote')
        if 'runtime' in meta:
            meta.pop('runtime')
        if 'crew' in meta:
            meta.pop('crew')
        if 'overview' in meta:
            meta.pop('overview')
        if 'vote_average' in meta:
            meta.pop('vote_average')
        if 'vote_count' in meta:
            meta.pop('vote_count')
        if 'backdrop_url' in meta:
            meta.pop('backdrop_url')
            
        for key, value in meta.items():
            self.addItemValues(key, value)
            
        return