1616import requests_cache
1717from rapidfuzz import fuzz
1818
19- import colrev .env .environment_manager
2019import colrev .exceptions as colrev_exceptions
2120import colrev .record .record_prep
2221import colrev .utils
@@ -329,15 +328,21 @@ def __init__(
329328 self ,
330329 * ,
331330 url : str ,
331+ email : str = "my@email.edu" ,
332332 rerun : bool = False ,
333333 cache : typing .Optional [bool ] = None ,
334334 ):
335335 assert url .startswith (self ._api_url )
336336 self .url = url
337337
338- _ , self .email = (
339- colrev .env .environment_manager .EnvironmentManager .get_name_mail_from_git ()
340- )
338+ self .email = email
339+ if email == "my@email.edu" :
340+ # warn
341+ print (
342+ "Warning: Using default email for Crossref API. "
343+ "Please set a valid email to comply with Crossref's polite usage policy."
344+ )
345+
341346 self .rerun = rerun
342347 # default: disable cache in CI; but allow explicit override
343348 if cache is None :
@@ -597,13 +602,12 @@ def _norm_doi(doi: str) -> str:
597602 return record_list
598603
599604
600- def query_doi (* , doi : str ) -> colrev .record .record_prep .PrepRecord :
605+ def query_doi (
606+ * , doi : str , email = "my@email.edu"
607+ ) -> colrev .record .record_prep .PrepRecord :
601608 """Get records from Crossref based on a doi query"""
602609
603610 try :
604- _ , email = (
605- colrev .env .environment_manager .EnvironmentManager .get_name_mail_from_git ()
606- )
607611 endpoint = Endpoint ("https://api.crossref.org/works/" + doi , email = email )
608612
609613 crossref_query_return = next (iter (endpoint ))
@@ -619,4 +623,4 @@ def query_doi(*, doi: str) -> colrev.record.record_prep.PrepRecord:
619623 except (requests .exceptions .RequestException , StopIteration ) as exc :
620624 raise colrev_exceptions .RecordNotFoundInPrepSourceException (
621625 msg = "Record not found in crossref (based on doi)"
622- ) from exc
626+ ) from exc
0 commit comments