def __init__(self, xml_file, location, item_information=None, sources=None):
     super(ManualCacheWindow, self).__init__(xml_file, location, item_information=item_information)
     self.sources = SourceSorter(item_information['info']['mediatype'], uncached=True).sort_sources(sources)
     self.canceled = False
     self.display_list = None
     self.cached_source = None
     self.cache_assist_helper = CacheAssistHelper()
     g.close_busy_dialog()
 def __init__(self,
              xml_file,
              location,
              item_information=None,
              sources=None,
              close_text=None):
     super(ManualCacheWindow,
           self).__init__(xml_file,
                          location,
                          item_information=item_information,
                          sources=sources)
     self.sources = SourceSorter(self.item_information).sort_sources(
         self.sources)
     self.cache_assist_helper = CacheAssistHelper()
     self.cached_source = None
     if not close_text:
         close_text = g.get_language_string(30459)
     self.setProperty("close.text", close_text)
    def sort_sources(self, item_information, sources_list):
        """
        Method to handle source filtering, sorting and notifications
        :param item_information: The item information
        :type item_information: dict
        :param sources_list: the list of sources to be sorted
        :type sources_list list
        :return: Filtered and Sorted sources
        :rtype: list
        """
        sources = SourceSorter(item_information).sort_sources(sources_list)
        if sources is None or len(sources) < 1:
            g.cancel_playback()
            g.notification(g.ADDON_NAME,
                           g.get_language_string(30032),
                           time=5000)
            return

        return sources
    def _finalise_results(self):
        monkey_requests.allow_provider_requests = False
        self._send_provider_stop_event()

        uncached = [i for i in self.sources_information["allTorrents"].values()
                    if i['hash'] not in self.sources_information['cached_hashes']]

        if not self._is_playable_source():
            self._build_cache_assist()
            g.cancel_playback()
            if self.silent:
                g.notification(g.ADDON_NAME, g.get_language_string(30055))
            return uncached, [], self.item_information

        sorted_sources = SourceSorter(self.media_type).sort_sources(
            list(self.sources_information["torrentCacheSources"].values()),
            list(self.sources_information['hosterSources'].values()),
            self.sources_information['cloudFiles'])
        sorted_sources = self.sources_information['adaptiveSources'] + sorted_sources
        return uncached, sorted_sources, self.item_information