Created
October 14, 2012 23:12
-
-
Save FiXato/3890124 to your computer and use it in GitHub Desktop.
Retrieve page title for YouTube video ID.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If the url is a youtube URL, make sure we query the api instead of the actual page to prevent triggering captcha requests | |
if 'v=' in url and ('youtube.com' in url or 'youtu.be' in url): | |
m = re.search('v=([\w\d_-]+)', url) | |
if m: | |
youtube_id = m.group(1) | |
url = "http://gdata.youtube.com/feeds/api/videos?v=2&q=" + youtube_id + "&max-results=1&fields=entry(title)&prettyprint=false" | |
weechat.prnt("", url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -A "Title Retriever" --silent "http://gdata.youtube.com/feeds/api/videos?v=2&q=$1&max-results=1&fields=entry(title)&prettyprint=false"|awk -vRS="</title>" '/<title>/{gsub(/.*<title>|\n+/,"");print;exit}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment