Advertisement
Kuroneko-yousenpai

Auths sorter

May 15th, 2021 (edited)
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 27.40 KB | None | 0 0
  1. """
  2.  - Copyright 2021 Ruri Gokou (Kuroneko-yousenpai)
  3.  - Email: Kuronekoyousenpai@gmail.com
  4.  - Telegram: https://t.me/Kuroneko_yousenpai
  5.  - VK: https://vk.com/id466386210
  6. """
  7.  
  8. import os
  9. import re
  10. import socket
  11. import sys
  12. from datetime import date, datetime
  13. from pathlib import Path
  14. import requests
  15. from bs4 import BeautifulSoup
  16. from pip._vendor.distlib.compat import raw_input
  17. from sty import fg, Style, RgbFg
  18.  
  19. date_today : date = date.today()
  20. time_now : datetime = datetime.now()
  21.  
  22. MAX_FILENAME_LENGTH = 259
  23.  
  24. version : str = "1.0.5"
  25.  
  26. input_file_path : str = "./"
  27. input_file_name : str = ""
  28. input_file : str
  29.  
  30. output_file_path : str = './'
  31. output_file_name : str = "log" + "_" + "auths" + "_" + date_today.strftime("%d-%m-%y") + "_" + time_now.strftime("%H%M%S")
  32. output_file : str
  33.  
  34. output_vk_ids_path : str = './'
  35. output_vk_ids_name : str = "log" + "_" + "vk_ids" + "_" + date_today.strftime("%d-%m-%y") + "_" + time_now.strftime("%H%M%S")
  36. output_vk_ids_file : str
  37.  
  38. restrictions_for_path : str = r"^[a-zA-Zа-яА-Я0-9:/\\\\.\- ]*$"
  39. restrictions_for_filename : str = r"^[a-zA-Zа-яА-Я0-9._\- ]*$"
  40.  
  41. ids_seen : set = set()
  42.  
  43. vk_ids : list = []
  44. vk_ids_count : int = 0
  45.  
  46. mail_ids : list = []
  47. mail_ids_count : int = 0
  48.  
  49. okru_ids : list = []
  50. okru_ids_count : int = 0
  51.  
  52. ampfinder : str = r"(?<=&)(amp;)"
  53. ampremover = re.compile(ampfinder)
  54.  
  55. vk_url : str = "https://vk.com/id"
  56.  
  57. vkontakte : str = "vkontakte"
  58. mail_ru : str = "mail_ru"
  59. okru : str = "odnoklassniki"
  60.  
  61. viewer_id_regexp : str = r"(?<=&viewer_id=)(\d*)(?=&)"
  62. user_id_regexp : str = r"(?<=&user_id=)(\d*)(?=&)"
  63. vid_regexp : str = r"(?<=vid=)(\d*)(?=&)"
  64. oid_regexp : str = r"(?<=oid=)(\d*)(?=&)"
  65. okru_id_regexp : str = r"(?<=logged_user_id=)(\d*)(?=&)"
  66.  
  67. sort_buffer : str = ""
  68. secondary_auths : list = []
  69.  
  70. auth_vk_url : str = "https://markus.rmart.ru/engine/preloader/preloader.html"
  71. auth_mail_url : str = "https://markus.rmart.ru/wormix_mm/preloader/preloader.html"
  72. auth_okru_url : str = "https://markus.rmart.ru/wormix_ok/preloader/preloader.html"
  73.  
  74. fg.red = Style(RgbFg(255, 0, 0))
  75. fg.lightgreen = Style(RgbFg(0, 255, 95))
  76. fg.lightblue = Style(RgbFg(217, 199, 255)) #For 256 colors terminal
  77. fg.lightblue2 = Style(RgbFg(135, 135, 255))
  78.  
  79. #Yes/no
  80. def query_yes_no(question, default="yes"):
  81.     """Ask a yes/no question via raw_input() and return their answer.
  82.  
  83.    "question" is a string that is presented to the user.
  84.    "default" is the presumed answer if the user just hits <Enter>.
  85.        It must be "yes" (the default), "no" or None (meaning
  86.        an answer is required of the user).
  87.  
  88.    The "answer" return value is True for "yes" or False for "no".
  89.    """
  90.     valid = {"yes": True, "y": True, "yea": True,
  91.              "no": False, "n": False, "nope": False}
  92.     if default is None:
  93.         prompt = " [y/n] "
  94.     elif default == "yes":
  95.         prompt = " [Y/n] "
  96.     elif default == "no":
  97.         prompt = " [y/N] "
  98.     else:
  99.         raise ValueError("invalid default answer: '%s'" % default)
  100.  
  101.     while True:
  102.         sys.stdout.write(question + prompt)
  103.         choice = raw_input().lower()
  104.         if default is not None and choice == '':
  105.             return valid[default]
  106.         elif choice in valid:
  107.             return valid[choice]
  108.         else:
  109.             sys.stdout.write("Please respond with 'yes' or 'no' ""(or 'y'/'n').\n")
  110.  
  111. #Sort by social identifiers
  112. def SocialIdentifierSorter (uid, social):
  113.     global vkontakte
  114.     global mail_ru
  115.     global okru
  116.     global sort_buffer
  117.     global ids_seen
  118.     global vk_ids
  119.     global mail_ids
  120.     global okru_ids
  121.  
  122.     if uid and social == vkontakte:
  123.         ids_seen.add(uid)
  124.         vk_ids += [uid]
  125.  
  126.         print("VK ID: " + uid)
  127.         sort_buffer = sort_buffer + auth_vk_url + line.rstrip('\n') + " " + "//VK ID: " + uid + ((" " + "|" + " " + "VK: " + GetSocialName(uid)) if (GetSocialName(uid)) else "") + " " + "|" + " " + "Url:" + " " + "https://vk.com/id" + uid + "\n"
  128.     elif uid and social == mail_ru:
  129.         ids_seen.add(uid)
  130.         mail_ids += [uid]
  131.  
  132.         print("MAIL ID: " + uid)
  133.         sort_buffer = sort_buffer + auth_mail_url + line.rstrip('\n') + " " + "//MM ID: " + uid + "\n"
  134.     elif uid and social == okru:
  135.         ids_seen.add(uid)
  136.         okru_ids += [uid]
  137.  
  138.         print("OK.RU ID: " + uid)
  139.         sort_buffer = sort_buffer + auth_okru_url + line.rstrip('\n') + " " + "//OK.RU ID: " + uid + "\n"
  140.  
  141. #Check internet connection
  142. def internet_check(host="8.8.8.8", port=53, timeout=3):
  143.     """
  144.    Host: 8.8.8.8 (google-public-dns-a.google.com)
  145.    OpenPort: 53/tcp
  146.    Service: domain (DNS/TCP)
  147.    """
  148.     try:
  149.         socket.setdefaulttimeout(timeout)
  150.         socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
  151.         return True
  152.     except socket.error as ex:
  153.         print(ex)
  154.         return False
  155.  
  156. #Get social name by id
  157. def GetSocialName (social_id):
  158.  
  159.     if internet_check():
  160.         url = vk_url + social_id
  161.         # Making requests instance
  162.         reqs = requests.get(url)
  163.         # Using the BeaitifulSoup module
  164.         soup = BeautifulSoup(reqs.text, 'html.parser')
  165.         # Get title and return name
  166.         for title in soup.find_all('title'):
  167.             if title:
  168.                 page_title = title.get_text()
  169.                 splitted_title = page_title.split()
  170.                 if len(splitted_title) >= 4:
  171.                     name_from_title = splitted_title[0] + " " + splitted_title[1]
  172.                     return name_from_title
  173.                 else:
  174.                     return False
  175.     else:
  176.         return False
  177.  
  178. #Сортировка ауткеев по группам: ауткеи вк, майла и одноклассников
  179. def SocialSorter(line_x):
  180.     social_folders = {'engine': 1, 'wormix_mm': 2, 'wormix_ok': 3}
  181.     line_fields = line_x.strip().split("/")
  182.     if len(line_fields) >= 3:
  183.         social = line_fields[3]
  184.         return social_folders[social]
  185.     else:
  186.         return -1
  187.  
  188. #Logs types (split by spaces count)
  189. def logs_type_first():
  190.     return 3
  191. def logs_type_second():
  192.     return 2
  193. def logs_type_third():
  194.     return 1
  195. def logs_type_five():
  196.     return int(input("Введите количество отступов до основной части ауткея: "))
  197. def logs_type_zero():
  198.     return 0
  199.  
  200. switch_logs_types = {
  201.     1: logs_type_first,
  202.     2: logs_type_second,
  203.     3: logs_type_third,
  204.     4: logs_type_zero,
  205.     5: logs_type_five
  206.     }
  207.  
  208. def switch_logs_type(logs_type):
  209.     return switch_logs_types.get(logs_type, logs_type_zero)()
  210.  
  211. print(f"{fg.red}Wormix Auths Sorter{fg.rs}" + "\n" + f"{fg.lightgreen}Version: {version}{fg.rs}" + "\n\n" + f"{fg.lightblue2}- Copyright 2021 Ruri Gokou (Kuroneko-yousenpai)" + "\n" + "- Email: Kuronekoyousenpai@gmail.com" + "\n" + "- Telegram: https://t.me/Kuroneko_yousenpai" + "\n" + "- VK: https://vk.com/id466386210" + f"{fg.rs}", end="\n\n")
  212.  
  213. while True:
  214.     try:
  215.         while True:
  216.             try:
  217.                 input_file_name = str(input("Укажите имя входного файла:  "))
  218.                 if not re.match(restrictions_for_filename, input_file_name) or len(input_file_name) >= MAX_FILENAME_LENGTH:
  219.                     raise ("Restricted characters or too long file name!")
  220.                 question_filename = bool(query_yes_no("Всё правильно?"))
  221.                 print()
  222.                 if question_filename == True:
  223.                     input_file: str = input_file_path + input_file_name + '.txt'
  224.                     break
  225.             except:
  226.                 print("Error: Invalid file name", end="\n\n")
  227.  
  228.         print("Файл лога должен находиться в одной папке с программой")
  229.         question_filename_main = bool(query_yes_no("Или желаете указать полный путь до лога?"))
  230.         print()
  231.         if question_filename_main == True:
  232.             while True:
  233.                 try:
  234.                     print("Пример: D:/Documents/Consollite/", end="\n\n")
  235.                     input_file_path = str(input("Укажите полный путь к файлу: "))
  236.                     if input_file_path[-1:] != "/":
  237.                         input_file_path = input_file_path + "/"
  238.                     if not (re.match(restrictions_for_path, input_file_path)):
  239.                         raise ("Restricted characters!")
  240.                     question_path = bool(query_yes_no("Всё правильно?"))
  241.                     print()
  242.                     if question_path == True:
  243.                         if os.path.exists(input_file_path):
  244.                             input_file: str = input_file_path + input_file_name + '.txt'
  245.                             break
  246.                         else:
  247.                             raise FileNotFoundError("Path are not existed!")
  248.                 except FileNotFoundError:
  249.                     print("Error: Path not found", end="\n\n")
  250.                 except ValueError:
  251.                     print("Error: File not found", end="\n\n")
  252.                 except:
  253.                     print("Error: Invalid path", end="\n\n")
  254.         if os.path.isfile(input_file):
  255.             break
  256.         else:
  257.             raise ValueError("File is not exist")
  258.     except ValueError:
  259.         print("Error: File not found", end="\n\n")
  260.     except:
  261.         print("Error: Something went wrong", end="\n\n")
  262.  
  263. output_file = output_file_path + output_file_name + '.txt'
  264.  
  265. print("Выходной файл сохраняется в той же директории, в которой находится программа")
  266. question_output_path_main = bool(query_yes_no("Желаете указать полный путь к выходному файлу?"))
  267. print()
  268. if question_output_path_main == True:
  269.     while True:
  270.         try:
  271.             print("Пример: D:/Documents/Consollite/", end="\n\n")
  272.             output_file_path = str(input("Укажите полный путь к файлу: "))
  273.             if output_file_path[-1:] != "/":
  274.                 output_file_path = output_file_path + "/"
  275.             if not (re.match(restrictions_for_path, output_file_path)):
  276.                 raise ("Restricted characters!")
  277.             question_output_path = bool(query_yes_no("Всё правильно?"))
  278.             print()
  279.             if question_output_path == True:
  280.                 if os.path.exists(output_file_path):
  281.                     break
  282.                 else:
  283.                     print("Такой директории не существует!")
  284.                     question_dirnotexist = bool(query_yes_no("Хотите создать?"))
  285.                     print()
  286.                     if question_dirnotexist == True:
  287.                        try:
  288.                             Path(output_file_path).mkdir(parents=True, exist_ok=True)
  289.                             break
  290.                        except:
  291.                            raise ("Maybe program lack access...")
  292.                     else:
  293.                         raise ValueError("Path are not existed!")
  294.         except ValueError:
  295.             print("Error: Path not found", end="\n\n")
  296.         except:
  297.             print("Error: Invalid path", end="\n\n")
  298.  
  299. question_output_filename_main = bool(query_yes_no("Желаете указать имя выходного файла?"))
  300. print()
  301. if question_output_filename_main == True:
  302.     while True:
  303.             try:
  304.                 output_file_name = str(input("Укажите желаемое имя выходного файла:  "))
  305.                 print()
  306.                 if not re.match(restrictions_for_filename, output_file_name) or len(output_file_name) >= MAX_FILENAME_LENGTH:
  307.                     raise ValueError("Restricted characters or file name is too long!")
  308.                 output_file = output_file_path + output_file_name + '.txt'
  309.                 question_output_filename = bool(query_yes_no("Всё правильно?"))
  310.                 print()
  311.                 if question_output_filename == True:
  312.                     break
  313.             except ValueError:
  314.                 print("Error: Invalid file name", end="\n\n")
  315.             except:
  316.                 print("Error: Something went wrong", end="\n\n")
  317.  
  318. question_urls = bool(query_yes_no("Хотите изменить ссылки для подставления?"))
  319. if question_urls == True:
  320.     while True:
  321.                 question_vk_url = bool(query_yes_no("Изменить ссылку для ауткеев из вк?"))
  322.                 print()
  323.                 if question_vk_url == True:
  324.                     auth_vk_url = str(input("Укажите ссылку для ауткеев из вк: "))
  325.                     print()
  326.                 question_mail_url = bool(query_yes_no("Изменить ссылку для ауткеев из майла?"))
  327.                 print()
  328.                 if question_mail_url == True:
  329.                     auth_mail_url = str(input("Укажите ссылку для ауткеев из майла: "))
  330.                     print()
  331.                 question_okru_url = bool(query_yes_no("Изменить ссылку для ауткеев из одноклассников?"))
  332.                 print()
  333.                 if question_okru_url == True:
  334.                     auth_okru_url = str(input("Укажите ссылку для ауткеев из одноклассников: "))
  335.                     print()
  336.                 question_urls_confirmation = bool(query_yes_no("Всё правильно?"))
  337.                 print()
  338.                 if question_urls_confirmation == True:
  339.                     break
  340.  
  341. while True:
  342.         try:
  343.             print()
  344.             split_num_choice = int(input("Выберите формат логов: " + "\n" + "1 — [date] [time] [ip] auth" + "\n" + "2 — [date] [ip] auth" + "\n" + "3 — [ip] auth" + "\n" + "4 — auth" + "\n" + "5 — Свой вариант" + "\n\n" + "Если не знаете — ставьте 4" "\n\n" + "Enter number of choice: "))
  345.             split_num = switch_logs_type(split_num_choice)
  346.             question_splitnum = bool(query_yes_no("Всё правильно?"))
  347.             print()
  348.             if question_splitnum == True:
  349.                 break
  350.         except:
  351.             print("Error: Unknown logs format")
  352.  
  353. #Sorting Hell
  354.  
  355. # При проверке на дубликаты "viewer_id", "viewer_id" приоритетнее, чем "user_id"
  356. # Аналогично с "vid" и "oid", "vid" приоритетнее
  357.  
  358. with open(input_file, 'r', errors='ignore') as logs_file, open(output_file, 'w+', errors='ignore') as logs_sorted_file:
  359.     for line in logs_file.readlines():
  360.  
  361.         try:
  362.             # Splitted by spaces
  363.             splitted_line = line.split()
  364.             if len(splitted_line) >= split_num:
  365.                 if re.search(viewer_id_regexp, splitted_line[split_num]) or re.search(user_id_regexp, splitted_line[split_num]) or re.search(vid_regexp, splitted_line[split_num]) or re.search(oid_regexp, splitted_line[split_num]) or re.search(okru_id_regexp, splitted_line[split_num]):
  366.                     line = splitted_line[split_num]
  367.             # Удаляет всё до "?" вместе с вопросительным знаком и заменяет на вопросительный знак
  368.             if re.search(r'^.*?\?', line):
  369.                 line = re.sub(r'^.*?\?', '?', line)
  370.                 # If at least one "amp;" are exists in line
  371.             if re.search(ampfinder, line):
  372.                 line = ampremover.sub("", line)
  373.             # Если нашлись ауткеи в ауткеях (два ауткея и более в одной строке)
  374.             if len(line.split("?")) >= 3:
  375.                 split_by_qmark = line.split("?")
  376.                 split_by_qmark = list(filter(None, split_by_qmark))
  377.                 for i, auth in enumerate(split_by_qmark):
  378.                     additional_line = "?" + split_by_qmark[i] + "\n"
  379.                     secondary_auths += [additional_line]
  380.                 for line_secondaries in secondary_auths:
  381.                     if re.search(viewer_id_regexp, line_secondaries) or re.search(user_id_regexp, line_secondaries):
  382.                         if re.search(viewer_id_regexp, line_secondaries):
  383.                             viewer_id = re.search(viewer_id_regexp, line_secondaries).group()
  384.                         if re.search(user_id_regexp, line_secondaries):
  385.                             user_id = re.search(user_id_regexp, line_secondaries).group()
  386.  
  387.                         if viewer_id and viewer_id != '0' and user_id and user_id != '0':
  388.                             if viewer_id not in ids_seen:
  389.                                 SocialIdentifierSorter(viewer_id, vkontakte)
  390.                             elif user_id != viewer_id:
  391.                                 if user_id not in ids_seen:
  392.                                     SocialIdentifierSorter(user_id, vkontakte)
  393.                         elif viewer_id and viewer_id != '0' or user_id and user_id != '0':
  394.                             if viewer_id and viewer_id != '0':
  395.                                 if viewer_id not in ids_seen:
  396.                                     SocialIdentifierSorter(viewer_id, vkontakte)
  397.                             elif user_id and user_id != viewer_id and user_id != '0':
  398.                                 if user_id not in ids_seen:
  399.                                     SocialIdentifierSorter(user_id, vkontakte)
  400.  
  401.                     elif re.search(vid_regexp, line_secondaries) or re.search(oid_regexp, line_secondaries):
  402.                         if re.search(vid_regexp, line_secondaries):
  403.                             mm_vid = re.search(vid_regexp, line_secondaries).group()
  404.                         if re.search(oid_regexp, line_secondaries):
  405.                             mm_oid = re.search(oid_regexp, line_secondaries).group()
  406.  
  407.                         if mm_vid and mm_vid != '0' or mm_oid and mm_oid != '0':
  408.                             if mm_vid and mm_vid != '0':
  409.                                 if mm_vid not in ids_seen:
  410.                                     SocialIdentifierSorter(mm_vid, mail_ru)
  411.                             elif mm_oid and mm_oid != '0':
  412.                                 if mm_oid not in ids_seen:
  413.                                     SocialIdentifierSorter(mm_oid, mail_ru)
  414.  
  415.                     elif re.search(okru_id_regexp, line_secondaries):
  416.                         okru_uid = re.search(okru_id_regexp, line_secondaries).group()
  417.  
  418.                         if okru_uid and okru_uid != '0':
  419.                             if okru_uid not in ids_seen:
  420.                                 SocialIdentifierSorter(okru_uid, okru)
  421.             else:
  422.                 if re.search(viewer_id_regexp, line) or re.search(user_id_regexp, line):
  423.                     if re.search(viewer_id_regexp, line):
  424.                         viewer_id = re.search(viewer_id_regexp, line).group()
  425.                     if re.search(user_id_regexp, line):
  426.                         user_id = re.search(user_id_regexp, line).group()
  427.  
  428.                     if viewer_id and viewer_id != '0' and user_id and user_id != '0':
  429.                         if viewer_id not in ids_seen:
  430.                             SocialIdentifierSorter(viewer_id, vkontakte)
  431.                         elif user_id != viewer_id:
  432.                             if user_id not in ids_seen:
  433.                                 SocialIdentifierSorter(user_id, vkontakte)
  434.                     elif viewer_id and viewer_id != '0' or user_id and user_id != '0':
  435.                         if viewer_id and viewer_id != '0':
  436.                             if viewer_id not in ids_seen:
  437.                                 SocialIdentifierSorter(viewer_id, vkontakte)
  438.                         elif user_id and user_id != viewer_id and user_id != '0':
  439.                             if user_id not in ids_seen:
  440.                                 SocialIdentifierSorter(user_id, vkontakte)
  441.  
  442.                 elif re.search(vid_regexp, line) or re.search(oid_regexp, line):
  443.                     if re.search(vid_regexp, line):
  444.                         mm_vid = re.search(vid_regexp, line).group()
  445.                     if re.search(oid_regexp, line):
  446.                         mm_oid = re.search(oid_regexp, line).group()
  447.  
  448.                     if mm_vid and mm_vid != '0' or mm_oid and mm_oid != '0':
  449.                         if mm_vid and mm_vid != '0':
  450.                             if mm_vid not in ids_seen:
  451.                                 SocialIdentifierSorter(mm_vid, mail_ru)
  452.                         elif mm_oid and mm_oid != '0':
  453.                             if mm_oid not in ids_seen:
  454.                                 SocialIdentifierSorter(mm_oid, mail_ru)
  455.  
  456.                 elif re.search(okru_id_regexp, line):
  457.                     okru_uid = re.search(okru_id_regexp, line).group()
  458.  
  459.                     if okru_uid and okru_uid != '0':
  460.                         if okru_uid not in ids_seen:
  461.                             SocialIdentifierSorter(okru_uid, okru)
  462.         except:
  463.             ValueError("Probably, user set too high number for \"split_num\" variable")
  464.  
  465.     sort_buffer = sort_buffer.rstrip()
  466.     for line in sort_buffer:
  467.         logs_sorted_file.write(line)
  468.  
  469.     # Переставляем наконечник на начало файла, чтобы прочитать файл с самого начала и до конца
  470.     logs_sorted_file.seek(0)
  471.     auth_groups = 'VK auths', 'Mail.ru auths', 'Ok.ru auths'
  472.     folds = ['engine', 'wormix_mm', 'wormix_ok']
  473.     contents = logs_sorted_file.readlines()
  474.  
  475. if contents:
  476.     with open(output_file, 'w', errors='ignore') as logs_sorted_file:
  477.         contents[-1] = f'{contents[-1]}\n'
  478.         contents.sort(key=SocialSorter)
  479.         for k, fold in enumerate(auth_groups):
  480.             # Put enter before every category, except the first one
  481.             if k != 0:
  482.                 logs_sorted_file.write(f'\n')
  483.             # Conditional to test that category exists
  484.             if any(line.strip().split("/")[3] == folds[k] for line in contents):
  485.                 # Put the label of each category
  486.                 logs_sorted_file.write(f'{auth_groups[k]}:\n')
  487.                 for i, line in enumerate(contents):
  488.                     # Put the right label in each category
  489.                     try:
  490.                         if line.strip().split("/")[3] == folds[k]:
  491.                             logs_sorted_file.write(f'{line}')
  492.                     except:
  493.                         pass
  494.  
  495.         if vk_ids != 0 or mail_ids != 0 or okru_ids != 0:
  496.             if vk_ids != 0:
  497.                 for vk_id in vk_ids:
  498.                     vk_ids_count += vk_ids.count(vk_id)
  499.             if mail_ids != 0:
  500.                 for mail_id in mail_ids:
  501.                     mail_ids_count += mail_ids.count(mail_id)
  502.             if okru_ids != 0:
  503.                 for okru_uid in okru_ids:
  504.                     okru_ids_count += okru_ids.count(okru_uid)
  505.             print()
  506.             print(f"{fg.red}Total{fg.rs}:" + " " + str(vk_ids_count + mail_ids_count + okru_ids_count) + (" " + "|" + " " + "VK:" + " " + str(vk_ids_count) if (vk_ids_count != 0) else "") + (" " + "|" + " " + "Mail: " + str(mail_ids_count) if (mail_ids_count != 0) else "") + (" " + "|" + " " + "Ok.ru: " + str(okru_ids_count) if (okru_ids_count != 0) else ""))
  507.             logs_sorted_file.write("\n" + "Total:" + " " + str(vk_ids_count + mail_ids_count + okru_ids_count) + (" " + "|" + " " + "VK:" + " " + str(vk_ids_count) if (vk_ids_count != 0) else "") + (" " + "|" + " " + "Mail: " + str(mail_ids_count) if (mail_ids_count != 0) else "") + (" " + "|" + " " + "Ok.ru: " + str(okru_ids_count) if (okru_ids_count != 0) else ""))
  508.  
  509. if vk_ids and vk_ids != 0:
  510.     print()
  511.     question_vk_ids_main = bool(query_yes_no("Хотите создать файл с ссылками на всех вк пользователей ауткеев?"))
  512.     print()
  513.     if question_vk_ids_main == True:
  514.         output_vk_ids_file = output_vk_ids_path + output_vk_ids_name + '.txt'
  515.         print("Файл с ссылками на вк пользователей сохраняется в той же директории, в которой находится программа", end="\n\n")
  516.         question_vk_ids_path = bool(query_yes_no("Желаете указать полный путь к файлу с ссылками на вк пользователей?"))
  517.         print()
  518.         if question_vk_ids_path == True:
  519.             while True:
  520.                 try:
  521.                     print("Пример: D:/Documents/Consollite/", end="\n\n")
  522.                     output_vk_ids_path = str(input("Укажите полный путь к файлу: "))
  523.                     if (output_vk_ids_path[-1:] != "/"):
  524.                         output_vk_ids_path = output_file_path + "/"
  525.                     if not (re.match(restrictions_for_path, output_vk_ids_path)):
  526.                         raise ("Restricted characters!")
  527.                     question_output_vk_ids_path = bool(query_yes_no("Всё правильно?"))
  528.                     print()
  529.                     if question_output_vk_ids_path == True:
  530.                         if os.path.exists(output_vk_ids_path):
  531.                             break
  532.                         else:
  533.                             print("Такой директории не существует!")
  534.                             question_vk_ids_dirnotexist = bool(query_yes_no("Хотите создать?"))
  535.                             print()
  536.                             if question_vk_ids_dirnotexist == True:
  537.                                 try:
  538.                                     Path(output_vk_ids_path).mkdir(parents=True, exist_ok=True)
  539.                                     break
  540.                                 except:
  541.                                     raise ValueError("Maybe program lack access...")
  542.                             else:
  543.                                 raise ValueError("Path are not existed!")
  544.                 except ValueError:
  545.                     print("Error: Path not found", end="\n\n")
  546.                 except:
  547.                     print("Error: Invalid path")
  548.  
  549.         question_output_vk_ids_main = bool(query_yes_no("Желаете указать имя файла с ссылками на пользователей вк?"))
  550.         if question_output_vk_ids_main == True:
  551.             while True:
  552.                 try:
  553.                     output_vk_ids_name = str(input("Укажите желаемое имя выходного файла:  "))
  554.                     if not re.match(restrictions_for_filename, output_vk_ids_name) or len(output_vk_ids_name) >= MAX_FILENAME_LENGTH:
  555.                         raise ValueError("Restricted characters or file name is too long!")
  556.                     output_vk_ids_file = output_vk_ids_path + output_vk_ids_name + '.txt'
  557.                     question_output_vk_ids_filename = bool(query_yes_no("Всё правильно?"))
  558.                     print()
  559.                     if question_output_vk_ids_filename == True:
  560.                         break
  561.                 except ValueError:
  562.                     print("Error: Invalid file name", end="\n\n")
  563.                 except:
  564.                     print("Error: Something went wrong")
  565.         with open(output_vk_ids_file, 'w') as logs_vk_ids_file:
  566.             for line in vk_ids:
  567.                 line = vk_url + line + "\n"
  568.                 logs_vk_ids_file.write(line)
  569.             logs_vk_ids_file.write("\n" + "Total vk users: " + str(vk_ids_count))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement