url_generator.py 363 Bytes
import requests

base_URL = 'https://data.yt8m.org/2/j/i/'
youtube_url = 'https://www.youtube.com/watch?v='

def getURL(vid_id):
    URL = base_URL + vid_id[:-2] + '/' + vid_id + '.js'
    response = requests.get(URL, verify = False)
    if response.status_code == 200:
        return youtube_url + response.text[10:-3]
        

# example usage : getURL('nXSc');