예제 #1
0
    def update_item(self):
        self.setText(0, self.download_info["name"])

        if self.download_info["size"] == 0 and self.get_raw_download_status() == DLSTATUS_METADATA:
            self.setText(1, "unknown")
        else:
            self.setText(1, format_size(float(self.download_info["size"])))

        try:
            self.progress_slider.setValue(int(self.download_info["progress"] * 100))
        except RuntimeError:
            self._logger.error("The underlying GUI widget has already been removed.")

        if self.download_info["vod_mode"]:
            self.setText(3, "Streaming")
        else:
            self.setText(3, DLSTATUS_STRINGS[dlstatus_strings.index(self.download_info["status"])])
        self.setText(4, "%s (%s)" % (self.download_info["num_connected_seeds"], self.download_info["num_seeds"]))
        self.setText(5, "%s (%s)" % (self.download_info["num_connected_peers"], self.download_info["num_peers"]))
        self.setText(6, format_speed(self.download_info["speed_down"]))
        self.setText(7, format_speed(self.download_info["speed_up"]))
        self.setText(8, "%.3f" % float(self.download_info["ratio"]))
        self.setText(9, "yes" if self.download_info["anon_download"] else "no")
        self.setText(10, str(self.download_info["hops"]) if self.download_info["anon_download"] else "-")
        self.setText(12, datetime.fromtimestamp(int(self.download_info["time_added"])).strftime('%Y-%m-%d %H:%M'))

        eta_text = "-"
        if self.get_raw_download_status() == DLSTATUS_DOWNLOADING:
            eta_text = duration_to_string(self.download_info["eta"])
        self.setText(11, eta_text)
예제 #2
0
    def update_pages(self, new_download=False):
        if self.current_download is None:
            return

        if "files" not in self.current_download:
            self.current_download["files"] = []

        self.window().download_progress_bar.update_with_download(self.current_download)
        self.window().download_detail_name_label.setText(self.current_download['name'])

        if self.current_download["vod_mode"]:
            self.window().download_detail_status_label.setText('Streaming')
        else:
            status_string = DLSTATUS_STRINGS[dlstatus_strings.index(self.current_download["status"])]
            if dlstatus_strings.index(self.current_download["status"]) == DLSTATUS_STOPPED_ON_ERROR:
                status_string += f" (error: {self.current_download['error']})"
            self.window().download_detail_status_label.setText(status_string)

        self.window().download_detail_filesize_label.setText(
            tr("%(num_bytes)s in %(num_files)d files")
            % {
                'num_bytes': format_size(float(self.current_download["size"])),
                'num_files': len(self.current_download["files"]),
            }
        )
        self.window().download_detail_health_label.setText(
            tr("%d seeders, %d leechers") % (self.current_download["num_seeds"], self.current_download["num_peers"])
        )
        self.window().download_detail_infohash_label.setText(self.current_download['infohash'])
        self.window().download_detail_destination_label.setText(self.current_download["destination"])
        self.window().download_detail_ratio_label.setText(
            "%.3f, up: %s, down: %s"
            % (
                self.current_download["ratio"],
                format_size(self.current_download["total_up"]),
                format_size(self.current_download["total_down"]),
            )
        )
        self.window().download_detail_availability_label.setText(f"{self.current_download['availability']:.2f}")

        if force_update := (new_download or self.window().download_files_list.is_empty):
            # (re)populate the files list
            self.window().download_files_list.clear()
            files = convert_to_files_tree_format(self.current_download)
            self.window().download_files_list.fill_entries(files)
예제 #3
0
 def get_raw_download_status(self):
     return dlstatus_strings.index(self.download_info["status"])
예제 #4
0
    def update_pages(self, new_download=False):
        if self.current_download is None:
            return

        if "files" not in self.current_download:
            self.current_download["files"] = []

        self.window().download_progress_bar.update_with_download(
            self.current_download)
        self.window().download_detail_name_label.setText(
            self.current_download['name'])

        if self.current_download["vod_mode"]:
            self.window().download_detail_status_label.setText('Streaming')
        else:
            status_string = DLSTATUS_STRINGS[dlstatus_strings.index(
                self.current_download["status"])]
            if dlstatus_strings.index(self.current_download["status"]
                                      ) == DLSTATUS_STOPPED_ON_ERROR:
                status_string += f" (error: {self.current_download['error']})"
            self.window().download_detail_status_label.setText(status_string)

        self.window().download_detail_filesize_label.setText(
            tr("%(num_bytes)s in %(num_files)d files") % {
                'num_bytes': format_size(float(self.current_download["size"])),
                'num_files': len(self.current_download["files"]),
            })
        self.window().download_detail_health_label.setText(
            tr("%d seeders, %d leechers") %
            (self.current_download["num_seeds"],
             self.current_download["num_peers"]))
        self.window().download_detail_infohash_label.setText(
            self.current_download['infohash'])
        self.window().download_detail_destination_label.setText(
            self.current_download["destination"])
        self.window().download_detail_ratio_label.setText(
            "%.3f, up: %s, down: %s" % (
                self.current_download["ratio"],
                format_size(self.current_download["total_up"]),
                format_size(self.current_download["total_down"]),
            ))
        self.window().download_detail_availability_label.setText(
            f"{self.current_download['availability']:.2f}")

        if new_download or len(self.current_download["files"]) != len(
                self.files_widgets.keys()):

            # (re)populate the files list
            self.window().download_files_list.clear()
            self.files_widgets = {}
            for dfile in self.current_download["files"]:
                item = DownloadFileWidgetItem(
                    self.window().download_files_list, dfile)
                DownloadsDetailsTabWidget.update_file_row(item, dfile)
                self.files_widgets[dfile["name"]] = item

        else:  # No new download, just update data in the lists
            for dfile in self.current_download["files"]:
                DownloadsDetailsTabWidget.update_file_row(
                    self.files_widgets[dfile["name"]], dfile)

        # Populate the trackers list
        self.window().download_trackers_list.clear()
        for tracker in self.current_download["trackers"]:
            item = QTreeWidgetItem(self.window().download_trackers_list)
            DownloadsDetailsTabWidget.update_tracker_row(item, tracker)

        # Populate the peers list if the peer information is available
        self.window().download_peers_list.clear()
        if "peers" in self.current_download:
            for peer in self.current_download["peers"]:
                item = QTreeWidgetItem(self.window().download_peers_list)
                DownloadsDetailsTabWidget.update_peer_row(item, peer)