当前位置: 首页>>代码示例>>Python>>正文


Python SearchModule类代码示例

本文整理汇总了Python中SearchModule的典型用法代码示例。如果您正苦于以下问题:Python SearchModule类的具体用法?Python SearchModule怎么用?Python SearchModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SearchModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dosearch

	def dosearch(self, args):
		#~ restore originals
		self.cfg = copy.deepcopy(self.cfg_cpy)
		
		if('q' not in args):
			self.results = []
			return self.results
		nuqry = args['q'] + ' ' + self.cgen['searchaddontxt']
		self.logic_items = self.logic_expr.findall(nuqry)
		self.qry_nologic = self.logic_expr.sub(" ",nuqry)
		if('selcat' in args):
			if(args['selcat'] != ""):
				self.qry_nologic += " " + args['selcat']

		#~ speed class
		speed_class_sel = 1	
		if('tm' in args):
			speed_class_sel = int(args['tm'])
		
		#~ speed class deepsearch
		self.ds.set_timeout_speedclass(speed_class_sel)
		#~ speed class Nabbased	
		for conf in self.cfg :
			if ( (conf['speed_class'] <=  speed_class_sel) and (conf['valid'])):
				conf['timeout']  = self.cgen['timeout_class'][ speed_class_sel ]
				#~ print conf['type'] + " " + str(conf['timeout'] ) + ' ' + str(speed_class_sel )
			else:
				conf['valid']  = 0
		 
					
		if( len(args['q']) == 0 ):
			if('selcat' in args):
				if(len(args['selcat'])==0):
					self.results = []
					return self.results
			else:
				self.results = []
				return self.results
		if(self.qry_nologic.replace(" ", "") == ""):
			self.results = []
			return self.results
						
		self.cleancache()
		#~ cache hit, no server report
		self.returncode_fine['code'] = 2
		self.resultsraw = self.chkforcache(self.wrp.chash64_encode(SearchModule.sanitize_strings(self.qry_nologic)), speed_class_sel)
		if( self.resultsraw is None):
			self.resultsraw = SearchModule.performSearch(self.qry_nologic, self.cfg, self.ds )
			self.prepareretcode();
			
		if( self.cgen['smartsearch'] == 1):
			#~ smartsearch
			self.results = summary_results(self.resultsraw, self.qry_nologic, self.logic_items)
		else:
			#~ no cleaning just flatten in one array
			self.results = []
			for provid in xrange(len(self.resultsraw)):
				for z in xrange(len(self.resultsraw[provid])):
					if (self.resultsraw[provid][z]['title'] != None):
						self.results.append(self.resultsraw[provid][z])
开发者ID:PeterBeard,项目名称:usntssearch,代码行数:60,代码来源:megasearch.py

示例2: generate_music_nabresponse

    def generate_music_nabresponse(self):
        dstring = []
        if self.args.has_key("artist"):
            dstring.append(SearchModule.sanitize_strings(self.args["artist"]))
        if self.args.has_key("album"):
            dstring.append(SearchModule.sanitize_strings(self.args["album"]))
        if self.args.has_key("track"):
            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 = ""
        for i in xrange(len(dstring)):
            if len(dstring[i]) and i < len(dstring) - 1:
                music_search_str = music_search_str + dstring[i]

        print music_search_str
        # ~ print movie_search_str
        self.searchstring = music_search_str
        self.typesearch = 0
        # ~ compile results
        # ~ results = SearchModule.performSearch(movie_search_str, self.cfg )
        # ~ flatten and summarize them
        # ~ cleaned_results = megasearch.summary_results(results,movie_search_str)
        # ~ render XML
        # ~ return self.cleanUpResultsXML(cleaned_results)
        return "m"
开发者ID:cauchy49,项目名称:usntssearch,代码行数:27,代码来源:ApiModule.py

示例3: generate_music_nabresponse

	def generate_music_nabresponse(self):
		dstring = []
		if(self.args.has_key('artist')):
			dstring.append(SearchModule.sanitize_strings(self.args['artist']))
		if(self.args.has_key('album')):
			dstring.append(SearchModule.sanitize_strings(self.args['album']))
		if(self.args.has_key('track')):
			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 = ''
		for i in xrange(len(dstring)):
			if(len(dstring[i]) and i<len(dstring)-1):
				music_search_str = music_search_str + dstring[i]

		print music_search_str
		#~ print movie_search_str
		self.searchstring = music_search_str
		self.typesearch = 0
		#~ compile results
		#~ results = SearchModule.performSearch(movie_search_str, self.cfg )
		#~ flatten and summarize them
		#~ cleaned_results = megasearch.summary_results(results,movie_search_str)
		#~ render XML
		#~ return self.cleanUpResultsXML(cleaned_results)
		return 'm'
