From c36276aee5fe4b2b827b7b915e6c57903991c6d5 Mon Sep 17 00:00:00 2001 From: Piotr Dec Date: Wed, 30 Apr 2025 12:40:00 +0200 Subject: [PATCH] Channel export --- exporter_ng.py | 16 +++++++++++----- tui.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/exporter_ng.py b/exporter_ng.py index 955eb44..4d96221 100644 --- a/exporter_ng.py +++ b/exporter_ng.py @@ -368,17 +368,23 @@ class SlackExporter: f.write(data) def export_channels(self, channels: List[str]): - with open(os.path.join(self.output_dir, "channels.txt"), "w", encoding="utf-8") as f: - for channel in channels: - f.write(str(channel) + "\n") - pass + channels_map = {ch.id: ch for ch in self.channels} + self.export_channel_list(True) + self.export_user_list(True) + for channel_id in channels: + print(f"Eksport {channels_map.get(channel_id).label}...") + self.export_channel_history(channel_id) + self.export_channel_history(channel_id, as_json=True) + self.export_channel_replies(channel_id) + self.export_channel_replies(channel_id, as_json=True) + self.export_channel_files(channel_id) def export_channel_list(self, as_json: bool = False): """Eksportuje listę kanałów""" if as_json: data = [vars(ch) for ch in self.channels] else: - data = "\n".join(ch.format(self.users) for ch in self.channels) + data = "\n".join(ch.label for ch in self.channels) self._save_data(data, "channel_list", as_json) def export_user_list(self, as_json: bool = False): diff --git a/tui.py b/tui.py index f91f343..d146443 100644 --- a/tui.py +++ b/tui.py @@ -107,7 +107,7 @@ def run_tui(exporter: SlackExporter): app = SlackTUI(exporter) app.run() if app.get_return_code() == 8080: - exporter.export_channels(app.get_selection()) + exporter.export_channels(list(app.get_selection())) if __name__ == "__main__": try: