Created
September 20, 2015 20:21
-
-
Save controversial/29adaaf8f38a1eab57c2 to your computer and use it in GitHub Desktop.
YoutubePiP-1.5.py
This file contains 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
import bs4, urllib2, webbrowser | |
starturl = raw_input('url: ') | |
#handle redirects, in case of shortened url | |
url = urllib2.urlopen(urllib2.Request(starturl)).geturl() | |
#keepvid page url | |
url = 'http://www.keepvid.com/?url='+url.split('&feature')[0] | |
#beautifulsoup object of keepvid page | |
soup = bs4.BeautifulSoup(urllib2.urlopen(url).read()) | |
#find valid links | |
links = [] | |
for l in soup.select('a'): | |
if l.get('href'): | |
if 'googlevideo.com' in l.get('href'): | |
links.append(l) | |
#Open the link | |
webbrowser.open('safari-'+links[0].get('href')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment