Esempio n. 1
0
    def update_status (self, item_iter, **kwargs):
        self.lock.acquire ()
        if not item_iter in self.tree_items:
            self.lock.release ()
            return

        # Only update at certain intervals due to Windows GTK
        # runtime crashing when updating after each new message
        force_update = kwargs.get ("force_update", False)
        time_since_update = (
            time.time () - self.tree_items[item_iter]["last_update"]
        )
        #self._log.debug ("Time since update: {0}".format (time_since_update))
        update_time = time_since_update > self.UPDATE_INTERVAL
        # Return if it is not time to update item status
        if not update_time and not force_update:
            self.lock.release ()
            return

        thread = self.tree_items[item_iter]["thread"]
        gtk.gdk.threads_enter ()
        for column, key in self.COLUMN_NAMES.items ():
            if key in kwargs:
                self.tree_model.set (item_iter, column, kwargs[key])

        # Update download speed total message in statusbar
        if (thread.status == VideoDownloadThread.READY):
        # and time_since_speed_update > self.__class__.UPDATE_INTERVAL:
            total_speed = thread.download_speed
            # Loop through items and update total speed for all
            # other threads
            for iter_for_item, item in self.tree_items.iteritems ():
                if item_iter is not iter_for_item:
                    total_speed += item["last_updated_speed"]

            self.emit ("progress_update", "Active: {0} of {1}".format (
                self._running_items, self._num_objects))
            self.emit ("speed_progress_update", "DL Speed: {0}/s".format (
                    FileDownloader.humanizeSize (total_speed)))

        item = self.tree_items[item_iter]
        item["last_update"] = time.time ()
        item["last_updated_speed"] = thread.download_speed
        gtk.gdk.threads_leave ()
        self.lock.release ()
Esempio n. 2
0
    def update_status(self, item_iter, **kwargs):
        self.lock.acquire()
        if not item_iter in self.tree_items:
            self.lock.release()
            return

        # Only update at certain intervals due to Windows GTK
        # runtime crashing when updating after each new message
        force_update = kwargs.get("force_update", False)
        time_since_update = time.time() - self.tree_items[item_iter]["last_update"]
        # self._log.debug ("Time since update: {0}".format (time_since_update))
        update_time = time_since_update > self.UPDATE_INTERVAL
        # Return if it is not time to update item status
        if not update_time and not force_update:
            self.lock.release()
            return

        thread = self.tree_items[item_iter]["thread"]
        gtk.gdk.threads_enter()
        for column, key in self.COLUMN_NAMES.items():
            if key in kwargs:
                self.tree_model.set(item_iter, column, kwargs[key])

        # Update download speed total message in statusbar
        if thread.status == VideoDownloadThread.READY:
            # and time_since_speed_update > self.__class__.UPDATE_INTERVAL:
            total_speed = thread.download_speed
            # Loop through items and update total speed for all
            # other threads
            for iter_for_item, item in self.tree_items.iteritems():
                if item_iter is not iter_for_item:
                    total_speed += item["last_updated_speed"]

            self.emit("progress_update", "Active: {0} of {1}".format(self._running_items, self._num_objects))
            self.emit("speed_progress_update", "DL Speed: {0}/s".format(FileDownloader.humanizeSize(total_speed)))

        item = self.tree_items[item_iter]
        item["last_update"] = time.time()
        item["last_updated_speed"] = thread.download_speed
        gtk.gdk.threads_leave()
        self.lock.release()
Esempio n. 3
0
        youtube_video.setFilePaths(videos_dir)

    output_filename = youtube_video.getOutputFileName()

    wget_file = ffmpeg_file = ""
    if WINDOWS:
        wget_file = os.path.join("bin", "wget.exe")
        ffmpeg_file = os.path.join("bin", "ffmpeg.exe")
    else:
        wget_file = os.path.join(sys.prefix, "bin", "wget")
        ffmpeg_file = os.path.join(sys.prefix, "bin", "ffmpeg")

    if not os.path.exists(youtube_video.flv_file):
        print 'Downloading "%s"' % os.path.basename(youtube_video.flv_file)
        print
        n00b = FileDownloader(youtube_video.real_url, youtube_video.flv_file)
        n00b.open()
        start_update = time.time()
        speeda = 0
        last_message_length = 0
        data = n00b.readBlock()

        while data != "":
            speeda = n00b.getBytesDownloaded() / float(
                (time.time() - start_update))
            speed = "%s/s" % n00b.humanizeSize(speeda)

            progress = n00b.downloadPercentage()
            if progress >= 0:
                progress_message = "%3s%%" % progress
            else:
Esempio n. 4
0
        youtube_video.setFilePaths (videos_dir)

    output_filename = youtube_video.getOutputFileName ()

    wget_file = ffmpeg_file = ""
    if WINDOWS:
        wget_file = os.path.join ("bin", "wget.exe")
        ffmpeg_file = os.path.join ("bin", "ffmpeg.exe")
    else:
        wget_file = os.path.join (sys.prefix, "bin", "wget")
        ffmpeg_file = os.path.join (sys.prefix, "bin", "ffmpeg")

    if not os.path.exists (youtube_video.flv_file):
        print 'Downloading "%s"' % os.path.basename (youtube_video.flv_file)
        print
        n00b = FileDownloader (youtube_video.real_url, youtube_video.flv_file)
        n00b.open ()
        start_update = time.time ()
        speeda = 0
        last_message_length = 0
        data = n00b.readBlock ()

        while data != "":
            speeda = n00b.getBytesDownloaded () / float ((time.time () - start_update))
            speed = "%s/s" % n00b.humanizeSize (speeda)

            progress = n00b.downloadPercentage ()
            if progress >= 0:
                progress_message = "%3s%%" % progress
            else:
                progress_message = "???%%"