Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def youtube(searchterm):
- searchterm = quote(get_nowplaying())
- url = "https://gdata.youtube.com/feeds/api/videos?q={}&orderBy=relevance&alt=json"
- url = url.format(searchterm)
- j = requests.get(url).json()
- results = j["feed"]
- if "entry" not in results:
- return "sorry, no videos found"
- video = results["entry"][0]["link"][0]["href"]
- video = re.sub("&feature=youtube_gdata", "", video)
- return video
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement