acdh-transkribus-utils
A python package providing some utility functions for interacting with the Transkribus-API
Installation
pip install acdh-transkribus-utils
Usage
Authentication
Set Transkribus-Credentials as environment variables:
export TRANSKRIBUS_USER=some@mail.com
export TRANSKRIBUS_PASSWORD=verysecret
(or create a file called env.secret
similar to env.dummy
and run source export_env_variables.sh
)
you can pass in your credentials also as params e.g.
import os
from transkribus_utils.transkribus_utils import ACDHTranskribusUtils
tr_user = os.environ.get("TRANSKRIBUS_USER")
tr_pw = os.environ.get("TRANSKRIBUS_PASSWORD")
client = ACDHTranskribusUtils(user=tr_user, password=tr_pw)
List all collections
collections = client.list_collections()
for x in collections[-7:]:
print(x["colId"], x["colName"])
List all documents from a given collection
col_id = 142911
documents = client.list_docs(col_id)
n = -3
for x in documents[n:]:
print(x["docId"], x["title"], x["author"], x["nrOfPages"])
Download METS files from Collection
from transkribus_utils.transkribus_utils import ACDHTranskribusUtils
COL_ID = 51052
client = ACDHTranskribusUtils()
client.collection_to_mets(COL_ID)
client.collection_to_mets(COL_ID, file_path='./foo')
client.collection_to_mets(COL_ID, filter_by_doc_ids=[230161, 230155])