Beispiel #1
0
    def get_hosts(self):
        """ Returns a list with the avaliable downloaders for the file. """

        result = []
        avaliable_downloaders = Downloaders.get_avaliable()

        hosts = self.file_object.file_hosts
        hosts["dummy"] = ""

        for host in hosts:
            if host in avaliable_downloaders:
                result.append(Downloaders.get(host, self.gui_manager, hosts[host]))

        return result
    def __init__(self):
        self.id = self.generate_id()
        self.name = 'plb-' + str(self.id) + '.mp4'

        self.vid_num = random.randint(2, 5)
        self.gif_num = random.randint(3, 9)
        self.pic_num = random.randint(3, 9)
        self.sfx_num = random.randint(3, 9)

        logger.info('Vid num: ' + str(self.vid_num))
        logger.info('Gif num: ' + str(self.gif_num))
        logger.info('Pic num: ' + str(self.pic_num))
        logger.info('Sfx num: ' + str(self.sfx_num))

        self.result_path = config.RESULT_PATH + self.name
        self.tags = None

        self.vid_downloader = Downloaders.VidDownloader(self.id, self.vid_num)
        self.gif_downloader = Downloaders.GifDownloader(self.id, self.gif_num)
        self.pic_downloader = Downloaders.PicDownloader(self.id, self.pic_num)
        self.sfx_downloader = Downloaders.SfxDownloader(self.id, self.sfx_num)

        self.content_uploader = ContentUploader(self.name, self.id,
                                                self.result_path)
Beispiel #3
0
    def get_hosts(self):
        """ Returns a dict with the avaliable downloaders for the file. """

        result = {}
        avaliable_downloaders = Downloaders.get_avaliable()

        hosts = self.file_object.file_hosts

        hosts["dummy"] = ""

        for host in hosts:
            host = host.lower()
            if host in avaliable_downloaders:
                result[host] = hosts[host]

        return result
Beispiel #4
0
    def get_hosts(self):
        """ Returns a dict with the avaliable downloaders for the file. """

        result = {}
        avaliable_downloaders = Downloaders.get_avaliable()

        hosts = self.file_object.file_hosts

        hosts["dummy"] = ""

        for host in hosts:
            host = host.lower()
            if host in avaliable_downloaders:
                result[host] = hosts[host]

        return result
Beispiel #5
0
class Player(object):
    """
    Class that takes care of the downloading and correctly
    playing the file.
    """
    def __init__(self,
                 gui_manager,
                 file_object,
                 file_path=None,
                 download_only=False,
                 choose_host=False):
        self.gui_manager = gui_manager
        self.config = Config.get()

        self.file_object = file_object
        self.download_only = download_only
        self.choose_host = choose_host

        self.selected_quality = None

        self._speed_list = []
        self._last_downloaded_size = 0
        self.speed = 0

        self.file_path = file_path
        if not self.file_path:
            self.file_path = self.config.get_key("cache_dir")

        self.file_path = os.path.join(self.file_path, self.get_filename())

        # Builder for the hosts selection
        self.hosts_builder = gtk.Builder()
        self.hosts_builder.add_from_file(HOSTS_GUI_FILE)
        self.hosts_builder.connect_signals(self)

        glade_objects = [
            "hosts_window", "hosts_icon_view", "hosts_icon_view_model"
        ]

        for glade_object in glade_objects:
            setattr(self, glade_object,
                    self.hosts_builder.get_object(glade_object))

        self.gui_manager.background_task(
            self.get_hosts,
            self.display_hosts,
            status_message=gettext("Fetching hosts..."),
            unfreeze=False)

    def get_hosts(self):
        """ Returns a dict with the avaliable downloaders for the file. """

        result = {}
        avaliable_downloaders = Downloaders.get_avaliable()

        hosts = self.file_object.file_hosts

        hosts["dummy"] = ""

        for host in hosts:
            host = host.lower()
            if host in avaliable_downloaders:
                result[host] = hosts[host]

        return result

    def display_hosts(self, (is_error, result)):
        """ Shows up the hosts selecting window. """

        gobject.idle_add(self.gui_manager.set_status_message, "")

        if is_error:
            self.gui_manager.report_error(gettext("Error fetching hosts: %s") % \
                                          result)
            gobject.idle_add(self.gui_manager.progress_box.hide)
            return

        if not result:
            self.gui_manager.report_error(gettext("No host found"))
            self.gui_manager.unfreeze()
            return

        automatic_start = self.config.get_key("automatic_start")

        if automatic_start and len(result) == 1 and not self.choose_host:
            host, qualities = result.items()[0]

            if len(qualities) == 1:
                gobject.idle_add(
                    self.gui_manager.set_status_message,
                    gettext("Only one host found, starting download..."))

                url = qualities.items()[0][1]
                self.downloader = Downloaders.get(host, self.gui_manager, url)
                self.downloader.process_url(self.play, self.file_path)
                return

        for host in result:
            for quality in result[host]:
                downloader = Downloaders.get(host, self.gui_manager,
                                             result[host][quality])
                icon = downloader.icon
                name = "%s (%s)" % (downloader.name, quality)

                self.hosts_icon_view_model.append([icon, name, downloader])

        self.hosts_window.show_all()