Channel export

This commit is contained in:
Piotr Dec 2025-04-30 12:40:00 +02:00
parent 906566825f
commit c36276aee5
No known key found for this signature in database
GPG key ID: D3B5A5D0150D147A
2 changed files with 12 additions and 6 deletions

View file

@ -368,17 +368,23 @@ class SlackExporter:
f.write(data) f.write(data)
def export_channels(self, channels: List[str]): def export_channels(self, channels: List[str]):
with open(os.path.join(self.output_dir, "channels.txt"), "w", encoding="utf-8") as f: channels_map = {ch.id: ch for ch in self.channels}
for channel in channels: self.export_channel_list(True)
f.write(str(channel) + "\n") self.export_user_list(True)
pass 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): def export_channel_list(self, as_json: bool = False):
"""Eksportuje listę kanałów""" """Eksportuje listę kanałów"""
if as_json: if as_json:
data = [vars(ch) for ch in self.channels] data = [vars(ch) for ch in self.channels]
else: 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) self._save_data(data, "channel_list", as_json)
def export_user_list(self, as_json: bool = False): def export_user_list(self, as_json: bool = False):

2
tui.py
View file

@ -107,7 +107,7 @@ def run_tui(exporter: SlackExporter):
app = SlackTUI(exporter) app = SlackTUI(exporter)
app.run() app.run()
if app.get_return_code() == 8080: if app.get_return_code() == 8080:
exporter.export_channels(app.get_selection()) exporter.export_channels(list(app.get_selection()))
if __name__ == "__main__": if __name__ == "__main__":
try: try: