Example #1
0
def search(request, search_type, search_query):
	print "search called: %s %s" % (search_type, search_query)
	if search_type == "person":
		template = loader.get_template('frontend/search_person.html')
		results = Person.objects.all()
	elif search_type == "character":
		template = loader.get_template('frontend/search_character.html')
		results = Character.objects.all()
	elif search_type == "genre":
		template = loader.get_template('frontend/search_genre.html')
		results = Genre.objects.all()
	else:
		template = loader.get_template('frontend/search_movie.html')
		results = Movie.objects.all()
		
	for word in search_query.split("+"):
		if search_type == "movie":
			results = results.filter(title__icontains = word)
		else:
			results = results.filter(name__icontains = word)
			
	if results.__len__() == 1:
		if search_type ==  "movie":
			return HttpResponseRedirect(reverse(viewname='src.frontend.views.movie', args= (cleanName(results[0].title), results[0].id)))
		elif search_type == "person":
			return HttpResponseRedirect(reverse(viewname='src.frontend.views.person', args= (cleanName(results[0].name), results[0].id)))
		elif search_type == "character":
			return HttpResponseRedirect(reverse(viewname='src.frontend.views.character', args= (cleanName(results[0].name), results[0].id)))
		elif search_type == "genre":
			return HttpResponseRedirect(reverse(viewname='src.frontend.views.genre', args= (cleanName(results[0].name), results[0].id)))
	
	context = Context({'results': results, 'query': search_query.replace("+", " ")})
	return HttpResponse(template.render(context))
Example #2
0
def search(request, search_type, search_query):
    print "search called: %s %s" % (search_type, search_query)
    if search_type == "person":
        template = loader.get_template('frontend/search_person.html')
        results = Person.objects.all()
    elif search_type == "character":
        template = loader.get_template('frontend/search_character.html')
        results = Character.objects.all()
    elif search_type == "genre":
        template = loader.get_template('frontend/search_genre.html')
        results = Genre.objects.all()
    else:
        template = loader.get_template('frontend/search_movie.html')
        results = Movie.objects.all()

    for word in search_query.split("+"):
        if search_type == "movie":
            results = results.filter(title__icontains=word)
        else:
            results = results.filter(name__icontains=word)

    if results.__len__() == 1:
        if search_type == "movie":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.movie',
                        args=(cleanName(results[0].title), results[0].id)))
        elif search_type == "person":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.person',
                        args=(cleanName(results[0].name), results[0].id)))
        elif search_type == "character":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.character',
                        args=(cleanName(results[0].name), results[0].id)))
        elif search_type == "genre":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.genre',
                        args=(cleanName(results[0].name), results[0].id)))

    context = Context({
        'results': results,
        'query': search_query.replace("+", " ")
    })
    return HttpResponse(template.render(context))
Example #3
0
def search_post(request):
    #	try:
    search_type = request.GET["search-option"]
    search_words = request.GET["search-string"]

    if search_type == "person":
        template = loader.get_template('frontend/search_person.html')
        results = Person.objects.all()
    elif search_type == "character":
        template = loader.get_template('frontend/search_character.html')
        results = Character.objects.all()
    elif search_type == "genre":
        template = loader.get_template('frontend/search_genre.html')
        results = Genre.objects.all()
    else:
        template = loader.get_template('frontend/search_movie.html')
        results = Movie.objects.all()

    for word in search_words.split(" "):
        if search_type == "movie":
            results = results.filter(title__icontains=word)
        else:
            results = results.filter(name__icontains=word)

    if results.__len__() == 1:
        if search_type == "movie":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.movie',
                        args=(cleanName(results[0].title), results[0].id)))
        elif search_type == "person":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.person',
                        args=(cleanName(results[0].name), results[0].id)))
        elif search_type == "character":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.character',
                        args=(cleanName(results[0].name), results[0].id)))
        elif search_type == "genre":
            return HttpResponseRedirect(
                reverse(viewname='src.frontend.views.genre',
                        args=(cleanName(results[0].name), results[0].id)))

    context = Context({'results': results, 'query': search_words})
    return HttpResponse(template.render(context))
Example #4
0
def search_post(request):
#	try:	
		search_type = request.GET["search-option"]
		search_words = request.GET["search-string"]
		
		if search_type == "person":
			template = loader.get_template('frontend/search_person.html')
			results = Person.objects.all()
		elif search_type == "character":
			template = loader.get_template('frontend/search_character.html')
			results = Character.objects.all()
		elif search_type == "genre":
			template = loader.get_template('frontend/search_genre.html')
			results = Genre.objects.all()
		else:
			template = loader.get_template('frontend/search_movie.html')
			results = Movie.objects.all()
		
		for word in search_words.split(" "):
			if search_type == "movie":
				results = results.filter(title__icontains = word)
			else:
				results = results.filter(name__icontains = word)
			
		if results.__len__() == 1:
			if search_type ==  "movie":
				return HttpResponseRedirect(reverse(viewname='src.frontend.views.movie', args= (cleanName(results[0].title), results[0].id)))
			elif search_type == "person":
				return HttpResponseRedirect(reverse(viewname='src.frontend.views.person', args= (cleanName(results[0].name), results[0].id)))
			elif search_type == "character":
				return HttpResponseRedirect(reverse(viewname='src.frontend.views.character', args= (cleanName(results[0].name), results[0].id)))
			elif search_type == "genre":
				return HttpResponseRedirect(reverse(viewname='src.frontend.views.genre', args= (cleanName(results[0].name), results[0].id)))
	
		context = Context({'results': results, 'query': search_words})
		return HttpResponse(template.render(context))
