示例#1
0
        tags.setTrailer('/home/akva/fluffy/bunnies.mkv')
        tags.setGenres(['Action', 'Comedy'])
        tags.setWriters(['None', 'Want', 'To Admit It'])
        tags.setDirectors(['Director 1', 'Director 2'])
        tags.setStudios(['Studio1', 'Studio2'])
        tags.setDateAdded('2016-01-01')
        tags.setPremiered('2015-01-01')
        tags.setFirstAired('2007-01-01')
        tags.setTvShowStatus('Cancelled')
        tags.setEpisodeGuide('/path/to/show/guide')
        tags.setTagLine('Family / Mom <3')
        tags.setRatings({'imdb': (9, 100000), 'tvdb': (8.9, 1000)}, defaultRating='imdb')
        tags.setUniqueIDs({'imdb': 'tt8938399', 'tmdb': '9837493'}, defaultUniqueID='tvdb')
        tags.addSeason(1, 'Beautiful')
        tags.addSeason(2, 'Sun')
        tags.setCast([xbmc.Actor('spiff', 'himself', order=2, thumbnail='/home/akva/Pictures/fish.jpg'),
                      xbmc.Actor('monkey', 'orange', order=1, thumbnail='/home/akva/Pictures/coffee.jpg')])
        tags.addAvailableArtwork('DefaultBackFanart.png', 'banner')
        tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
        liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
                                {'image': '/home/akva/Pictures/hawaii-shirt.png',
                                 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
        xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz)

elif action == 'getepisodelist':
    url = params['url']
    xbmc.log(f'Get episode list callback "{url}"', xbmc.LOGDEBUG)
    if url == '/path/to/show/guide':
        liz = xbmcgui.ListItem('Demo Episode 1x1', offscreen=True)
        tags = liz.getVideoInfoTag()
        tags.setTitle('Demo Episode 1')
示例#2
0
    def createListItem(self, oGuiElement):
        # Enleve les elements vides
        data = {
            key: val
            for key, val in oGuiElement.getItemValues().items() if val != ""
        }

        itemTitle = oGuiElement.getTitle()
        if oGuiElement.getMeta() == 6 and data.get(
                'tagline'):  # Nom de l'épisode
            itemTitle += ' - ' + str(data.get('tagline'))
            data['title'] = itemTitle  # kodi 19

        oListItem = listitem(itemTitle)

        if not isNexus():
            # voir : https://kodi.wiki/view/InfoLabels
            oListItem.setInfo(oGuiElement.getType(), data)

        else:
            videoInfoTag = oListItem.getVideoInfoTag()

            # gestion des valeurs par defaut si non renseignées
            videoInfoTag.setMediaType(data.get('mediatype'))
            videoInfoTag.setTitle(itemTitle)
            videoInfoTag.setOriginalTitle(data.get('originaltitle'))
            videoInfoTag.setPlot(data.get('plot'))
            videoInfoTag.setPlotOutline(data.get('plotoutline'))
            videoInfoTag.setYear(int(data.get('year', 0)))
            videoInfoTag.setRating(float(data.get('rating', 0.0)))
            videoInfoTag.setMpaa(data.get('mpaa'))
            try:
                videoInfoTag.setDuration(int(data.get('duration', 0)))
            except:
                #Pour convertir le temps en seconde.
                videoInfoTag.setDuration(
                    sum(x * int(t)
                        for x, t in zip([3600, 60, 1],
                                        data.get('duration').split(":"))))
            videoInfoTag.setPlaycount(int(data.get('playcount', 0)))
            videoInfoTag.setCountries(data.get('country', [""]))
            videoInfoTag.setTrailer(data.get('trailer'))
            videoInfoTag.setTagLine(data.get('tagline'))
            videoInfoTag.setStudios(list(data.get('studio', '').split("/")))
            videoInfoTag.setWriters(list(data.get('writer', '').split("/")))
            videoInfoTag.setDirectors(list(
                data.get('director', '').split("/")))
            videoInfoTag.setGenres(''.join(data.get('genre', [""])).split('/'))
            videoInfoTag.setSeason(int(data.get('season', 0)))
            videoInfoTag.setEpisode(int(data.get('episode', 0)))

            # TODO Gestion du pourcentage de lecture
            # v20 Python API changes:
            # ResumeTime and TotalTime deprecated. Use InfoTagVideo.setResumePoint() instead.

            try:
                credits = eval(data.get('credits'))['cast']
            except:
                credits = None

            cast = []
            if credits is not None:
                for actor in credits:
                    thumbnail = actor['profile_path']
                    cast.append(
                        xbmc.Actor(actor['name'], actor['character'],
                                   actor['order'], thumbnail))
                videoInfoTag.setCast(cast)

        oListItem.setArt({
            'poster': oGuiElement.getPoster(),
            'thumb': oGuiElement.getThumbnail(),
            'icon': oGuiElement.getIcon(),
            'fanart': oGuiElement.getFanart()
        })

        aProperties = oGuiElement.getItemProperties()
        for sPropertyKey, sPropertyValue in aProperties.items():
            oListItem.setProperty(sPropertyKey, str(sPropertyValue))

        return oListItem
示例#3
0
    def fillVideoInfos(plexServer: server.PlexServer,
                       itemId: int,
                       plexItem: video.Video,
                       mediaType: str,
                       item: ListItem,
                       allowDirectPlay: bool = False):
        """
        Populate the provided ListItem object with existing data from plexItem
        and additional detail pulled from the provided plexServer

        :param plexServer: Plex server to gather additional details from
        :type plexServer: server.PlexServer
        :param itemId: Unique ID of the plex Video object item
        :type itemId: int
        :param plexItem: Plex object populated with information about the item
        :type plexItem: video.Video
        :param mediaType: Kodi Media type object
        :type mediaType: str
        :param item: Instantiated Kodi ListItem to populate with additional details
        :type item: :class:`ListItem`
        :param allowDirectPlay: Settings definition on provider if directPlay is allowed
        :type allowDirectPlay: bool, optional
        """
        videoInfoTag = item.getVideoInfoTag()

        videoInfoTag.setMediaType(mediaType)
        videoInfoTag.setTitle(item.getLabel() or '')

        date = None
        isFolder = False

        resumeTime = 0.0
        duration = 0.0

        artwork = {}
        collections = []
        media = []
        locations = []
        roles = []

        if isinstance(plexItem, video.Video):
            videoInfoTag.setSortTitle(plexItem.titleSort or '')
            videoInfoTag.setPlot(plexItem.summary or '')
            videoInfoTag.setDateAdded(
                Api.convertDateTimeToDbDateTime(plexItem.addedAt))
            videoInfoTag.setPlaycount(plexItem.viewCount or 0)
            videoInfoTag.setLastPlayed(
                Api.convertDateTimeToDbDateTime(plexItem.lastViewedAt))
            videoInfoTag.setTags([plexItem.librarySectionTitle])

        if isinstance(plexItem, video.Movie):
            date = Api.convertDateTimeToDbDate(plexItem.originallyAvailableAt)
            duration = Api.MillisecondsToSeconds(plexItem.duration)
            resumeTime = Api.MillisecondsToSeconds(plexItem.viewOffset)
            collections = plexItem.collections or []
            media = plexItem.media or []
            roles = plexItem.roles or []

            videoInfoTag.setMpaa(plexItem.contentRating or '')
            videoInfoTag.setDuration(int(duration))
            videoInfoTag.setOriginalTitle(plexItem.originalTitle or '')
            videoInfoTag.setPremiered(date)
            videoInfoTag.setRating(plexItem.rating or 0.0)
            videoInfoTag.setTagLine(plexItem.tagline or '')
            videoInfoTag.setUserRating(int(plexItem.userRating or 0))
            videoInfoTag.setYear(plexItem.year or 0)
            videoInfoTag.setStudios(Api.ListFromString(plexItem.studio))
            videoInfoTag.setCountries(Api.ListFromMediaTags(
                plexItem.countries))
            videoInfoTag.setGenres(Api.ListFromMediaTags(plexItem.genres))
            videoInfoTag.setDirectors(Api.ListFromMediaTags(
                plexItem.directors))
            videoInfoTag.setWriters(Api.ListFromMediaTags(plexItem.writers))
        elif isinstance(plexItem, collection.Collection):
            # ignore empty collections
            if plexItem.childCount <= 0:
                return

            isFolder = True

            videoInfoTag.setPlot(plexItem.summary or '')
            videoInfoTag.setDateAdded(
                Api.convertDateTimeToDbDateTime(plexItem.addedAt))
        elif isinstance(plexItem, video.Show):
            isFolder = True
            date = Api.convertDateTimeToDbDate(plexItem.originallyAvailableAt)
            duration = Api.MillisecondsToSeconds(plexItem.duration)
            locations = plexItem.locations or []
            collections = plexItem.collections or []
            roles = plexItem.roles or []

            banner = plexItem.banner
            if banner:
                artwork['banner'] = plexServer.url(banner, includeToken=True)

            videoInfoTag.setMpaa(plexItem.contentRating or '')
            videoInfoTag.setDuration(int(duration))
            videoInfoTag.setOriginalTitle(plexItem.originalTitle or '')
            videoInfoTag.setPremiered(date)
            videoInfoTag.setRating(plexItem.rating or 0.0)
            videoInfoTag.setTagLine(plexItem.tagline or '')
            videoInfoTag.setYear(plexItem.year or 0)
            videoInfoTag.setStudios(Api.ListFromString(plexItem.studio))
            videoInfoTag.setGenres(Api.ListFromMediaTags(plexItem.genres))
        elif isinstance(plexItem, video.Season):
            isFolder = True

            videoInfoTag.setTvShowTitle(plexItem.parentTitle or '')
            videoInfoTag.setSeason(plexItem.index)
        elif isinstance(plexItem, video.Episode):
            date = Api.convertDateTimeToDbDate(plexItem.originallyAvailableAt)
            resumeTime = Api.MillisecondsToSeconds(plexItem.viewOffset)
            duration = Api.MillisecondsToSeconds(plexItem.duration)
            media = plexItem.media or []

            videoInfoTag.setTvShowTitle(plexItem.grandparentTitle or '')
            videoInfoTag.setSeason(int(plexItem.parentIndex))
            videoInfoTag.setEpisode(plexItem.index)
            videoInfoTag.setMpaa(plexItem.contentRating or '')
            videoInfoTag.setDuration(int(duration))
            videoInfoTag.setFirstAired(date)
            videoInfoTag.setRating(plexItem.rating or 0.0)
            videoInfoTag.setYear(plexItem.year or 0)
            videoInfoTag.setDirectors(Api.ListFromMediaTags(
                plexItem.directors))
            videoInfoTag.setWriters(Api.ListFromMediaTags(plexItem.writers))

        # handle collections / sets
        collections = Api.ListFromMediaTags(collections)
        if collections:
            # Kodi can only store one set per media item
            videoInfoTag.setSet(collections[0])

        # set the item's datetime if available
        if date:
            item.setDateTime(date)

        # specify whether the item is a folder or not
        item.setIsFolder(isFolder)

        # add the item's ID as a unique ID belonging to Plex
        uniqueIDs = {PLEX_PROTOCOL: str(itemId)}
        # retrieve and map GUIDS from Plex
        if isinstance(plexItem,
                      (video.Movie, video.Show, video.Season, video.Episode)):
            guids = Api._mapGuids(plexItem.guids)
            if guids:
                uniqueIDs = {**guids, **uniqueIDs}

        videoInfoTag.setUniqueIDs(uniqueIDs, PLEX_PROTOCOL)

        # handle actors / cast
        cast = []
        for index, role in enumerate(roles):
            actor = xbmc.Actor(role.tag.strip(), (role.role or '').strip(),
                               index, role.thumb)
            cast.append(actor)
        if cast:
            videoInfoTag.setCast(cast)

        # handle resume point
        if resumeTime > 0 and duration > 0.0:
            videoInfoTag.setResumePoint(resumeTime, duration)

        # handle stream details
        path = None
        for mediaStream in media:
            for part in mediaStream.parts:
                # pick the first MediaPart with a valid file and stream URL
                if not path and part.file and part.key:
                    path = part.file

                for videoStream in part.videoStreams():
                    videoInfoTag.addVideoStream(
                        xbmc.VideoStreamDetail(width=videoStream.width or 0,
                                               height=videoStream.height or 0,
                                               codec=videoStream.codec or '',
                                               duration=int(duration),
                                               language=videoStream.language
                                               or ''))

                for audioStream in part.audioStreams():
                    videoInfoTag.addAudioStream(
                        xbmc.AudioStreamDetail(channels=audioStream.channels
                                               or 2,
                                               codec=audioStream.codec or '',
                                               language=audioStream.language
                                               or ''))

                for index, subtitleStream in enumerate(part.subtitleStreams()):
                    videoInfoTag.addSubtitleStream(
                        xbmc.SubtitleStreamDetail(
                            language=subtitleStream.language or f"[{index}]"))

        if isFolder:
            # for folders use locations for the path
            if locations:
                path = locations[0]
            item.setPath(plexServer.url(plexItem.key, includeToken=True))
        else:
            # determine if directPlay is enabled and possible
            if allowDirectPlay:
                directPlayUrl = Api.getDirectPlayUrlFromPlexItem(plexItem)
                if directPlayUrl:
                    item.setPath(directPlayUrl)

            # otherwise determine the stream URL
            if not item.getPath():
                item.setPath(Api.getStreamUrlFromPlexItem(
                    plexItem, plexServer))

        if path:
            videoInfoTag.setPath(path)
        videoInfoTag.setFilenameAndPath(item.getPath())

        # handle artwork
        poster = None
        fanart = None
        if isinstance(plexItem, video.Video):
            poster = plexItem.thumbUrl
            fanart = plexItem.artUrl
        elif isinstance(plexItem, collection.Collection) and plexItem.thumb:
            poster = plexServer.url(plexItem.thumb, includeToken=True)

        if poster:
            artwork['poster'] = poster
        if fanart:
            artwork['fanart'] = fanart
        if artwork:
            item.setArt(artwork)
示例#4
0
    def createVideoInfoItemWithVideoSetters(embyServer,
                                            itemId,
                                            itemPath,
                                            itemObj,
                                            mediaType,
                                            libraryView='',
                                            allowDirectPlay=True):

        item = ListItem(path=itemPath,
                        label=itemObj.get(constants.PROPERTY_ITEM_NAME, ''),
                        offscreen=True)
        item.setIsFolder(itemObj.get(constants.PROPERTY_ITEM_IS_FOLDER, False))

        # handle date
        premiereDate = itemObj.get(constants.PROPERTY_ITEM_PREMIERE_DATE)
        if premiereDate:
            item.setDateTime(premiereDate)

        videoInfoTag = item.getVideoInfoTag()

        userdata = {}
        if constants.PROPERTY_ITEM_USER_DATA in itemObj:
            userdata = itemObj[constants.PROPERTY_ITEM_USER_DATA]

        duration = int(
            Api.ticksToSeconds(
                itemObj.get(constants.PROPERTY_ITEM_RUN_TIME_TICKS, 0)))

        videoInfoTag.setMediaType(mediaType)
        videoInfoTag.setPath(itemObj.get(constants.PROPERTY_ITEM_PATH, ''))
        videoInfoTag.setFilenameAndPath(item.getPath())
        videoInfoTag.setTitle(item.getLabel() or '')
        videoInfoTag.setSortTitle(
            itemObj.get(constants.PROPERTY_ITEM_SORT_NAME, ''))
        videoInfoTag.setOriginalTitle(
            itemObj.get(constants.PROPERTY_ITEM_ORIGINAL_TITLE, ''))
        videoInfoTag.setPlot(
            Api._mapOverview(itemObj.get(constants.PROPERTY_ITEM_OVERVIEW,
                                         '')))
        videoInfoTag.setPlotOutline(
            itemObj.get(constants.PROPERTY_ITEM_SHORT_OVERVIEW, ''))
        videoInfoTag.setDateAdded(
            Api.convertDateTimeToDbDateTime(
                itemObj.get(constants.PROPERTY_ITEM_DATE_CREATED, '')))
        videoInfoTag.setYear(
            itemObj.get(constants.PROPERTY_ITEM_PRODUCTION_YEAR, 0))
        videoInfoTag.setMpaa(
            Api._mapMpaa(
                itemObj.get(constants.PROPERTY_ITEM_OFFICIAL_RATING, '')))
        videoInfoTag.setDuration(duration)
        videoInfoTag.setPlaycount(
            userdata.get(constants.PROPERTY_ITEM_USER_DATA_PLAY_COUNT, 0
                         ) if userdata.
            get(constants.PROPERTY_ITEM_USER_DATA_PLAYED, False) else 0)
        videoInfoTag.setLastPlayed(
            Api.convertDateTimeToDbDateTime(
                userdata.get(
                    constants.PROPERTY_ITEM_USER_DATA_LAST_PLAYED_DATE, '')))
        videoInfoTag.setArtists(
            itemObj.get(constants.PROPERTY_ITEM_ARTISTS, []))
        videoInfoTag.setAlbum(itemObj.get(constants.PROPERTY_ITEM_ALBUM, ''))
        videoInfoTag.setGenres(itemObj.get(constants.PROPERTY_ITEM_GENRES, []))
        videoInfoTag.setCountries(
            itemObj.get(constants.PROPERTY_ITEM_PRODUCTION_LOCATIONS, []))

        # process ratings
        if constants.PROPERTY_ITEM_COMMUNITY_RATING in itemObj:
            defaultRating = itemObj.get(
                constants.PROPERTY_ITEM_COMMUNITY_RATING)
            videoInfoTag.setRating(defaultRating, isDefault=True)
        # handle critic rating as rotten tomato rating
        if constants.PROPERTY_ITEM_CRITIC_RATING in itemObj:
            criticRating = float(
                itemObj.get(constants.PROPERTY_ITEM_CRITIC_RATING)) / 10.0
            videoInfoTag.setRating(criticRating, type='tomatometerallcritics')

        # handle unique / provider IDs
        uniqueIds = \
            {key.lower(): value for key, value in iteritems(itemObj.get(constants.PROPERTY_ITEM_PROVIDER_IDS, {}))}
        defaultUniqueId = Api._mapDefaultUniqueId(uniqueIds, mediaType)
        # add the item's ID as a unique ID belonging to Emby
        uniqueIds[constants.EMBY_PROTOCOL] = itemId
        videoInfoTag.setUniqueIDs(uniqueIds, defaultUniqueId)

        # process tags
        tags = []
        if constants.PROPERTY_ITEM_TAG_ITEMS in itemObj:
            tags = [
                tag.get(constants.PROPERTY_ITEM_TAG_ITEMS_NAME)
                for tag in itemObj.get(constants.PROPERTY_ITEM_TAG_ITEMS)
                if constants.PROPERTY_ITEM_TAG_ITEMS_NAME in tag
            ]
        # add the library view as a tag
        if libraryView:
            tags.append(libraryView)
        videoInfoTag.setTags(tags)

        # handle aired / premiered
        if premiereDate:
            pos = premiereDate.find('T')
            if pos >= 0:
                premiereDate = premiereDate[:pos]

            if mediaType == xbmcmediaimport.MediaTypeEpisode:
                videoInfoTag.setFirstAired(premiereDate)
            else:
                videoInfoTag.setPremiered(premiereDate)

        # handle trailers
        trailerUrl = Api.getTrailer(embyServer,
                                    itemId,
                                    itemObj,
                                    allowDirectPlay=allowDirectPlay)
        if trailerUrl:
            videoInfoTag.setTrailer(trailerUrl)

        # handle taglines
        embyTaglines = itemObj.get(constants.PROPERTY_ITEM_TAGLINES, [])
        if embyTaglines:
            videoInfoTag.setTagLine(embyTaglines[0])

        # handle studios
        studios = []
        for studio in itemObj.get(constants.PROPERTY_ITEM_STUDIOS, []):
            studios.append(Api._mapStudio(studio['Name']))
        videoInfoTag.setStudios(studios)

        # handle tvshow, season and episode specific properties
        if mediaType == xbmcmediaimport.MediaTypeTvShow:
            videoInfoTag.setTvShowTitle(videoInfoTag.getTitle())
            videoInfoTag.setTvShowStatus(
                itemObj.get(constants.PROPERTY_ITEM_STATUS, ''))
        elif mediaType in (xbmcmediaimport.MediaTypeSeason,
                           xbmcmediaimport.MediaTypeEpisode):
            videoInfoTag.setTvShowTitle(
                itemObj.get(constants.PROPERTY_ITEM_SERIES_NAME, ''))
            index = itemObj.get(constants.PROPERTY_ITEM_INDEX_NUMBER, 0)
            if mediaType == xbmcmediaimport.MediaTypeSeason:
                videoInfoTag.setSeason(index)

                # ATTENTION
                # something is wrong with the SortName property for seasons which interfers with Kodi
                # abusing sorttitle for custom season titles
                videoInfoTag.setSortTitle('')
            else:
                videoInfoTag.setSeason(
                    itemObj.get(constants.PROPERTY_ITEM_PARENT_INDEX_NUMBER,
                                0))
                videoInfoTag.setEpisode(index)

        # handle resume point
        videoInfoTag.setResumePoint(
            Api.ticksToSeconds(
                userdata.get(
                    constants.PROPERTY_ITEM_USER_DATA_PLAYBACK_POSITION_TICKS,
                    0)), duration)

        # handle actors / cast
        cast = []
        writers = []
        directors = []
        for index, person in enumerate(
                itemObj.get(constants.PROPERTY_ITEM_PEOPLE, [])):
            name = person.get(constants.PROPERTY_ITEM_PEOPLE_NAME, '')
            castType = person.get(constants.PROPERTY_ITEM_PEOPLE_TYPE, '')
            if castType == constants.PROPERTY_ITEM_PEOPLE_TYPE_ACTOR:
                role = person.get(constants.PROPERTY_ITEM_PEOPLE_ROLE, '')
                # determine the thumbnail (if available)
                thumbnail = ''
                personId = person.get(constants.PROPERTY_ITEM_PEOPLE_ID, None)
                primaryImageTag = person.get(
                    constants.PROPERTY_ITEM_PEOPLE_PRIMARY_IMAGE_TAG, '')
                if personId and primaryImageTag:
                    thumbnail = \
                        embyServer.BuildImageUrl(personId, constants.PROPERTY_ITEM_IMAGE_TAGS_PRIMARY, primaryImageTag)

                cast.append(xbmc.Actor(name, role, index, thumbnail))
            elif castType == constants.PROPERTY_ITEM_PEOPLE_TYPE_WRITER:
                writers.append(name)
            elif castType == constants.PROPERTY_ITEM_PEOPLE_TYPE_DIRECTOR:
                directors.append(name)

        videoInfoTag.setCast(cast)
        videoInfoTag.setWriters(writers)
        videoInfoTag.setDirectors(directors)

        # stream details
        for stream in itemObj.get(constants.PROPERTY_ITEM_MEDIA_STREAMS, []):
            streamType = stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_TYPE,
                                    '')
            if streamType == 'video':
                details = Api._mapVideoStream({
                    'codec':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_CODEC, ''),
                    'profile':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_PROFILE,
                               ''),
                    'language':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_LANGUAGE,
                               ''),
                    'width':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_WIDTH, 0),
                    'height':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_HEIGHT, 0),
                    'aspect':
                    stream.get(
                        constants.PROPERTY_ITEM_MEDIA_STREAM_ASPECT_RATIO,
                        '0'),
                    'stereomode':
                    stream.get(
                        constants.PROPERTY_ITEM_MEDIA_STREAM_VIDEO_3D_FORMAT,
                        'mono'),
                    'duration':
                    duration
                })
                videoInfoTag.addVideoStream(
                    xbmc.VideoStreamDetail(
                        width=details['width'],
                        height=details['height'],
                        aspect=details['aspect'],
                        duration=details['duration'],
                        codec=details['codec'],
                        stereoMode=details['stereomode'],
                        language=details['language'],
                    ))
            elif streamType == 'audio':
                details = Api._mapAudioStream({
                    'codec':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_CODEC, ''),
                    'profile':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_PROFILE,
                               ''),
                    'language':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_LANGUAGE,
                               ''),
                    'channels':
                    stream.get(constants.PROPERTY_ITEM_MEDIA_STREAM_CHANNELS,
                               2)
                })
                videoInfoTag.addAudioStream(
                    xbmc.AudioStreamDetail(
                        channels=details['channels'],
                        codec=details['codec'],
                        language=details['language'],
                    ))
            elif streamType == 'subtitle':
                videoInfoTag.addSubtitleStream(
                    xbmc.SubtitleStreamDetail(language=stream.get(
                        constants.PROPERTY_ITEM_MEDIA_STREAM_LANGUAGE, ''), ))

        return item
