Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Unhandled exception: <b>AttributeError</b>:object has no attribute 'id' (http://opds.oreilly.com/opds/) #28

Closed
ruscourier opened this issue Oct 3, 2020 · 6 comments

Comments

@ruscourier
Copy link

calibre, version 5.1.0
ERROR: Unhandled exception: AttributeError:object has no attribute 'id'

calibre 5.1 embedded-python: True is64bit: True
macOS-10.15.7-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '19.6.0', 'Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64')
Python 3.8.5
OSX: ('10.15.7', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: OPDS Client (1, 0, 0)
Traceback (most recent call last):
File "site-packages/feedparser.py", line 398, in getattr
File "site-packages/feedparser.py", line 356, in getitem
KeyError: 'id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre_plugins.opds_client.main", line 182, in download_opds
File "calibre_plugins.opds_client.model", line 97, in downloadOpdsCatalog
File "calibre_plugins.opds_client.model", line 143, in makeMetadataFromParsedOpds
File "calibre_plugins.opds_client.model", line 150, in opdsToMetadata
File "site-packages/feedparser.py", line 400, in getattr
AttributeError: object has no attribute 'id'

@ruscourier
Copy link
Author

oreilly

@steinarb
Copy link
Owner

steinarb commented Oct 3, 2020

FWIW see #12

(I sort of gave up on handling OPDS feeds other than calibre back in October 2015, because the code got bogged down in handling special cases...)

But this looks like a simple one to guard against (unless I actually need the id...? I haven checked), so I will try.

@steinarb
Copy link
Owner

steinarb commented Oct 4, 2020

@ruscourier I have pushed a fix for the stack trace which stops the code from failing if the id isn't present.

I'm not sure what effect an empty string id will have on the results. Even with the fix, the OPDS URL comes up empty, which is probably because of what I ran into trying to fix #12 i.e. there are many ways of creating OPDS and parsing them all is hard.

The OPDS respose from the URL in the screen shot, does have id both on the top element and in the entries in the list of entries:

<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://opds.oreilly.com/opds/</id>
  <link rel="self" href="/opds/" type="application/atom+xml;profile=opds-catalog" />
  <link rel="start" href="/opds/" type="application/atom+xml;profile=opds-catalog" />
  <title>O'Reilly Media Catalog</title>
  <updated>2010-01-10T10:01:10Z</updated>
  <author>
    <name>O'Reilly Media</name>
  </author>
  <entry>
      <title>New Releases</title>
      <link href="/opds/new" rel="http://opds-spec.org/sort/new" type="application/atom+xml;profile=opds-catalog" />
      <updated>2010-01-10T10:01:01Z</updated>
      <id>http://opds.oreilly.com/new</id>
    </entry>
  <entry>
      <title>Bestsellers</title>
      <link href="/opds/best" rel="http://opds-spec.org/sort/popular" type="application/atom+xml;profile=opds-catalog" />
      <updated>2010-01-10T10:01:01Z</updated>
      <id>http://opds.oreilly.com/best</id>
    </entry>
  <entry>
      <title>Alphabetical</title>
      <link href="/opds/alpha" rel="subsection" type="application/atom+xml;profile=opds-catalog" />
      <updated>2010-01-10T10:01:01Z</updated>
      <id>http://opds.oreilly.com/alpha</id>
    </entry>
</feed>

Possibly the required recursion that is the problem here. I think the fix branch tries to recurse into child lists until it actually finds books...? (but it's been 5 years so I don't recall exactly what I did...)

@steinarb
Copy link
Owner

steinarb commented Oct 4, 2020

@ruscourier The feed in the screenshot actually works. I've just tried it. Couldn't download any books listed though. Suspect that requires some form of authentication...?

@ruscourier
Copy link
Author

Yes, I think a form of authentication is required because I have a similar situation with downloading books - they do not download and the process falls off by timeout

@steinarb
Copy link
Owner

steinarb commented Oct 5, 2020

Ah well, see #9 and #14

Pull requests are welcome! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants