Skip to content

Commit

Permalink
Merge pull request #9769 from fakegithub01/author
Browse files Browse the repository at this point in the history
Move author identifiers to version-controlled YAML file
  • Loading branch information
jimchamp authored Aug 27, 2024
2 parents 9ad3d49 + 9b16da4 commit 9c4db66
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 6 deletions.
62 changes: 62 additions & 0 deletions openlibrary/plugins/openlibrary/config/author/identifiers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
identifiers:
- label: Amazon ID
name: amazon
notes: Should be something like B000AQ0842
url: https://www.amazon.com/-/e/@@@
website: https://www.amazon.com
- label: BookBrainz
name: bookbrainz
url: https://bookbrainz.org/author/@@@
website: https://bookbrainz.org
- label: GoodReads
name: goodreads
notes: Should be a number
url: https://www.goodreads.com/author/show/@@@
- label: ISNI
name: isni
notes: ''
url: https://isni.org/isni/@@@
website: https://isni.org/
- label: Inventaire
name: inventaire
notes: two formats depending on if the author exists in wikidata, wd:Q42 or inv:914ad8068b8711ead0cc2efbed56e53c
url: https://inventaire.io/entity/@@@
website: https://inventaire.io/
- label: LibraryThing
name: librarything
notes: Should be something like kingstephen-1
url: https://www.librarything.com/author/@@@
- label: LibriVox
name: librivox
notes: Should be a number
url: https://librivox.org/author/@@@
website: https://librivox.org
- label: MusicBrainz
name: musicbrainz
url: https://musicbrainz.org/artist/@@@
website: https://musicbrainz.org
- label: Project Gutenberg
name: project_gutenberg
notes: Should be a number
url: https://www.gutenberg.org/ebooks/author/@@@
website: https://www.gutenberg.org
- label: Storygraph
name: storygraph
notes: eg 50b7fbd9-84ac-450d-b2ed-78c861d4ef00
url: https://app.thestorygraph.com/authors/@@@
website: https://www.thestorygraph.com/
- label: VIAF
name: viaf
notes: ''
url: https://viaf.org/viaf/@@@
website: https://viaf.org
- label: Wikidata
name: wikidata
notes: ''
url: https://www.wikidata.org/wiki/@@@
website: https://wikidata.org
- label: YouTube
name: youtube
notes: Link to the author's official YouTube channel
url: https://www.youtube.com/@@@
website: https://www.youtube.com
15 changes: 9 additions & 6 deletions openlibrary/plugins/upstream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,13 +1223,16 @@ def _get_author_config():
The results are cached on the first invocation.
Any changes to /config/author page require restarting the app.
"""
thing = web.ctx.site.get('/config/author')
if hasattr(thing, "identifiers"):
identifiers = [Storage(t.dict()) for t in thing.identifiers if 'name' in t]
else:
identifiers = {}
# Load the author config from the author.yml file in the author directory
with open(
'openlibrary/plugins/openlibrary/config/author/identifiers.yml'
) as in_file:
id_config = yaml.safe_load(in_file)
identifiers = [
Storage(id) for id in id_config.get('identifiers', []) if 'name' in id
]

return Storage(identifiers=identifiers)


Expand Down

0 comments on commit 9c4db66

Please sign in to comment.