윤영빈

get youtube url from video ID

1 +import requests
2 +
3 +base_URL = 'https://data.yt8m.org/2/j/i/'
4 +youtube_url = 'https://www.youtube.com/watch?v='
5 +
6 +def getURL(vid_id):
7 + URL = base_URL + vid_id[:-2] + '/' + vid_id + '.js'
8 + response = requests.get(URL, verify = False)
9 + if response.status_code == 200:
10 + return youtube_url + response.text[10:-3]
11 +
12 +
13 +# example usage : getURL('nXSc');
...\ No newline at end of file ...\ No newline at end of file