From 967aea4d9f2750a2d928e59563aafa126046b6c3 Mon Sep 17 00:00:00 2001 From: Raphael Mutschler Date: Tue, 21 Jan 2014 16:20:41 +0100 Subject: [PATCH 1/2] fix https://github.com/pillone/usntssearch/issues/113 allow user to define a search query for tvsearch as well as categories other than 5030,5040 --- NZBmegasearch/ApiModule.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/NZBmegasearch/ApiModule.py b/NZBmegasearch/ApiModule.py index a7c9ff7..651a35f 100644 --- a/NZBmegasearch/ApiModule.py +++ b/NZBmegasearch/ApiModule.py @@ -213,23 +213,25 @@ def sickbeard_req(self): return self.generate_tvserie_nabresponse(tvrage_show) else: return render_template('api_error.html') - elif(self.args.has_key('cat')): - if((self.args['cat'].find('5030') != -1) or (self.args['cat'].find('5040') != -1)): - return self.generate_tvserie_nabresponse_broadcast(); - else: - return render_template('api_error.html') + #if user searches for a query, look it up + elif(self.args.has_key('q')): + query = {'showtitle': self.args['q']} + return self.generate_tvserie_nabresponse(query) + #use userdefined category + elif(self.args.has_key('cat')): + return self.generate_tvserie_nabresponse_broadcast(self.args['cat']); else: return render_template('api_default.html') #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - def generate_tvserie_nabresponse_broadcast(self): + def generate_tvserie_nabresponse_broadcast(self, catIDs='5040,5030'): addparams = dict( age= '1500', t='tvsearch', - cat='5040,5030') + cat=catIDs) rawResults = SearchModule.performSearch('', self.cfg, self.cfg_ds, addparams) #~ rawResults = SearchModule.performSearch('', self.cfg, None, addparams) From ea42f50c201329ef1faf0edc43be3cd755083109 Mon Sep 17 00:00:00 2001 From: Raphael Mutschler Date: Tue, 21 Jan 2014 17:52:17 +0100 Subject: [PATCH 2/2] fix indent errors --- NZBmegasearch/ApiModule.py | 198 ++++++++++++++++++------------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/NZBmegasearch/ApiModule.py b/NZBmegasearch/ApiModule.py index 651a35f..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