File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -67,12 +67,17 @@ async def download_articles(
6767 async def _runner () -> list [ArticleContent ]:
6868 results : list [ArticleContent ] = []
6969 for record in records :
70- article = await _download_record (
71- record = record ,
72- client = sci_client ,
73- cache = cache ,
74- cache_namespace = cache_namespace ,
75- )
70+ try :
71+ article = await _download_record (
72+ record = record ,
73+ client = sci_client ,
74+ cache = cache ,
75+ cache_namespace = cache_namespace ,
76+ )
77+ except Exception :
78+ continue
79+ if article is None :
80+ continue
7681 results .append (article )
7782 return results
7883
@@ -87,7 +92,7 @@ async def _download_record(
8792 client : ScienceDirectClient ,
8893 cache : Any | None ,
8994 cache_namespace : str ,
90- ) -> ArticleContent :
95+ ) -> ArticleContent | None :
9196 doi = (record .get ("doi" ) or "" ).strip ()
9297 pmid = (record .get ("pmid" ) or "" ).strip ()
9398
@@ -117,8 +122,11 @@ async def _download_record(
117122 article .metadata .setdefault ("identifier_lookup" , dict (record ))
118123 return article
119124
120- assert last_error is not None # Should exist when all attempts fail.
121- raise last_error
125+ if last_error is not None and last_error .response .status_code == 404 :
126+ return None
127+ if last_error is not None :
128+ raise last_error
129+ return None
122130
123131
124132async def _download_identifier (
You can’t perform that action at this time.
0 commit comments