diff --git a/NZBmegasearch/ApiModule.py b/NZBmegasearch/ApiModule.py index a7c9ff7..2a5a7dd 100644 --- a/NZBmegasearch/ApiModule.py +++ b/NZBmegasearch/ApiModule.py @@ -1,19 +1,19 @@ -# # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # +# # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # #~ This file is part of NZBmegasearch by 0byte. -#~ +#~ #~ NZBmegasearch is free software: you can redistribute it and/or modify #~ it under the terms of the GNU General Public License as published by #~ the Free Software Foundation, either version 3 of the License, or #~ (at your option) any later version. -#~ +#~ #~ NZBmegasearch is distributed in the hope that it will be useful, #~ but WITHOUT ANY WARRANTY; without even the implied warranty of #~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #~ GNU General Public License for more details. -#~ +#~ #~ You should have received a copy of the GNU General Public License #~ along with NZBmegasearch. If not, see . -# # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # +# # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # ## # from flask import Flask, render_template, redirect, send_file, Response @@ -56,61 +56,61 @@ def __init__(self, conf, cgen, wrp, ds): } if(conf is not None): self.timeout = conf[0]['timeout'] - self.cfg= conf + self.cfg= conf self.cfg_cpy = copy.deepcopy(self.cfg) - #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ def set_extraopt(self): for conf in self.cfg : if ( (conf['extra_class'] == 1 ) and (conf['valid'])): conf['valid'] = 0 #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - + def dosearch(self, arguments, hname): self.args = arguments self.rqurl = hname.scheme+'://'+hname.netloc print arguments - + #~ restore originals - self.cfg = copy.deepcopy(self.cfg_cpy) + self.cfg = copy.deepcopy(self.cfg_cpy) self.cfg_ds.set_extraopt(None, 'api') - self.set_extraopt() + self.set_extraopt() if(self.args.has_key('t')): typesearch=self.args['t'] if (typesearch == 'tvsearch'): response = self.sickbeard_req() elif (typesearch == 'movie'): - response = self.couchpotato_req() + response = self.couchpotato_req() elif (typesearch == 'search'): - response = self.generate_tsearch_nabresponse() + response = self.generate_tsearch_nabresponse() #~ elif (typesearch == 'music'): - #~ response = self.headphones_req() - elif (typesearch == 'get'): + #~ response = self.headphones_req() + elif (typesearch == 'get'): filetosend = self.proxy_NZB_file() return filetosend else: - print '>> UNKNOWN REQ -- ignore' + print '>> UNKNOWN REQ -- ignore' response = render_template('api_error.html') else: response = render_template('api_error.html') - return response + return response #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ def dosearch_rss(self, arguments, hname): self.args = arguments - self.rqurl = hname.scheme+'://'+hname.netloc + self.rqurl = hname.scheme+'://'+hname.netloc addparams = dict( age= '1500', limit='20000', t='search', cat='1000,2000,3000,4000,5000,6000,7000') - + if('cat' in self.args): addparams['cat'] = self.args['cat'] - + rawResults = SearchModule.performSearch('', self.cfg, self.cfg_ds, addparams) results = [] #~ no cleaning just flatten in one array @@ -125,14 +125,14 @@ def dosearch_rss(self, arguments, hname): return self.cleanUpResultsXML(results) #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - - def headphones_req(self): + + def headphones_req(self): print self.args if(self.args.has_key('album') or self.args.has_key('artist') or self.args.has_key('track')): return self.generate_music_nabresponse() - else: + else: return render_template('api_error.html') - + #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ def generate_music_nabresponse(self): @@ -145,34 +145,34 @@ def generate_music_nabresponse(self): dstring.append(SearchModule.sanitize_strings(self.args['track'])) if(self.args.has_key('year')): dstring.append(SearchModule.sanitize_strings(self.args['year'])) - - music_search_str = '' + + music_search_str = '' for i in xrange(len(dstring)): if(len(dstring[i]) and i