Channel export
This commit is contained in:
parent
906566825f
commit
c36276aee5
2 changed files with 12 additions and 6 deletions
|
@ -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
2
tui.py
|
@ -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:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue