๋ฒ๊ฑฐ๋กญ๊ฒ ํด์ ์ฃ์กํฉ๋๋ค๋ง, ์ ๋ ์ค๋ซ๋์ ๋ฌธ์ ์ ์ง๋ฉดํด ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ฌ์ฉํ์ฌ Zenode ์์ ๋์ฉ๋ ๋ฐ์ดํฐ ์ธํธ๋ฅผ ๋ค์ด๋ก๋ํ๋ ๊ฒ์ ์์ ์ ์ด์ง ์์ต๋๋ค. ๊ทธ๋์ 'wget'์ ์ฌ์ฉํ๋ ๊ฒ์ด ์๊ฐ๋์ง๋ง Issues ์ ์ ๊ณต๋ ์ ๊ทผ ๋ฐฉ์์ ๋ฐ๋์ ๋ ์คํจํ์ต๋๋ค.
์ด์ ๋ฌธ์ ์์ ๋ค์์ ์ฌ์ฉํฉ๋๋ค.
curl https://zenodo.org/api/records/3407840
REST API๊ฐ ์์ต๋๋ค.
https://zenodo.org/api/files/f0d7eb3a-9575-4297-8a9f-39564e383750/Center%28Left_Down%29.zip.001
ํ์ง๋ง REST API๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒ์ฒ๋ผ 404๊ฐ ๋ฐ์ํ์ต๋๋ค .
wget -r https://zenodo.org/api/files/f0d7eb3a-9575-4297-8a9f-39564e383750/Center%28Left_Down%29.zip.001
์ ์ข ๋์์ฃผ์๊ฒ ์ด์? ๊ณ ๋ง์!
์ด ๋ ์ฝ๋์ ํ์ผ์ ๊ณต๊ฐ์ ์ผ๋ก ์ฌ์ฉํ ์ ์๋ ์ ํ๋ ์ก์ธ์ค๋ก ์ค์ ๋์ด ์์ผ๋ฏ๋ก ์ก์ธ์คํ๋ ค๋ฉด ID๋ฅผ ํ์ธํ๊ธฐ ์ํ ์ก์ธ์ค ํ ํฐ์ด ํ์ํฉ๋๋ค. ์ฌ๊ธฐ์ ์์ฑํ๊ฑฐ๋ ํ์๋ ์ ์ฐจ๋ฅผ ๋ฐ๋ผ์ผ ํฉ๋๋ค.
์ค๋ฅ๊ฐ ์๋๋ฏ๋ก ๋ซ์ต๋๋ค.
๋น๊ณต๊ฐ ํ ํฐ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ฌด์์ ๋๊น? ์ด๋ค ์์ด๋์ด๋ผ๋? ์ ๋ง ๊ฐ์ฌํฉ๋๋ค
๋๋ ํ์ํด, ์๋ ์ฌ๋?
๋๋ ๊ถ๊ธํ๋ค
@thesby @keunwoochoi
ํ์ผ์ ๋ค์ด๋ก๋ํ๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๋ช
๋ น์ค ์์ฒด์์
1- ๊ฐ์ธ ํ ํฐ ํ๋(์ด๋ฏธ ๊ฐ์ง๊ณ ์์ ์ ์์)
2- ๋ค์ ๋ช
๋ น์ ์คํํ์ญ์์ค
curl --cookie zenodo-cookies.txt "https://zenodo.org/record/1117372?token=<your token here>"
ํด๋น ๋ ์ฝ๋ ๋ฒํธ 1117372๋ฅผ ์ ์ ํ ๊ฒ์ผ๋ก ๊ต์ฒดํ์ญ์์ค.
์ฟ ํค ํ์ผ์ ์์ฑํ ํ
์ด์ ๋ธ๋ผ์ฐ์ ์์ ๋ค์ด๋ก๋ ๋ฒํผ์ ๋ง์ฐ์ค ์ค๋ฅธ์ชฝ ๋ฒํผ์ผ๋ก ํด๋ฆญํ๊ณ URL์ ๋ณต์ฌํ์ญ์์ค.
https://zenodo.org/record/1117372/files/musdb18.zip?download=1 ๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
์ง๊ธ ,
ํฐ๋ฏธ๋์์ ์ด ๋ช ๋ น์ ์คํํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
curl --cookie zenodo-cookies.txt "https://zenodo.org/record/1117372/files/musdb18.zip?download=1" --output musdb18.zip
๋ค์ด๋ก๋ ๋งํฌ๋ฅผ ํน์ ๋ค์ด๋ก๋ URL๋ก ๊ต์ฒด
๋ค์ด๋ก๋๋ฅผ ์์ํด์ผ ํฉ๋๋ค.
--output musdb18.zip์ ํ์ผ ์ด๋ฆ์ ๋ฐ๊พธ์ญ์์ค.
์ํ๋ ์ ์ ํ ํ์ผ ์ด๋ฆ์ผ๋ก
์ด๊ฒ์ ๋๋ฅผ ์ํด ์๋ํ๋ ๋ฐฉ๋ฒ์ ๋๋ค.
๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ฉด ์๋ ค์ฃผ์ญ์์ค.
์ข์ ํ๋ฃจ ๋์ธ์!
์ฟ ํค ์ ๊ทผ ๋ฐฉ์์ ๋ฌธ์ ๊ฐ ์์๊ธฐ ๋๋ฌธ์ ๋์ zenodo API ์ ๊ทผ ๋ฐฉ์(Python์์)์ ์ฌ์ฉํ์ต๋๋ค.
๋จผ์ ๊ฐ์ธ ์ก์ธ์ค ํ ํฐ (๊ฐ๋ฐ์ ์์ฉ ํ๋ก๊ทธ๋จ ์๋)์ ๋ง๋ค๊ณ ๋ณ์ ACCESS_TOKEN
ํ ๋นํ์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ด ๊ธฐ๋ก์์ ๋ค์ด๋ก๋ํ ์ ์๋ ๋ชจ๋ ํ์ผ์ ์ฟผ๋ฆฌํ์ต๋๋ค.
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)
์ด์ ๋ค์ด๋ก๋ํ๋ ค๋ ํ์ผ์ URL๊ณผ ์ด๋ฆ(์: ํค)์ด ์์ผ๋ฏ๋ก requests.get
๋ฅผ ์ฌ์ฉํ์ฌ ํ์ผ์ ๋ค์ด๋ก๋ํ๊ณ ํ์ผ์ ์ ์ฅํ ์ ์์ต๋๋ค.
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)
๋๋ ์ด๊ฒ์ ์๋ํ๊ณ ๊ทธ๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค.
https://gist.github.com/slint/d47fe5628916d14b8d0b987ac45aeb66#file -zenodo-restricted-curl-sh-L26
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๋ ์ด๊ฒ์ ์๋ํ๊ณ ๊ทธ๊ฒ์ ๋๋ฅผ ์ํด ์ผํ์ต๋๋ค.
https://gist.github.com/slint/d47fe5628916d14b8d0b987ac45aeb66#file -zenodo-restricted-curl-sh-L26