Alright, i put this together and it seems to work.
1channel.py -breakingbad 1
The Output (1-10):
(1) - Currently 3.80/5
(2) - Currently 3.50/5
(1 opens the link in browser)
if anyone has any suggestions or wants to improve it...
Thanks.
from bs4 import BeautifulSoup
import urllib2, sys, webbrowser
def Work(tvshow):
print "\n[*] Working...\n"
try:
f = urllib2.urlopen(tvshow)
html = f.read()
soup = BeautifulSoup(html)
for table in soup.findAll('table',{"width":"100%"}):
for a in table.findAll('a',{"target":"_blank"}):
for li in table.findAll('li',{"class":"current-rating"}):
if a.text=="Version 2":
print "(1) - %s\n" % (li.text)
link1 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 3":
print "(2) - %s\n" % (li.text)
link2 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 4":
print "(3) - %s\n" % (li.text)
link3 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 5":
print "(4) - %s\n" % (li.text)
link4 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 6":
print "(5) - %s\n" % (li.text)
link5 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 7":
print "(6) - %s\n" % (li.text)
link6 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 8":
print "(7) - %s\n" % (li.text)
link7 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 9":
print "(8) - %s\n" % (li.text)
link8 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 10":
print "(9) - %s\n" % (li.text)
link9 = "http://www.1channel.ch" + a['href']
elif a.text=="Version 11":
print "(10) - %s\n" % (li.text)
link10 = "http://www.1channel.ch" + a['href']
user = raw_input(">>> ")
if user == '1':
webbrowser.open(link1)
elif user == '2':
webbrowser.open(link2)
elif user == '3':
webbrowser.open(link3)
elif user == '4':
webbrowser.open(link4)
elif user == '5':
webbrowser.open(link5)
elif user == '6':
webbrowser.open(link6)
elif user == '7':
webbrowser.open(link7)
elif user == '8':
webbrowser.open(link8)
elif user == '9':
webbrowser.open(link9)
elif user == '10':
webbrowser.open(link10)
else:
exit(0)
except urllib2.HTTPError:
print "- HTTP Error!"
except urllib2.URLError:
print "- Connection Faliure!"
except UnboundLocalError:
print "Episode does not exist!"
def Main():
if len(sys.argv) !=3:
print "1channel.py -show episode#"
sys.exit()
elif sys.argv[1] == '-breakingbad':
tvshow = 'http://www.1channel.ch/tv-4128-Breaking-Bad/season-4-episode-' + sys.argv[2]
elif sys.argv[1] == '-walkingdead':
tvshow = 'http://www.1channel.ch/tv-2490619-The-Walking-Dead/season-3-episode-' + sys.argv[2]
elif sys.argv[1] == '-poi':
tvshow = 'http://www.1channel.ch/tv-2727923-Person-of-Interest/season-2-episode-' + sys.argv[2]
else:
sys.exit()
Work(tvshow)
if __name__ == '__main__':
Main()