Beispiel #1
0
class localMediaMovie(Agent.Movies):
    name = 'Local Media Assets (Movies)'
    languages = [Locale.Language.NoLanguage]
    primary_provider = False
    persist_stored_files = False
    contributes_to = ['com.plexapp.agents.imdb', 'com.plexapp.agents.none']

    def search(self, results, media, lang):
        results.Append(MetadataSearchResult(id='null', score=100))

    def update(self, metadata, media, lang):

        # Clear out the title to ensure stale data doesn't clobber other agents' contributions.
        metadata.title = None

        part = media.items[0].parts[0]
        path = os.path.dirname(part.file)

        # Look for local media.
        try:
            localmedia.findAssets(metadata, media.title, [path], 'movie',
                                  media.items[0].parts)
        except Exception, e:
            Log('Error finding media for movie %s: %s' % (media.title, str(e)))

        # Look for subtitles
        for item in media.items:
            for part in item.parts:
                localmedia.findSubtitles(part)

        # If there is an appropriate VideoHelper, use it.
        video_helper = videohelpers.VideoHelpers(part.file)
        if video_helper:
            video_helper.process_metadata(metadata)
Beispiel #2
0
    def update(self, metadata, media, lang):
        # Set title if needed.
        if media and metadata.title is None: metadata.title = media.title

        part = media.items[0].parts[0]
        path = os.path.dirname(part.file)

        # Look for local media.
        try:
            localmedia.findAssests(metadata, [path], 'movie', part)
        except:
            Log('Error finding media for movie %s', media.title)

        # Look for subtitles
        for item in media.items:
            for part in item.parts:
                localmedia.findSubtitles(part)

        # If there is an appropriate VideoHelper, use it.
        video_helper = videohelpers.VideoHelpers(part.file)
        if video_helper:
            video_helper.process_metadata(metadata)
Beispiel #3
0
class localMediaTV(Agent.TV_Shows):
    name = 'Local Media Assets (TV)'
    languages = [Locale.Language.NoLanguage]
    primary_provider = False
    persist_stored_files = False
    contributes_to = ['com.plexapp.agents.thetvdb', 'com.plexapp.agents.none']

    def search(self, results, media, lang):
        results.Append(MetadataSearchResult(id='null', score=100))

    def update(self, metadata, media, lang):

        # Clear out the title to ensure stale data doesn't clobber other agents' contributions.
        metadata.title = None

        # Look for media, collect directories.
        dirs = {}
        for s in media.seasons:
            Log('Creating season %s', s)
            metadata.seasons[s].index = int(s)
            for e in media.seasons[s].episodes:

                # Make sure metadata exists, and find sidecar media.
                episodeMetadata = metadata.seasons[s].episodes[e]
                episodeMedia = media.seasons[s].episodes[e].items[0]
                dir = os.path.dirname(episodeMedia.parts[0].file)
                dirs[dir] = True

                try:
                    localmedia.findAssets(episodeMetadata, media.title, [dir],
                                          'episode', episodeMedia.parts)
                except Exception, e:
                    Log('Error finding media for episode: %s' % str(e))

        # Figure out the directories we should be looking in.
        try:
            dirs = FindUniqueSubdirs(dirs)
        except:
            dirs = []

        # Look for show images.
        Log("Looking for show media for %s.", metadata.title)
        try:
            localmedia.findAssets(metadata, media.title, dirs, 'show')
        except:
            Log("Error finding show media.")

        # Look for season images.
        for s in metadata.seasons:
            Log('Looking for season media for %s season %s.', metadata.title,
                s)
            try:
                localmedia.findAssets(metadata.seasons[s], media.title, dirs,
                                      'season')
            except:
                Log("Error finding season media for season %s" % s)

        # Look for subtitles for each episode.
        for s in media.seasons:
            # If we've got a date based season, ignore it for now, otherwise it'll collide with S/E folders/XML and PMS
            # prefers date-based (why?)
            if int(s) < 1900 or metadata.guid.startswith(
                    PERSONAL_MEDIA_IDENTIFIER):
                for e in media.seasons[s].episodes:
                    for i in media.seasons[s].episodes[e].items:

                        # Look for subtitles.
                        for part in i.parts:
                            localmedia.findSubtitles(part)

                            # If there is an appropriate VideoHelper, use it.
                            video_helper = videohelpers.VideoHelpers(part.file)
                            if video_helper:
                                video_helper.process_metadata(
                                    metadata,
                                    episode=metadata.seasons[s].episodes[e])
            else:
                # Whack it in case we wrote it.
                #del metadata.seasons[s]
                pass
Beispiel #4
0
    def update(self, metadata, media, lang):
        # Set title if needed.
        if media and metadata.title is None: metadata.title = media.title

        # Look for media, collect directories.
        dirs = {}
        for s in media.seasons:
            Log('Creating season %s', s)
            metadata.seasons[s].index = int(s)
            for e in media.seasons[s].episodes:

                # Make sure metadata exists, and find sidecar media.
                episodeMetadata = metadata.seasons[s].episodes[e]
                episodeMedia = media.seasons[s].episodes[e].items[0]
                dir = os.path.dirname(episodeMedia.parts[0].file)
                dirs[dir] = True

                try:
                    localmedia.findAssests(episodeMetadata, [dir], 'episode',
                                           episodeMedia.parts[0])
                except:
                    Log("Error finding season media for episode")

        # Figure out the directories we should be looking in.
        try:
            dirs = FindUniqueSubdirs(dirs)
        except:
            dirs = []

        # Look for show images.
        Log("Looking for show media for %s.", metadata.title)
        try:
            localmedia.findAssests(metadata, dirs, 'show')
        except:
            Log("Error finding show media.")

        # Look for season images.
        for s in metadata.seasons:
            Log('Looking for season media for %s season %s.', metadata.title,
                s)
            try:
                localmedia.findAssests(metadata.seasons[s], dirs, 'season')
            except:
                Log("Error finding season media for season %s" % s)

        # Look for subtitles for each episode.
        for s in media.seasons:
            # If we've got a date based season, ignore it for now, otherwise it'll collide with S/E folders/XML and PMS
            # prefers date-based (why?)
            if int(s) < 1900 or metadata.guid.startswith(
                    PERSONAL_MEDIA_IDENTIFIER):
                for e in media.seasons[s].episodes:
                    for i in media.seasons[s].episodes[e].items:

                        # Look for subtitles.
                        for part in i.parts:
                            localmedia.findSubtitles(part)

                            # If there is an appropriate VideoHelper, use it.
                            video_helper = videohelpers.VideoHelpers(part.file)
                            if video_helper:
                                video_helper.process_metadata(
                                    metadata,
                                    episode=metadata.seasons[s].episodes[e])
            else:
                # Whack it in case we wrote it.
                #del metadata.seasons[s]
                pass