Exemplo n.º 1
0
def amazon_json(request, title, author=''):
    result = amazon.item_lookup(title, author)
    if result.imageurl == None:
        result.imageurl = 'http://www.librarygadget.com/images/noimage_available.png'
    #result.short_itemurl = shorten_url(result.itemurl)
    jsonresponse = json.dumps(result.__dict__)
    response = HttpResponse(jsonresponse)
    response['Content-Type'] = 'application/json; charset=utf-8'
    return response
Exemplo n.º 2
0
def amazon_redirect(request):
    title = request.GET.get('title','')
    author = request.GET.get('author','')
    result = amazon.item_lookup(title, author)
    if result is None or result.itemurl is None:
        return HttpResponseRedirect(''.join(
            ["http://www.amazon.com/gp/search?ie=UTF8&tag=librgadg-20&index=blended&linkCode=ur2&camp=1789&creative=9325&",
             urllib.urlencode({'keywords': title})]))

    return HttpResponseRedirect(result.itemurl)
Exemplo n.º 3
0
def amazon_image(request, size):
    title = request.GET.get('title','')
    author = request.GET.get('author','')
    result = amazon.item_lookup(title, author)
    if result is None or result.itemurl is None:
        return HttpResponseRedirect('/images/none.jpg')

    if size == 'small':
        return HttpResponseRedirect(result.small_image_url)
    if size == 'large':
        return HttpResponseRedirect(result.large_image_url)

    return HttpResponseRedirect(result.medium_image_url)
Exemplo n.º 4
0
 def noop_test_no_image(self):
     itemresult = amazon.item_lookup('Judas and the Gospel of Jesus : have we missed the truth about Christianity?', 'Wright, N. T. (Nicholas Thomas)')
     self.assertEquals('amazon', itemresult.source)
     self.assert_not_empty(itemresult)
Exemplo n.º 5
0
 def test_item_loookup(self):
     itemresult = amazon.item_lookup('Love in the Ruins', 'Percy, Walker')
     self.assertEquals('amazon', itemresult.source)
     self.assert_not_empty(itemresult)