Guest User

Untitled

a guest
Dec 9th, 2024
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. import os
  2. import csv
  3.  
  4. def list_txt_files(folder):
  5. """List all .txt files in a folder."""
  6. return [f for f in os.listdir(folder) if f.endswith('.txt')]
  7.  
  8. def read_file(file_path):
  9. """Read lines from a file."""
  10. with open(file_path, 'r') as file:
  11. return file.readlines()
  12.  
  13. def write_csv(file_path, rows, header):
  14. """Write rows to a CSV file."""
  15. with open(file_path, 'w', newline='') as file:
  16. writer = csv.writer(file)
  17. writer.writerow(header)
  18. writer.writerows(rows)
  19.  
  20. def main():
  21. # List available files
  22. txt_files = list_txt_files('.')
  23. if not txt_files:
  24. print("No .txt files found in the current directory.")
  25. return
  26.  
  27. print("Available .txt files:")
  28. for i, file in enumerate(txt_files, 1):
  29. print(f"{i}. {file}")
  30.  
  31. # Choose the accounts file
  32. acc_file_index = int(input("Choose the file that contains the accounts (type in the number associated with a file and press Enter): ")) - 1
  33. accounts_file = txt_files[acc_file_index]
  34. accounts = read_file(accounts_file)
  35.  
  36. # Choose the proxies file
  37. proxy_file_index = int(input("Choose the proxy .txt file (format proxyip:port,username,password): ")) - 1
  38. proxies_file = txt_files[proxy_file_index]
  39. proxies = read_file(proxies_file)
  40.  
  41. # Parse proxies
  42. proxies = [proxy.strip().split(',') for proxy in proxies]
  43. proxy_count = len(proxies)
  44.  
  45. if proxy_count == 0:
  46. print("No valid proxies found in the proxies file.")
  47. return
  48.  
  49. # Define CSV header
  50. header = [
  51. "name", "email/username", "password", "proxy-url/proxy-ip:port",
  52. "proxy username", "proxy password", "tags", "date of birth (US format)",
  53. "description", "unique name", "email validation username",
  54. "email validation pass", "email validation pop3server", "email validation port",
  55. "EB user agent", "api user agent", "username", "platform", "Notes",
  56. "ApiCookies", "Phone Number", "2FA Secret Key"
  57. ]
  58.  
  59. # Ask for the number of accounts per proxy
  60. accounts_per_proxy = int(input("Enter how many accounts will use the same proxy: "))
  61.  
  62.  
  63. # Replace proxies in accounts and prepare CSV rows
  64. rows = []
  65. proxy_index = 0
  66. for i, account in enumerate(accounts):
  67. if "#proxy-url/proxy-ip:port" in account:
  68. # Determine the proxy to use based on accounts_per_proxy
  69. proxy = proxies[proxy_index % proxy_count]
  70. proxy_str = f"{proxy[0]},{proxy[1]},{proxy[2]}"
  71. account = account.replace("#proxy-url/proxy-ip:port,#proxy username,#proxy password", proxy_str)
  72.  
  73. # Increment proxy index only after `accounts_per_proxy` accounts have been assigned the same proxy
  74. if (i + 1) % accounts_per_proxy == 0:
  75. proxy_index += 1
  76.  
  77. # Split account data by comma and add to rows
  78. rows.append(account.strip().split(','))
  79.  
  80. # Save to CSV file
  81. output_file = "output.csv"
  82. write_csv(output_file, rows, header)
  83. print(f"Updated accounts have been saved to {output_file} as a CSV file. Ready to import to Jarvee/Susocial")
  84.  
  85. if __name__ == "__main__":
  86. try:
  87. main()
  88. except Exception as e:
  89. print(f"An error occurred: {e}")
  90. finally:
  91. input("Press Enter to exit...")
  92.  
Advertisement
Add Comment
Please, Sign In to add comment