fix glue resolution

pull/43/head
eric 2017-08-07 21:46:21 -04:00
parent 489790fa2f
commit f9d31b0f51
2 changed files with 13 additions and 6 deletions

View File

@ -334,13 +334,13 @@ def loaded_book_ok(book, work, edition):
ID_URLPATTERNS = {
'goog': re.compile(r'[\./]google\.com/books\?.*id=([a-zA-Z0-9\-_]{12})'),
'olwk': re.compile(r'[\./]openlibrary\.org(/works/OL\d{1-8}W)'),
'gdrd': re.compile(r'[\./]goodreads\.com/book/show/(\d{1-8})'),
'ltwk': re.compile(r'[\./]librarything\.com/work/(\d{1-8})'),
'oclc': re.compile(r'\.worldcat\.org/.*oclc/(\d{8-12})'),
'olwk': re.compile(r'[\./]openlibrary\.org(/works/OL\d{1,8}W)'),
'gdrd': re.compile(r'[\./]goodreads\.com/book/show/(\d{1,8})'),
'ltwk': re.compile(r'[\./]librarything\.com/work/(\d{1,8})'),
'oclc': re.compile(r'\.worldcat\.org/.*oclc/(\d{8,12})'),
'doi': re.compile(r'[\./]doi\.org/(10\.\d+/\S+)'),
'gtbg': re.compile(r'[\./]gutenberg\.org/ebooks/(\d{1-6})'),
'glue': re.compile(r'[\./]unglue\.it/work/(\d{1-7})'),
'gtbg': re.compile(r'[\./]gutenberg\.org/ebooks/(\d{1,6})'),
'glue': re.compile(r'[\./]unglue\.it/work/(\d{1,7})'),
}
def ids_from_urls(url):

View File

@ -99,6 +99,13 @@ def get_edition_for_id(id_type, id_value):
if edition:
return edition
if identifiers.has_key('glue'):
try:
work = models.safe_get_work(identifiers['glue'])
return work.preferred_edition
except:
pass
if identifiers.has_key('http'):
edition = add_by_webpage(identifiers['http'])
return edition