Cover fetch from google and amazon does not work anymore

Bug #467714 reported by David Caro
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Listen
Fix Released
Medium
Mehdi Abaakouk

Bug Description

On a fresh ubuntu 9.10 install, when you try to fetch a cover from google or amazon you get no results, and a message that says "INFO listen.widget.cover.CoverWindow 0xa3dd3ec failed retrieve amazon or google image information" or "Perhaps Google page structure has changed".

Using listen 0.6.2 from ubutu repositories.

A 'fast and dirty' fix to the problem is to change these lines of /usr/lib/lkisten/widget/cover.py:

356 def on_search_google_cb(self,html_handler,page):
357
358 html = html_handler.read()
359 #js_images = re.findall('[,\[]\[".*?,"1",\[\],""\]',html, re.S)
360 js_images = re.findall('\[\"/imgres[^"]*",\"[^"]*",\"[^"]*",\"([^"]*)",\"[^"]*",\"[^"]*",\"([^"]*)",\"[^"]*",\"[^"]*",\"([^"]*)",',html, re.S)
361 if not js_images :
362 self.logwarn("Perhaps Google page structure has changed")
363 self.fail_fetch()
364 return
365
366 mid = len(js_images)/2
367 if page%2==0:
368 js_images = js_images[ : mid-1 ]
369 else:
370 js_images = js_images[ mid : ]
371
372 items = []
373 for jsimg in js_images:
374 info = jsimg[1]
375 url = str(jsimg[0])
376 title = jsimg[2]
377 #title = unicode(title,errors="ignore")
378 #title = re.sub("<.*?>","",title)
379 items.append((url, title , info))
380
381 self.populate(page,items)

At least lets you fetch google covers :)

python version:Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1] on linux2

Revision history for this message
David Caro (dcaro) wrote :
Revision history for this message
Julien Valroff (julienv) wrote :

Hi,

Here is a patch for the Google image search.

Not sure what's wrong with the Amazon search.

Cheers,
Julien

Revision history for this message
ZioGR (ziogiallorosso) wrote :

Unfortunately I have the same problem both Amazon and Google, I tried to apply what was said by cascara and Julien does not work

Any idea?

Revision history for this message
ZioGR (ziogiallorosso) wrote :

Correction,
I was wrong to insert a line, the patch indicated by Julien works, unfortunately only for Google but for now it's ok, I hope will be resolved soon for Amazon.

Thanks

Revision history for this message
Florian Demmer (fdemmer) wrote :

after adding a new Exception class "MissingParameter" to amazon.py:
    class MissingParameters(AWSException): pass
    class MissingParameter(AWSException): pass

... and changing line 170 to:
     class_name = error.childNodes[0].firstChild.data

i get the following "nice" traceback:

ERROR:listen.cover_manager.ListenCoverManager:0x2d1f490 failed to search on amazon
Traceback (most recent call last):
  File "/usr/local/listen/lib/listen/cover_manager.py", line 283, in get_cover
    ResponseGroup="Images,Request" )
  File "/usr/local/listen/lib/listen/amazon.py", line 354, in ItemSearch
    return pagedIterator(XMLItemSearch, argv, "ItemPage", 'Items', plugins)
  File "/usr/local/listen/lib/listen/amazon.py", line 231, in __init__
    dom = self.__search(** self.__arguments)
  File "/usr/local/listen/lib/listen/amazon.py", line 363, in XMLItemSearch
    return query(buildRequest(argv))
  File "/usr/local/listen/lib/listen/amazon.py", line 190, in query
    raise e
MissingParameter: The request must contain the parameter Signature.

maybe that helps resolving that.

Revision history for this message
Florian Demmer (fdemmer) wrote :

i commited a fix to my 0.6 branch in rev1126

http://bazaar.launchpad.net/~fdemmer/listen/0.6/revision/1126

amazon requires REST requests to be signed with a key computed using a secret key, you get when creating an account with them at http://aws.amazon.com.

to make amazon cover fetch work again use my amazon.py, uncomment the setLicenseKey() in line 284 of cover_manager.py and set the AWS_LICENSE_KEY and AWS_SECRET_KEY environment variables before starting listen. for a cleaner fix i would suggest adding the license and secret key to the preferences dialog and adapt the code in cover_manager.py...

i am new to launchpad so i am not sure how the merge process works... maybe just check my other changes in the branch and see what you want to use...

Revision history for this message
Florian Demmer (fdemmer) wrote :

sorry, that last commit was not clean. with rev1127 it should work as described. i removed the setLicenseKey() from cover.py... missed that one.

http://bazaar.launchpad.net/~fdemmer/listen/0.6/revision/1127

Revision history for this message
Mehdi Abaakouk (sileht) wrote :

Thank a lot Florian Demmer and Julien Valroff

Changed in listen:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Mehdi Abaakouk (theli48)
milestone: none → 0.6.4
Mehdi Abaakouk (sileht)
Changed in listen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.