Example #5
0
def getTrailerAddictTag(filmName):
	cleanedFilmName = cleanName(filmName)

	filmWords = cleanedFilmName.split(" ")
	url = u"http://www.google.com/search?q=site:traileraddict.com"
	for word in filmWords: 
		url = u"%s+%s" % (url, word)
	request = urllib2.Request(url, None, headers)
	print "Google request: %s" % (url)
	sock = urllib2.urlopen(request)
	parser = URLLister()
	parser.feed(sock.read())
	sock.close()
	parser.close()
 
	for url in parser.urls:
		if re.match("^http://www.traileraddict.com/trailer/.*$", url):
			return re.sub("(^http://www.traileraddict.com/trailer/)|(/[A-Za-z0-9\\-]+)", "", url)

	return ""
Example #6
0
def clean_name(name):
    return cleanName(name)
Example #7
0
 def string_cleaner(self, fieldName):
     return cleanName(fieldName)
Example #8
0
def search(request):
    """
        INPUT :
            search-string
            search-option
        OUTPUT :
            Search_WF's OUTPUT
            time-to-serve
    """
    start = datetime.now()
    search_wf = Search_WF(request.GET, None)
    search_result = search_wf.work()
    
    search_type = request.GET["search-option"]
    search_words = request.GET["search-string"]
    
    if search_type in ["movie-original-title", "movie-aka-title"]:
        template = loader.get_template('frontend/search_movie.html')
    elif search_type in ["actor", "writer", "director"]:
        template = loader.get_template('frontend/search_person.html')
    elif search_type == "character":
        template = loader.get_template('frontend/search_character.html')
    elif search_type == "genre":
        template = loader.get_template('frontend/search_genre.html')
    elif search_type == "award":
        template = loader.get_template('TO DO : frontend/search_award.html')
    elif search_type == "award-category":
        template = loader.get_template('TO DO : frontend/search_award_category.html')
    
    if len(search_result["search-result"]) == 1:
            if search_type in ["movie-original-title", "movie-aka-title"]:
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.movie', args= (cleanName(search_result["search-result"][0].original_title), search_result["search-result"][0].id)))
            elif search_type == "actor":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.actor', args= (cleanName(search_result["search-result"][0].full_name), search_result["search-result"][0].id)))
            elif search_type == "director":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.director', args= (cleanName(search_result["search-result"][0].full_name), search_result["search-result"][0].id)))
            elif search_type == "writer":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.writer', args= (cleanName(search_result["search-result"][0].full_name), search_result["search-result"][0].id)))
            elif search_type == "character":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.character', args= (cleanName(search_result["search-result"][0].character_name), search_result["search-result"][0].id)))
            elif search_type == "genre":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.genre', args= (cleanName(search_result["search-result"][0].genre_name), search_result["search-result"][0].id)))
            elif search_type == "award":
                pass
            elif search_type == "award_category":
                pass
    
#    display_result = {}
#    if search_result["type-of-result"] == "homogeneous":
#        homogeneous_wf = Get_Infos_For_Homogeneous_Search_WF(
#                        {"dict-of-models" : search_result["search-result"]}, None)
#        display_result = homogeneous_wf.work()
#    if search_result["type-of-result"] == "heterogeneous":
#        heterogeneous_wf = Get_Infos_For_Heterogeneous_Search_WF(
#                            {"dict-of-matches" : search_result["search-result"]}, None)
#        display_result = heterogeneous_wf.work()
    served_in = datetime.now() - start + search_result["time-to-serve"]
    search_result["time-to-serve"] = str(served_in.microseconds)
#    return render_to_response("template_targeted", result)
#    return HttpResponse(JSONEncoder().encode(str(search_result["search-result"]["actor-models"][0].get_infos_for_model())))
#    return HttpResponse(JSONEncoder().encode(str(display_result["result"])))
    context = Context({'results': search_result["search-result"],
                       'type' : search_type,
                       'query': search_words,
                       'time' : search_result["time-to-serve"]})
    return HttpResponse(template.render(context))
Example #9
0
def search_post(request):
#    try:    
        search_type = request.GET["search-option"]
        search_words = request.GET["search-string"]
        
        if search_type == "person":
            template = loader.get_template('frontend/search_person.html')
            results = Actor_Model.objects.all()
        elif search_type == "character":
            template = loader.get_template('frontend/search_character.html')
            results = Character_Model.objects.all()
        elif search_type == "genre":
            template = loader.get_template('frontend/search_genre.html')
            results = Genre_Model.objects.all()
        elif search_type in ["movie-original-title", "movie-aka-title"]:
            template = loader.get_template('frontend/search_movie.html')
            results = Movie_Model.objects.all()
        
        for word in search_words.split(" "):
            if search_type in ["movie-original-title", "movie-aka-title"]:
                results = results.filter(original_title__icontains = word)
            elif search_type in ["actor", "writer", "director"]:
                results = results.filter(full_name__icontains = word)
            elif search_type == "character":
                results = results.filter(character_name__icontains = word)
            elif search_type == "genre":
                results = results.filter(genre_name__icontains = word)
            
        if results.__len__() == 1:
            if search_type == "movie":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.movie', args= (cleanName(results[0].original_title), results[0].id)))
            elif search_type == "person":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.person', args= (cleanName(results[0].full_name), results[0].id)))
            elif search_type == "character":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.character', args= (cleanName(results[0].character_name), results[0].id)))
            elif search_type == "genre":
                return HttpResponseRedirect(reverse(viewname='src.seeker.views.genre', args= (cleanName(results[0].genre_name), results[0].id)))
        
        context = Context({'results': results, 'query': search_words})
        return HttpResponse(template.render(context))
Example #10
0
 def string_cleaner(self, fieldName):
     return cleanName(fieldName)
Example #11
0
def clean_name(name):
	return cleanName(name)