Last active
July 5, 2021 00:46
-
-
Save JonnyWong16/b87c99cb6e32ff34a1827fcf9b3b9a37 to your computer and use it in GitHub Desktop.
Generate Plex accounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import requests | |
import string | |
import sys | |
import time | |
import uuid | |
try: | |
NUMBER_OF_ACCOUNTS = int(sys.argv[1]) | |
except (IndexError, ValueError): | |
NUMBER_OF_ACCOUNTS = 1 | |
characters = string.ascii_uppercase + string.ascii_lowercase + string.digits | |
created = 0 | |
while created < NUMBER_OF_ACCOUNTS: | |
email = ''.join(random.choices(characters, k=20)) + '@protonmail.com' | |
password = ''.join(random.choices(characters, k=20)) | |
params = { | |
'X-Plex-Product': 'Plex SSO', | |
'X-Plex-Client-Identifier': str(uuid.uuid4()) | |
} | |
data = { | |
'email': email, | |
'password': password | |
} | |
r = requests.post('https://plex.tv/api/v2/users', params=params, data=data) | |
if r.status_code == 201: | |
combined = email + ':' + password | |
with open('plex_accounts.txt', 'a') as f: | |
f.write(combined + '\n') | |
print(combined) | |
created += 1 | |
time.sleep(random.randint(5, 10)) | |
elif r.status_code == 422: | |
print('Username has already been taken: %' % email) | |
elif r.status_code == 429: | |
print('Rate-limited: sleeping for 10 minutes') | |
time.sleep(600) | |
else: | |
print('Error: [%s] %s' % (r.status_code, r.content)) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment