Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Download optimizations & verbose logging #20

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
}
23 changes: 17 additions & 6 deletions 0_download_dialogs_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def init_args():

:return: argparse.Namespace
"""
parser = argparse.ArgumentParser(
description="Download dialogs list for user."
)
parser = argparse.ArgumentParser(description="Download dialogs list for user.")

parser.add_argument(
"--dialogs_limit", type=int, help="number of dialogs", required=True
Expand Down Expand Up @@ -46,7 +44,7 @@ async def save_dialogs(client, dialogs_limit):
dialog_name = dialog.name
dialog_members = []

print(f"dialog #{dialog_id}")
skip = False

dialog_type = ""
if dialog.is_user:
Expand All @@ -55,6 +53,12 @@ async def save_dialogs(client, dialogs_limit):
dialog_type = "Group"
elif dialog.is_channel:
dialog_type = "Channel"
skip = True

prefix = "SKIP " if skip else ""
print(f"{prefix}dialog #{dialog_id}, name: {dialog_name}, type: {dialog_type}")
if skip:
continue

try:
users = await client.get_participants(dialog)
Expand All @@ -73,7 +77,9 @@ async def save_dialogs(client, dialogs_limit):
except BaseException as error:
print("ERROR\n", error)

save_dialog(dialog_id, dialog_name, dialog_members, dialog_type, DIALOGS_LIST_FOLDER)
save_dialog(
dialog_id, dialog_name, dialog_members, dialog_type, DIALOGS_LIST_FOLDER
)


if __name__ == "__main__":
Expand All @@ -85,7 +91,12 @@ async def save_dialogs(client, dialogs_limit):
SESSION_NAME = args.session_name

config = init_config(CONFIG_PATH)
client = TelegramClient(SESSION_NAME, config["api_id"], config["api_hash"], system_version="4.16.30-vxCUSTOM")
client = TelegramClient(
SESSION_NAME,
config["api_id"],
config["api_hash"],
system_version="4.16.30-vxCUSTOM",
)

DIALOGS_LIST_FOLDER = config["dialogs_list_folder"]

Expand Down
Loading