| import re |
| import os |
| import sys |
|
|
| from api_client import fetch_users, get_endpoint, get_phpsessid |
|
|
| ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) |
|
|
| inp = input("Enter User IDs: ") |
| user_ids = re.findall(r"\d+", inp) |
|
|
| user_ids = [int(uid) for uid in user_ids] |
|
|
| if len(user_ids) == 0: |
| sys.exit() |
|
|
| def main() -> int: |
| phpsessid = get_phpsessid() |
| endpoint = get_endpoint() |
| try: |
| data = fetch_users(user_ids, phpsessid, endpoint) |
| except Exception as exc: |
| print(f"Error: {exc}") |
| return 1 |
| for user_data in data: |
| if "error" in user_data: |
| print(f"User ID {user_data.get('user_id')} Error: {user_data.get('error')}") |
| continue |
| filename = user_data["filename"] |
| post_ids = user_data["post_ids"] |
| with open(os.path.join(ROOT_DIR, filename + ".txt"), "w", encoding="utf-8") as f: |
| f.write("\n".join(map(str, post_ids))) |
| return 0 |
|
|
| if __name__ == "__main__": |
| raise SystemExit(main()) |
|
|