开发者ID:cytec,项目名称:usntssearch,代码行数:27,代码来源:ApiModule.py

示例4: generate_tvserie_nabresponse

	def generate_tvserie_nabresponse(self,tvrage_show ):
		#~ compile string
		season_num = self.args.get('season',-1, type=int)
		relaxed_seasonmatch = 0
		serie_search_str = SearchModule.sanitize_strings(tvrage_show['showtitle'])
		if(self.args.has_key('ep')):
			ep_num = self.args.get('ep',-1, type=int)
			serie_search_str = serie_search_str + '.s%02d' % season_num + 'e%02d' % ep_num
		else:
			serie_search_str = serie_search_str + '.s%02d' % season_num
			relaxed_seasonmatch = 1

		self.typesearch = 1
		self.searchstring = serie_search_str
		#~ compile results
		results = SearchModule.performSearch(serie_search_str, self.cfg , self.cfg_ds )

		cleaned_results = []
		if(relaxed_seasonmatch):
			#~ no cleaning just flatten in one array
			for provid in xrange(len(results)):
				if(results[provid] is not None):
					for z in xrange(len(results[provid])):
						cleaned_results.append(results[provid][z])
		else:
			#~ flatten and summarize them
			cleaned_results = megasearch.summary_results(results,serie_search_str)

		#~ render XML
		return self.cleanUpResultsXML(cleaned_results)
开发者ID:cytec,项目名称:usntssearch,代码行数:30,代码来源:ApiModule.py

示例5: generate_tsearch_nabresponse

	def generate_tsearch_nabresponse(self):

		if(self.args.has_key('q')):
			freesearch_str = SearchModule.sanitize_strings(self.args['q'])
			self.searchstring = freesearch_str
			self.typesearch = 2
			#~ compile results
			results = SearchModule.performSearch(freesearch_str, self.cfg, self.cfg_ds )
			#~ flatten and summarize them
			cleaned_results = megasearch.summary_results(results, freesearch_str)
			#~ render XML
			return self.cleanUpResultsXML(cleaned_results)
开发者ID:cytec,项目名称:usntssearch,代码行数:12,代码来源:ApiModule.py

示例6: __init__

	def __init__(self):
		import urlparse

		cfgsets = config_settings.CfgSettings()
		
		self.cgen = cfgsets.cgen
		self.logsdir = SearchModule.resource_path('logs/nzbmegasearch.log')
		self.scriptsdir = SearchModule.resource_path('get_stats.sh')
		self.cfg_urlidx = []
		self.excludeurls= ['http://ftdworld.net', 'https://nzbx.co']
		if(cfgsets.cfg is not None):
			self.config = cfgsets.cfg
			for i in xrange(len(self.config)):
				if(self.config[i]['builtin'] == 0):
					self.cfg_urlidx.append(i)
开发者ID:PeterBeard,项目名称:usntssearch,代码行数:15,代码来源:miscdefs.py

示例7: search

def search():   
    data=request.query.data
    str_lim=request.query.limit
    columns=request.query.getall("selected[]")
    #print(request.query.keys())
    print(columns)
    if(str_lim==''):
        limit=0
    else:
        limit=int(str_lim)
    callback_name = cgi.escape(request.query.callback)
    print "callback="+str(callback_name)
    res=SearchModule.search_by_id(data,limit,columns)
    add_list_to_process_queue(res[0:10]) 
    
    #para que muestre solo algunas columnas (gronchada)
    if(len(columns)==0):
        show=["sha1","description","size"]
    else:
        show=["sha1"]
        for col in columns:
            dic=tree_menu.ids[int(col)]
            path=str(dic["path"]).split('.')[-1]
            show.append(path)
    
    responsex={}
    responsex["normal"]=res
    responsex["show"]=show
        
    return jsonp(responsex,callback_name)
开发者ID:Bijaye,项目名称:codex-backend,代码行数:30,代码来源:api2.py

示例8: api_batch_process_file

def api_batch_process_file():
    logging.debug("api_batch_process_file(): Running Batch process")
    file_hashes = request.forms.get('file_hash')
    # transform file_hashes in a list of hashes
    if file_hashes is None:
        return jsonize({"Error: file_hash parameter is missing."})
    not_found = []
    added_to_queue = 0
    downloaded_from_vt = 0
    for hash_id in file_hashes.split("\n"):
        hash_id = clean_hash(hash_id)
        if hash_id is None:
            continue
        data = "1=" + str(hash_id)
        res = SearchModule.search_by_id(data, 1, [], True)
        if(len(res) == 0):
            not_found.append(hash_id)
            continue
        else:
            sha1 = res[0]["sha1"]

        added_to_queue += 1
        logging.debug(str(hash_id) + " added to queue")
        add_hash_to_process_queue(sha1)

    responsex = str(added_to_queue) + " files added to the process queue.\n"
    if(downloaded_from_vt > 0):
        responsex += str(downloaded_from_vt) + " new hashes.\n"
    if(len(not_found) != 0):
        responsex += str(len(not_found)) + " hashes not found.\n"
        responsex += "Not Found:\n"
        for aux in not_found:
            responsex = responsex + str(aux) + "\n"

    return jsonize({"message": responsex})
开发者ID:codexgigassys,项目名称:codex-backend,代码行数:35,代码来源:api2.py

示例9: search

def search():
    data = request.query.data
    str_lim = request.query.limit
    columns = request.query.getall("selected[]")
    logging.debug("search(). columns=" + str(columns))
    if(str_lim == ''):
        limit = 0
    else:
        limit = int(str_lim)
    callback_name = cgi.escape(request.query.callback)
    logging.debug("search(). callback=" + str(callback_name))
    res = SearchModule.search_by_id(data, limit, columns, True)
    add_list_to_process_queue(res[0:10])

    # to only show a few columns (uggly stuff)
    if(len(columns) == 0):
        show = ["sha1", "description", "size"]
    else:
        show = ["sha1"]
        for col in columns:
            dic = tree_menu.ids[int(col)]
            path = str(dic["path"]).split('.')[-1]
            show.append(path)

    responsex = {}
    responsex["normal"] = res
    responsex["show"] = show

    return jsonp(clean_tree(responsex), callback_name)
开发者ID:codexgigassys,项目名称:codex-backend,代码行数:29,代码来源:api2.py

示例10: filter_obsolete_providers

	def	filter_obsolete_providers(self):
		
		#~ avoids obsolete modules to appear in the search routine
		#~ this is an additional safety measure
		if 'loadedModules' not in globals():
			SearchModule.loadSearchModules()
		
		saved_cfg = []
		for index in xrange(len(self.cfg)):
			index_found = False
			for module in SearchModule.loadedModules:
				if( module.typesrch == self.cfg[index]['type']):
					index_found = True
			if(index_found is True):
				saved_cfg.append(self.cfg[index])
		self.cfg = copy.deepcopy(saved_cfg)
开发者ID:PeterBeard,项目名称:usntssearch,代码行数:16,代码来源:config_settings.py

示例11: __init__

	def __init__(self, conf, cgen):
		self.trendsdir = SearchModule.resource_path('logs/')
		self.timeout = cgen['default_timeout']
		self.movie_trend = []
		self.movie_trend_ts = 0
		self.show_trend = []
		self.show_trend_ts = 0
		self.sugg_info = []
		self.active_trend = 1
		self.trends_refreshrate = cgen['trends_refreshrate']
		self.detached_trendpolling = cgen['large_server']
		self.best_k	= cgen['trends_qty']
		self.cgen	= cgen
		self.logic_expr = re.compile("(?:^|\s)([-+])(\w+)")
		self.predb_info = []
		self.tvrage_rqheaders = {
						'Connection': 'keep-alive;' ,
						'Cache-Control': 'max-age=0',
						'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
						'User-Agent': 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17',
						'Referer': 'http://services.tvrage.com/info.php?page=main',
						'Accept-Encoding': 'gzip,deflate,sdch',
						'Accept-Language': 'en-US,en;q=0.8',
						'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
						 }

		if(int(cgen['general_trend']) == 0):
			self.active_trend = 0
开发者ID:kloz8879,项目名称:usntssearch,代码行数:28,代码来源:SuggestionModule.py

示例12: generate_tvserie_nabresponse

	def generate_tvserie_nabresponse(self,tvrage_show ):
		#~ compile string
		season_num = self.args.get('season',-1, type=int)
		serie_search_str = SearchModule.sanitize_strings(tvrage_show['showtitle'])
		if(self.args.has_key('ep')):
			ep_num = self.args.get('ep',-1, type=int)			
			serie_search_str = serie_search_str + '.s%02d' % season_num + 'e%02d' % ep_num
		else:	
			serie_search_str = serie_search_str + '.s%02d' % season_num 
		self.typesearch = 1
		self.searchstring = serie_search_str
		#~ compile results				
		results = SearchModule.performSearch(serie_search_str, self.cfg )		
		#~ flatten and summarize them
		cleaned_results = megasearch.summary_results(results,serie_search_str)
		#~ render XML
		return self.cleanUpResultsXML(cleaned_results)
