|
|
#1 |
|
Member
![]() Posts: 11
Karma: 10
Join Date: Sep 2010
Device: Kindle
|
Error developing new plug-in
I found a python developer and asked him for help with building a new plug-in. He's put something together that looks good to me ( I'm a developer, but not with python ).
First, I load the plug-in through the command line. ( I've tried loading the plug-in ziped or not ziped. ) When I try and test the new plug-in, I get the following error. Code:
C:\Program Files\Calibre2>calibre-debug --add-simple-plugin="C:\Program Files\Calibre2\gr_plugin.py" Plugin added: Goodreads (1, 0, 0) C:\Program Files\Calibre2>calibre-debug -g Starting up... Started up in 4.42100000381 Exception in thread Thread-13: Traceback (most recent call last): File "threading.py", line 525, in __bootstrap_inner File "site-packages\calibre\gui2\dialogs\fetch_metadata.py", line 38, in run File "site-packages\calibre\ebooks\metadata\fetch.py", line 312, in search File "site-packages\calibre\ebooks\metadata\fetch.py", line 269, in __enter__ File "site-packages\calibre\customize\__init__.py", line 123, in __enter__ File "site-packages\calibre\utils\zipfile.py", line 734, in __init__ File "site-packages\calibre\utils\zipfile.py", line 755, in _GetContents File "site-packages\calibre\utils\zipfile.py", line 765, in _RealGetContents File "site-packages\calibre\utils\zipfile.py", line 204, in _EndRecData AttributeError: 'tuple' object has no attribute 'seek' Anyone have any idea what we're doing wrong? The plug-in has nothing to do with zipping. |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,592
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It looks like a bug, what type of plugin is this? Metadata download?
|
|
|
|
|
|
#3 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,592
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Also what version of calibre are you using?
|
|
|
|
|
|
#4 |
|
Member
![]() Posts: 11
Karma: 10
Join Date: Sep 2010
Device: Kindle
|
Yes, downloading metadata. And I'm using 7.18.
|
|
|
|
|
|
#5 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,592
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Can you post the python file of the plugin?
|
|
|
|
|
|
#6 |
|
Member
![]() Posts: 11
Karma: 10
Join Date: Sep 2010
Device: Kindle
|
This was kindly written by Giacomo Lacava.
Code:
__license__ = 'GPL v3'
__copyright__ = '2010, Giacomo Lacava <g.lacava@gmail.com>'
DEV_KEY = "xxxxxxxxxxxxxxxxx"
GR_API_SEARCH = "http://www.goodreads.com/search/search?" + "format=xml&key=%(key)s&q=%(param)s&page=%(page)i"
GR_API_BOOK_SHOW = "http://www.goodreads.com/book/show/%(id)s?key=%(key)s"
import time
from urllib import quote_plus
from lxml import etree
from calibre import browser
from calibre.customize import Plugin
from calibre.ebooks.metadata.fetch import MetadataSource
from calibre.ebooks.metadata import MetaInformation
class GrSource(MetadataSource):
author = 'Giacomo Lacava'
metadata_type = 'basic'
name = 'Goodreads'
description = _('Downloads metadata from Goodreads')
version = (1, 0, 0)
supported_platforms = ['windows', 'osx', 'linux']
def __init__(self,*params):
super(MetadataSource,self).__init__(params)
def fetch(self):
param = ""
if self.isbn is not None: #isbn excludes any other parameter
param = self.isbn
else:
for attr in [self.title,self.book_author]:
if attr is not None:
# strip stuff that GR doesn't (or may not) like
for char in "()[]~@?/\\`&*!£$%*+={}#><":
attr = attr.encode("utf8").replace(char,"")
param = "+".join([quote_plus(attr),param])
if param is not None:
page = 1
results_num = 0
self.results = []
while True: # run until we got all results
url = GR_API_SEARCH % {"key":DEV_KEY,
"param": param,
"page": page
}
print "calling " + url
br = browser()
response_xml = br.open(url).read()
root = etree.fromstring(response_xml)
time.sleep(1) # to avoid throttling from GR
for book in root.findall(".//work"):
title = book.find("./best_book/title").text
authors = [ author.find("./name").text for author in book.findall("./best_book/author")]
print "got " + title + " by " + "/".join(authors)
mi = MetaInformation(title,authors)
# what we should do now is to get descriptions etc
# no point threading it because of GR throttling requests
bookurl = GR_API_BOOK_SHOW % { "key":DEV_KEY,
"id": book.find("./best_book/id").text }
print "Calling " + bookurl
book_xml = br.open(bookurl).read()
xmlroot = etree.fromstring(book_xml)
time.sleep(1) # to avoid throttling from GR
## things we can add here:
# 'author_sort', 'title_sort', 'comments', 'category',
# 'publisher', 'series', 'series_index', 'rating',
# 'isbn', 'tags', 'cover_data', 'application_id', 'guide',
# 'manifest', 'spine', 'toc', 'cover', 'language',
# 'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc',
# 'pubdate', 'rights', 'publication_type', 'uuid'
mi.comments = xmlroot.find(".//book/description").text
mi.publisher = xmlroot.find(".//book/publisher").text
mi.isbn = xmlroot.find(".//book/isbn13").text
if mi.isbn is None: ## let's try with isbn10 then
xmlroot.find(".//book/isbn").text
cover_url = xmlroot.find(".//book/image_url").text
# er, shall I download this cover...? and save it how ...?
print mi
self.results.append(mi)
results_num += int(root.find(".//results-end").text)
total_results = int(root.find(".//total-results").text)
print "fetched %i of %i results" % (results_num, total_results)
# if enough results, get out of loop
if results_num >= total_results:
break
else:
# otherwise, fetch next page
page += 1
|
|
|
|
|
|
#7 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,592
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Looks like your plugins cache has gotten corrupted somehow.
Go to preferences->advanced->misc and click open config directory. In there will be a file customize.py. Quit calibre and delete it. Then re-add the plugin and you should be OK. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Very disappointed with the way the tech is developing. | harryE123 | General Discussions | 164 | 10-01-2010 07:05 PM |
| Developing for the iPad? | phmadore | General Discussions | 7 | 04-09-2010 05:48 PM |
| I need help for developing | Smellyday | Kindle Developer's Corner | 1 | 11-28-2009 11:12 AM |
| iLiad iLiad Developing Conventions? | rudysplif | iRex Developer's Corner | 2 | 12-04-2007 10:52 AM |
| iLiad Developing Apps | Open Window | iRex Developer's Corner | 10 | 02-13-2007 11:49 AM |