Zenodo: Use Commend Line to download the file from Zenode

Created on 16 Oct 2019  ·  8Comments  ·  Source: zenodo/zenodo

Sorry to bother you, but I have faced with a problem for a long time. It's not stable for me to download the large dataset from Zenode using browser, however. So use 'wget' comes to my mind, but when I follow the approach provided in Issues, I have failed.

From the former Issue, I use:

curl  https://zenodo.org/api/records/3407840

I got the REST API:

https://zenodo.org/api/files/f0d7eb3a-9575-4297-8a9f-39564e383750/Center%28Left_Down%29.zip.001

But I got 404 just like not using the REST API.

wget -r https://zenodo.org/api/files/f0d7eb3a-9575-4297-8a9f-39564e383750/Center%28Left_Down%29.zip.001

Could you help me out? Thx!

Most helpful comment

I tried this and it worked for me:
https://gist.github.com/slint/d47fe5628916d14b8d0b987ac45aeb66#file-zenodo-restricted-curl-sh-L26

All 8 comments

Since the files of this record are set to restricted access they are not publicly available, to access them you would need an access token to verify your identity, which you can create here or you should follow the procedure displayed .

Closing this since it is not an error.

how to use the privated token? Any idea? Thaks very much

I need it too, anyone known ?

i'm curious too

@thesby @keunwoochoi

Here are the steps to download the files
from commandline itself

1- Accquire the personal token (which you probably already have)
2- run the following commands

curl --cookie zenodo-cookies.txt "https://zenodo.org/record/1117372?token=<your token here>"
replace that record number 1117372 with your appropriate one

Once you have generated the cookie file ,
now just get on your browser , right click on the download button and copy its url

it should look something like https://zenodo.org/record/1117372/files/musdb18.zip?download=1

now ,

just run this command on your terminal ,

curl --cookie zenodo-cookies.txt "https://zenodo.org/record/1117372/files/musdb18.zip?download=1" --output musdb18.zip

replace the download link with your particular download url
and it should start downloading ,

and replace the filename on --output musdb18.zip

with the appropriate file name you want

this is the method that works for me ,

Let me know if you face any issues,
Have a great day !

I was having trouble with the cookies approach, so instead I used the zenodo API approach (in Python).

First, I created a Personal access tokens (NOT Developer Applications), and assigned it to my variable ACCESS_TOKEN. Then I queried all the files available to download in my record:

import requests

ACCESS_TOKEN = "replace this with your access token"
record_id = "replace this with your record"

r = requests.get(f"https://zenodo.org/api/records/{record_id}", params={'access_token': ACCESS_TOKEN})
download_urls = [f['links']['self'] for f in r.json()['files']]
filenames = [f['key'] for f in r.json()['files']]

print(r.status_code)
print(download_urls)

Now that I have the urls of the files I want to download as well as their name (i.e. key), I can just download them with requests.get and save them to a file:

for filename, url in zip(filenames, download_urls):
    print("Downloading:", filename)
    r = requests.get(url, params={'access_token': ACCESS_TOKEN})
    with open(filename, 'wb') as f:
        f.write(r.content)

I tried this and it worked for me:
https://gist.github.com/slint/d47fe5628916d14b8d0b987ac45aeb66#file-zenodo-restricted-curl-sh-L26

Was this page helpful?
0 / 5 - 0 ratings