def render_form(message=''):
<form action="" method="post">
Serie <input type="text" name="serie" />
Season code <input type="text" name="season_code" />
Language <input type="text" name="language" />
<input type="submit" value="submit" />
def results_form(serie='', season_code=1, language='es'):
parser = MUParser(serie, season_code)
""" % (serie, season_code, language, parser)
def application(environ, start_response):
method = environ['REQUEST_METHOD']
start_response('200 OK', [('content-type', 'text/html')])
req_size = int(environ['CONTENT_LENGTH'])
params = parse_qs(environ['wsgi.input'].read(req_size))
serie = params.get("serie",[""])[0]
season_code = params.get("season_code",[""])[0]
language = params.get("language",[""])[0]
start_response('200 OK', [('content-type', 'text/html')])
return results_form(serie, season_code, language)
Parser to get megaupload links from a website. You can use it
just creating an instance of it this way:
>>> from muparser import MUParser
>>> parser = MUParser('http://como-conoci-a-vuestra-madre.seriespepito.com/')
Once run is finished, you can access the links through the
def __init__(self, url=None, season=None):
self.season_code: string code used to find the proper links within
self.megaupload: string code used to identify megaupload links
self.links: dictionary containing each episode identifier as a key,
a list of megaupload links as the value
raise Exception('You have to provide me with an URL')
self.season_code = 'temporada-'
print 'Season must be an integer value, assuming all seasons'
self.season_code += season
self.megaupload = 'megaupload.com'
def get_mu_links(self, url):
Get all the megaupload links from the specified url
print ' --> Getting megaupload.com links'
page = parse(url).getroot()
title = page.find_class('subtitle')[0].text.strip()
for link in page.iterlinks():
if self.megaupload in link[2]:
print ' ---> Adding link:', link[2]
self.links[title].append(link[2])
print '[MUParser - init]', self.url
page = parse(self.url).getroot()
for link in page.iterlinks():
if self.season_code in link[2]:
print ' -> Found link to episode:', link[2]
self.get_mu_links(link[2])