Add id_from_url() to the Google metadata source

This commit is contained in:
Charles Haley 2022-04-14 18:14:30 +01:00
parent 84284c3fe1
commit e0fe581d1d

View File

@ -198,7 +198,16 @@ class GoogleBooks(Source):
goog = identifiers.get('google', None)
if goog is not None:
return ('google', goog, 'https://books.google.com/books?id=%s' % goog)
# }}}
def id_from_url(self, url): # {{{
url_pattern = '(?:http|https)://books\.google\.com/books\?id=(?P<id_>.+)'
url_pattern = re.compile(url_pattern)
id_ = url_pattern.search(url).group('id_')
if id_:
return ('google', id_)
else:
return None
# }}}
def create_query(self, title=None, authors=None, identifiers={}, capitalize_isbn=False): # {{{