Esempio n. 1
0
    def __init__(self, file_service_key, media_results):

        self._file_service_key = file_service_key

        self._sort_by = CC.SORT_BY_SMALLEST
        self._collect_by = None

        self._collect_map_singletons = {}
        self._collect_map_collected = {}

        self._sorted_media = HC.SortedList([
            self._GenerateMediaSingleton(media_result)
            for media_result in media_results
        ])

        self._singleton_media = set(self._sorted_media)
        self._collected_media = set()
Esempio n. 2
0
    def Collect(self, collect_by=-1):

        if collect_by == -1: collect_by = self._collect_by

        self._collect_by = collect_by

        for media in self._collected_media:
            self._singleton_media.update([
                self._GenerateMediaSingleton(media_result)
                for media_result in media.GenerateMediaResults()
            ])

        self._collected_media = set()

        self._collect_map_singletons = {}
        self._collect_map_collected = {}

        if collect_by is not None:

            keys_to_medias = self._CalculateCollectionKeysToMedias(
                collect_by, self._singleton_media)

            self._collect_map_singletons = {
                key: medias[0]
                for (key, medias) in keys_to_medias.items() if len(medias) == 1
            }
            self._collect_map_collected = {
                key: self._GenerateMediaCollection(
                    [media.GetMediaResult() for media in medias])
                for (key, medias) in keys_to_medias.items() if len(medias) > 1
            }

            self._singleton_media = set(self._collect_map_singletons.values())
            self._collected_media = set(self._collect_map_collected.values())

        self._sorted_media = HC.SortedList(
            list(self._singleton_media) + list(self._collected_media))