Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import re
- import urllib2
- import webbrowser
- from bs4 import BeautifulSoup
- def show_search(surl):
- title = raw_input("enter show: ").replace(' ','+')
- print '[*] Working...\n'
- host = 'http://www.primewire.ag'
- soup1 = BeautifulSoup(urllib2.urlopen(host))
- for field in soup1.find_all('fieldset', {'class':'search_container'}):
- key = field.find('input', {'name':'key'})
- base = host + '/index.php?search_keywords={}&key={}&search_section=2'.format(title, key['value'])
- soup1 = BeautifulSoup(urllib2.urlopen(base))
- for div in soup1.find_all('div', {'class':'index_item index_item_ie'}):
- a = div.find('a')['href']
- if a:
- link1 = host + a.replace('watch', 'tv') + surl
- print link1
- return link1
- def episode_list(search):
- soup2 = BeautifulSoup(urllib2.urlopen(search))
- links2 = {}
- for div in soup2.find_all('div', {'class':'tv_episode_item'}):
- for a in div.find_all('a'):
- match2 = re.search(r'(\d+)', a.get_text())
- title = a.find('span', {'class':'tv_episode_name'})
- if match2:
- number2 = match2.group(1)
- links2[number2] = 'http://www.primewire.ag' + a['href']
- if title:
- print '({}){}'.format(number2, title.get_text().encode('utf-8'))
- else:
- print '({}) - Untitled'.format(number2)
- return links2
- def link_search(episodes, episode):
- print '[*] Searching...\n'
- soup3 = BeautifulSoup(urllib2.urlopen(episodes[episode]))
- links3 = {}
- for table in soup3.find_all('table', {'width':'100%'}):
- for a in table.find_all('a', {'target':'_blank'}):
- for li in table.find_all('li', {'class':'current-rating'}):
- for sn in table.find_all('span', {'class':'version_host'}):
- match3 = re.search(r'(\d+)', a.get_text())
- img = table.find('img', {'title':'Verified Link'})
- if match3:
- number3 = match3.group(1)
- links3[number3] = 'http://www.primewire.ag' + a['href']
- if img:
- print '({}) - {} - {} [!]'.format(number3, li.get_text(), sn.get_text())
- else:
- print '({}) - {} - {}'.format(number3, li.get_text(), sn.get_text())
- return links3
- if __name__ == '__main__':
- if len(sys.argv) != 2:
- print 'Primewire.py season#'
- sys.exit()
- my_seasons = {
- '1': '/season-1',
- '2': '/season-2',
- '3': '/season-3',
- '4': '/season-4',
- '5': '/season-5',
- '6': '/season-6',
- }
- for number in my_seasons:
- if number == sys.argv[1]:
- season = my_seasons[number]
- try:
- search = show_search(season)
- episodes = episode_list(search)
- while True:
- episode = raw_input('\n>>> #: ')
- if episode in episodes:
- os.system('cls')
- break
- versions = link_search(episodes, episode)
- while True:
- vid_link = raw_input('\n>>> #: ')
- if vid_link in versions:
- break
- print '[*] Opening link in browser!'
- webbrowser.open(versions[vid_link])
- sys.exit()
- except urllib2.HTTPError:
- print '- HTTP Error!'
- sys.exit()
- except urllib2.URLError:
- print '- Connection Faliure!'
- sys.exit()
- except:
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement