@@ -190,16 +190,41 @@ def data_01(self):
190190 Message with the results or recommendations to improve this indicator
191191 """
192192 # Search and download GBIF data
193- try :
194- auth = (
195- self .config ["gbif" ]["api_mail" ],
196- self .config ["gbif" ]["api_user" ],
197- self .config ["gbif" ]["api_pass" ],
198- )
199- download_dict = gbif_doi_download (self .item_id , auth = auth )
200- except Exception as e :
201- logger .debug (e )
202- return (0 , "" )
193+ short_name = None
194+ for key , e in self .metadata [
195+ self .metadata ["qualifier" ] == "alternateIdentifier"
196+ ].iterrows ():
197+ if "ipt.gbif" in e ["text_value" ]:
198+ short_name = e ["text_value" ].split ("r=" , 1 )[1 ]
199+ url = "https://ipt.gbif.es/archive.do?r=" + short_name
200+ logger .debug (url )
201+ # Descarga los datos del conjunto
202+ logger .debug ("Descarga" )
203+ if short_name is not None :
204+ download_dict = {}
205+ download_dict ["path" ] = f"/FAIR_eva/plugins/gbif/downloads/{ short_name } .zip"
206+ try :
207+ os .makedirs ("/FAIR_eva/plugins/gbif/downloads/" , exist_ok = True )
208+ with open (download_dict ["path" ], "wb" ) as f :
209+ # Itera sobre los bloques del archivo descargado
210+ for data in requests .get (
211+ url ,
212+ stream = True ,
213+ ).iter_content (chunk_size = 1024 ):
214+ f .write (data )
215+ except Exception as e :
216+ logger .debug (f"ERROR Downloading Data: { e } " )
217+ if not os .path .exists (download_dict ["path" ]):
218+ try :
219+ auth = (
220+ self .config ["gbif" ]["api_mail" ],
221+ self .config ["gbif" ]["api_user" ],
222+ self .config ["gbif" ]["api_pass" ],
223+ )
224+ download_dict = gbif_doi_download (self .item_id , auth = auth )
225+ except Exception as e :
226+ logger .debug (e )
227+ return (0 , "" )
203228
204229 # Calculates ICA
205230 logger .debug ("Calculo ICA" )
0 commit comments