Guest User

Untitled

a guest
Mar 4th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import random, string
  2.  
  3. #Where created IDs will go to be checked for duplicates as newer IDs get generated.
  4. usedID = []
  5.  
  6. #Defining range of acceptable characters
  7. b64 = string.digits + string.ascii_uppercase + string.ascii_lowercase + "-" + "_"
  8.  
  9. def generate(requested):
  10. count = 1
  11. for j in range (requested):
  12. output = ""
  13. while output not in usedID:
  14. for i in range(11):
  15. rNum = random.randint(0, 63)
  16. digit = str(b64[rNum])
  17. output += digit
  18. digit = ""
  19. if output not in usedID:
  20. usedID.append(output)
  21. usedID.sort()
  22. print("{}/{}: {}".format(count, requested, output))
  23. count = count + 1
  24. break
  25.  
  26. req = int(input("Welcome! Type in a number to receive a custom amount of unique Base64 YouTube IDs!\n"))
  27.  
  28. generate(req)
  29.  
  30. print("Enjoy!")
Advertisement
Add Comment
Please, Sign In to add comment