-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from EnAccess/add-zotero-sync-script
Add Zotero sync script
- Loading branch information
Showing
6 changed files
with
10,841 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.12.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Datalayer | ||
|
||
This directory contains a small Python script to sync the Zotero Library of the [Co-Design toolkit](https://www.zotero.org/groups/4998453/humanitarian_energy_co-design_toolbox/library) into this repository. | ||
|
||
## Pre-requisites | ||
|
||
- [Poetry](https://python-poetry.org/) | ||
- [pyenv](https://github.com/pyenv/pyenv) | ||
- [Zotero](https://www.zotero.org/) Account and [API key](https://www.zotero.org/settings/keys/new) | ||
- (Optional) [direnv](https://direnv.net/) | ||
|
||
## Installation | ||
|
||
```sh | ||
poetry install | ||
``` | ||
|
||
Set environment variable `ZOTERO_API_KEY` to your previously configured API key. | ||
|
||
## Running the script | ||
|
||
```sh | ||
poetry run python datalayer.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import os | ||
|
||
from pyzotero import zotero | ||
|
||
ZOTERO_API_KEY = os.environ["ZOTERO_API_KEY"] | ||
|
||
|
||
def sync(): | ||
# https://www.zotero.org/groups/4998453/humanitarian_energy_co-design_toolbox/library | ||
zot = zotero.Zotero("4998453", "group", ZOTERO_API_KEY) | ||
items = zot.items() | ||
|
||
output_file = "../public/zotero_data.json" | ||
|
||
with open(output_file, "w") as file: | ||
json.dump(items, file, indent=2) | ||
|
||
print(f"Data has been written to {output_file}") | ||
|
||
|
||
if __name__ == "__main__": | ||
sync() |
Oops, something went wrong.