View Single Post
Old 05-27-2011, 10:33 AM   #79
loureiro
Junior Member
loureiro began at the beginning.
 
Posts: 2
Karma: 10
Join Date: May 2011
Device: Nook
Quote:
Originally Posted by jens32 View Post
@loureiro Problem is the same with the adaption in the get_browser method.
Now I am always getting an Error Code 400, no matter what version of the get_browser method I am using:
PHP Code:
  File "/tmp/calibre_0.8.2_tmp_EKxFgD/calibre_0.8.2_APXqCL_recipes/recipe0.py"line 57in article_downloaded
    br
.open(self.mark_as_read_urlfields)
  
File "site-packages/mechanize/_opener.py"line 204in open
  File 
"site-packages/mechanize/_urllib2_fork.py"line 457in http_response
  File 
"site-packages/mechanize/_opener.py"line 227in error
  File 
"site-packages/mechanize/_urllib2_fork.py"line 332in _call_chain
  File 
"site-packages/mechanize/_urllib2_fork.py"line 477in http_error_default
HTTPError
HTTP Error 400Bad Request 
Recipes run fine if there is no custom article_downloaded method.

Shouldn't have the id argument have a format like tag:google.com,2005:reader/item/041fa4grw5de72c9 when marking the article read? I can't find any id like this.
using "my version" of get_browser try changing this:


Code:
 
def article_downloaded(self, request, result): 
        br = self.browser 
        req = self.build_request(self.mark_as_read_url) 
        if not result[2]: 
            # Mark article as downloaded. 
            article = request.article 
            fields = urllib.urlencode([("i", article.id), ("a", "user/-/state/com.google/read"), 
                ("ac", "edit-tags"), ("T", self.token)]) 
            br.open(self.mark_as_read_url, fields) 
        return BasicNewsRecipe.article_downloaded(self, request, result)
to this:


Code:
 
def article_downloaded(self, request, result): 
        br = mybr # <----
        req = self.build_request(self.mark_as_read_url) 
        if not result[2]: 
            # Mark article as downloaded. 
            article = request.article 
            fields = urllib.urlencode([("i", article.id), ("a", "user/-/state/com.google/read"), 
                ("ac", "edit-tags"), ("T", self.token)]) 
            br.open(self.mark_as_read_url, fields) 
        return BasicNewsRecipe.article_downloaded(self, request, result)
loureiro is offline   Reply With Quote