示例#5
0
    def createListItem(self, oGuiElement):
        # Enleve les elements vides
        data = {
            key: val
            for key, val in oGuiElement.getItemValues().items() if val != ""
        }

        itemTitle = oGuiElement.getTitle()

        # Formatage nom episode
        sCat = oGuiElement.getCat()
        if sCat and int(sCat) == 8:  # Nom de l'épisode
            try:
                if 'tagline' in data and data['tagline']:
                    episodeTitle = data['tagline']
                else:
                    episodeTitle = 'Episode ' + str(data['episode'])
                host = ''
                if 'tvshowtitle' in data:
                    host = itemTitle.split(data['tvshowtitle'])[1]
                itemTitle = str(data['season']) + "x" + str(
                    data['episode']) + ". " + episodeTitle + " " + host
                data['title'] = itemTitle
            except:
                data['title'] = itemTitle
                pass
        else:
            #Permets d'afficher toutes les informations pour les films.
            data['title'] = itemTitle

        if ":" in str(data.get('duration')):
            # Convertion en seconde, utile pour le lien final.
            data['duration'] = (sum(x * int(t) for x, t in zip(
                [1, 60, 3600], reversed(data.get('duration', '').split(":")))))

        oListItem = listitem(itemTitle)

        if data.get('cast'):
            credits = json.loads(data['cast'])
            data['cast'] = []
            for i in credits:
                if isNexus():
                    data['cast'].append(
                        xbmc.Actor(i['name'], i['character'], i['order'],
                                   i.get('thumbnail', "")))
                else:
                    data['cast'].append((i['name'], i['character'], i['order'],
                                         i.get('thumbnail', "")))
        else:
            credits = None

        if not isNexus():
            # voir : https://kodi.wiki/view/InfoLabels
            oListItem.setInfo(oGuiElement.getType(), data)

        else:
            videoInfoTag = oListItem.getVideoInfoTag()

            # gestion des valeurs par defaut si non renseignées
            videoInfoTag.setMediaType(data.get('mediatype', ""))
            videoInfoTag.setTitle(data.get('title', ""))
            videoInfoTag.setTvShowTitle(data.get('tvshowtitle', ''))
            videoInfoTag.setOriginalTitle(data.get('originaltitle', ""))
            videoInfoTag.setPlot(data.get('plot', ""))
            videoInfoTag.setPlotOutline(data.get('tagline', ""))
            videoInfoTag.setYear(int(data.get('year', 0)))
            videoInfoTag.setRating(float(data.get('rating', 0.0)))
            videoInfoTag.setMpaa(data.get('mpaa', ""))
            videoInfoTag.setDuration(int(data.get('duration', 0)))
            videoInfoTag.setPlaycount(int(data.get('playcount', 0)))
            videoInfoTag.setCountries(data.get('country', [""]))
            videoInfoTag.setTrailer(data.get('trailer', ""))
            videoInfoTag.setTagLine(data.get('tagline', ""))
            videoInfoTag.setStudios(list(data.get('studio', '').split("/")))
            videoInfoTag.setWriters(list(data.get('writer', '').split("/")))
            videoInfoTag.setDirectors(list(
                data.get('director', '').split("/")))
            videoInfoTag.setGenres(''.join(data.get('genre', [""])).split('/'))
            videoInfoTag.setSeason(int(data.get('season', 0)))
            videoInfoTag.setEpisode(int(data.get('episode', 0)))
            videoInfoTag.setResumePoint(float(data.get('resumetime', 0.0)),
                                        float(data.get('totaltime', 0.0)))

            videoInfoTag.setCast(data.get('cast', []))

        oListItem.setArt({
            'poster': oGuiElement.getPoster(),
            'thumb': oGuiElement.getThumbnail(),
            'icon': oGuiElement.getIcon(),
            'fanart': oGuiElement.getFanart()
        })

        aProperties = oGuiElement.getItemProperties()
        for sPropertyKey, sPropertyValue in aProperties.items():
            oListItem.setProperty(sPropertyKey, str(sPropertyValue))

        return oListItem