Advertisement
paster442

Get random YouTube video

Aug 28th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from random import choice
  2. from requests import get
  3.  
  4. def get_id():
  5.     alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890---------__________"
  6.     id = ""
  7.     for _ in range(10):
  8.         id += choice(alphabet)
  9.     return id
  10.  
  11. videos = list()
  12. while True:
  13.     id = get_id()
  14.  
  15.     if get("https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=" + id).status_code == 200:
  16.         videos.append("https://www.youtube.com/watch&v=" + id)
  17.        
  18.         print("https://www.youtube.com/watch&v=" + id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement