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)
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):