Python script to register 4TU.ResearchData dois from Figshare in Datacite, by Egbert Gramsbergen.

The script uses APIs of Figshare (https://docs.figshare.com/) and Datacite (https://support.datacite.org/docs/mds-api-guide).

The script was originally made to run ad-hoc on a local computer and was later adapted to also run daily on a server. Apart from the daily update, there are options to registrate specific dois, e.g. based on a query.

The dirs datacite and modules can be placed anywhere. The location of modules must be added to the PYTONPATH. See comments in doi-reg.py for details.
To do the doi registration, run datacite/doi-reg.py.
modules/fig/utils.py contains a lot of stuff used by a large variety of scripts. Only a small part is actually used here.
The metadata sent to datacite contains custom metadata that are specific for 4TU (current version and older version that is still present on older datasets). A significant part of datacite.py is devoted to dealing with these custom metadata, and custom dois from our pre_Figshare era.
The dois resolve to short urls, not the standard long ones that include the title (i.e. "/Datatset/This_is_the_title/" is replaced by "/_/").

Adapt modules/fig/auth.py with your own Figshare API key and Datacite credentials for authorization.
To adapt for other repositories with other custom metadata, datacite.py will also need modification.
Tested with python versions 3.8.5 and 3.10.1.