开发者ID:carterjl2,项目名称:usntssearch,代码行数:17,代码来源:ApiModule.py

示例13: html_builtin_output

def html_builtin_output(cffile, genopt): 
	count = 0
	
	if 'SearchModule.loadedModules' not in globals():
		SearchModule.loadSearchModules()
	
	cffileb = []		
	for module in SearchModule.loadedModules:
		if(module.builtin):
			option='checked=yes'
			flogin=0
			login_name =  ''
			login_pwd = ''
			if(module.active == 0):
				option=''
			for i in xrange(len(cffile)):
				if(cffile[i]['type'] == module.typesrch):
					if(cffile[i]['valid'] == '0'):
						option=''
					else: 	
						option='checked=yes'
					
					login_name=cffile[i]['login']
					login_pwd=cffile[i]['pwd']
					
			if(module.login == 1):
				flogin = 1
			
			tmpcfg= {'stchk' : option,
					'humanname' : module.name,
					'idx' : count,
					'type' : module.typesrch,
					'flogin': flogin,
					'loginname': login_name,
					'loginpwd': login_pwd,
					}
			cffileb.append(tmpcfg)
			count = count + 1

	count = 0
	for i in xrange(len(cffile)):
		if(cffile[i]['builtin'] == 0):
			cffile[i]['idx'] =  count
			count = count + 1

	return render_template('config.html', cfg=cffile, cnt=count,  genopt = genopt, cnt_max=MAX_PROVIDER_NUMBER, cfg_bi=cffileb)
开发者ID:carterjl2,项目名称:usntssearch,代码行数:46,代码来源:config_settings.py

示例14: api_batch_process_debug_file

def api_batch_process_debug_file():
    yield "<html><body><pre>"
    yield "Running Batch process\n"
    file_hashes=request.forms.get('file_hash')
    #print(dir(request.forms))
    #print(request.forms.keys())
    #transformar file_hashes a una lista de hashes
    not_found=[]
    added_to_queue=0
    downloaded_from_vt=0
    for hash_id in file_hashes.split("\n"):
        hash_id=clean_hash(hash_id)
        if hash_id is None:
            continue
        data="1="+hash_id
        res=SearchModule.search_by_id(data,1,[],False)
        if(len(res)==0):
            print "downloading "+str(hash_id)+" from vt"
            sha1=SearchModule.add_file_from_vt(hash_id)
            if(sha1==None):
                not_found.append(hash_id)
                continue
            else:
                downloaded_from_vt+=1
        else:    
            sha1=res[0]["sha1"]

        added_to_queue+=1    
        add_hash_to_process_queue(sha1)
	yield str(sha1)+"\n"
   
    responsex=str(added_to_queue)+" files added to the process queue.\n"
    if(downloaded_from_vt > 0):
        responsex+=str(downloaded_from_vt)+" new hashes.\n"
    if(len(not_found)!=0):
        responsex+=str(len(not_found))+ " hashes not found.\n"
        responsex+="Not Found:\n"
        for aux in not_found:
            responsex=responsex+str(aux)+"\n"
    yield responsex
    yield "END"
开发者ID:Bijaye,项目名称:codex-backend,代码行数:41,代码来源:api2.py

示例15: prepareforquery_show

	def prepareforquery_show(self, sugg_info_raw, lastepisode, sugg_info):	
		
		for i in xrange(len(lastepisode)):
			si = {'searchstr': SearchModule.sanitize_strings(sugg_info_raw['title']) 
								+ '.S%02d' % int(lastepisode[i]['season']) 
								+  'E%02d' %  int(lastepisode[i]['ep']),
				  'prettytxt': sugg_info_raw['title'] +  ' S%02d ' %  int(lastepisode[i]['season']) 
								+ 'E%02d' %  int(lastepisode[i]['ep']),
				  'imdb_url': sugg_info_raw['tvdb_url']}
			sugg_info.append(si)
		
		return sugg_info 
开发者ID:kloz8879,项目名称:usntssearch,代码行数:12,代码来源:SuggestionModule.py


注:本文中的SearchModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。