Skip to content

Commit 19448d2

Browse files
committed
doc: update doc and code example for getArchivefileUrls
1 parent 195b139 commit 19448d2

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ onc.downloadArchivefile("AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg", ove
164164
You can use the method `downloadArchivefile()` as above to download individual files or the method `downloadDirectArchivefile()`
165165
to download all the files that match your filters.
166166

167+
Alternatively, if you prefer using a download manager like [aria2](https://aria2.github.io/) or [Free Download Manager](https://www.freedownloadmanager.org/), `getArchivefileUrls` and `getArchivefileUrl` can return the download URLs of the archivefile
168+
without downloading the files.
169+
167170
Check more on the _[archive file download methods guide](https://oceannetworkscanada.github.io/Oceans3.0-API/API_Guide.html#archive-file-download-methods)_
168171
and _[code examples](https://oceannetworkscanada.github.io/api-python-client/Code_Examples/Download_Archived_Files.html)_.
169172

doc/source/Code_Examples/Download_Archived_Files.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ onc.getArchivefile(params)
110110

111111
## Download archived files that match the parameters
112112

113-
Download all "mat" files from a hydrophone at Straight of Georgia East (_locationCode_:"**SEVIP**") using the parameter above.
113+
Download all "mat" files from a hydrophone at Straight of Georgia East (_locationCode_:"**SEVIP**").
114114

115115
```python
116116
params = {
@@ -127,3 +127,57 @@ onc.downloadDirectArchivefile(params)
127127
# onc.getDirectFiles(params)
128128

129129
```
130+
131+
## Download archived files using a download manager
132+
133+
Return the download URLs from a hydrophone at Straight of Georgia East (_locationCode_:"**SEVIP**").
134+
135+
```python
136+
params = {
137+
"deviceCategoryCode": "HYDROPHONE",
138+
"locationCode": "SEVIP",
139+
"extension": "mat",
140+
"dateFrom": "2018-10-05T00:00:00.000Z",
141+
"dateTo": "2018-10-05T00:10:00.000Z",
142+
}
143+
144+
# print is necessary to render the newline character
145+
print(onc.getArchivefileUrls(params, joinedWithNewline=True))
146+
```
147+
148+
After running the code, a list of URLs will be printed.
149+
150+
```
151+
https://data.oceannetworks.ca/api/archivefile/download?filename=ICLISTENHF1560_20181004T235903.000Z-spect.mat&token=Your_TOKEN
152+
https://data.oceannetworks.ca/api/archivefile/download?filename=ICLISTENHF1560_20181005T000403.000Z-spect.mat&token=Your_TOKEN
153+
https://data.oceannetworks.ca/api/archivefile/download?filename=ICLISTENHF1560_20181005T000903.000Z-spect.mat&token=Your_TOKEN
154+
```
155+
156+
At this point, you can open your favorite download manager, paste the URLs, and start the download.
157+
Most modern download managers support batch download, probably from a multi-line text input, the clipboard or a file.
158+
159+
Here is an example of using a popular open source download manager -- aria2.
160+
161+
### webui-aria2
162+
163+
[aria2](https://aria2.github.io/) is a lightweight multi-protocol & multi-source command-line download utility.
164+
[webui-aria2](https://github.com/ziahamza/webui-aria2) is a web interface to interact with aria2.
165+
Refer to the webui-aria2 [README](https://github.com/ziahamza/webui-aria2?tab=readme-ov-file#webui-aria2) file
166+
for more information on how to use the tool.
167+
168+
1. Install aria2 by downloading it from the [release](https://github.com/aria2/aria2/releases)
169+
(or use your package manager if you are on Linux), extract the zip file,
170+
and start the server by running
171+
172+
```shell
173+
./aria2c --enable-rpc --rpc-listen-all
174+
```
175+
176+
2. Go to <https://ziahamza.github.io/webui-aria2> (or you can download this repository and open index.html
177+
from docs folder), change "Enter the host" field to "localhost" in the setting, and save the settings.
178+
Sometimes you need to also refresh the page.
179+
![Aria2c host change.png](../_static/Code_Examples/webui-aria2c-host.png)
180+
181+
3. Click "Add" -> "By URIs" in the menu. Fill in the URLs and start the download.
182+
You can also customize the download in the "Download settings" like changing the download directory.
183+
![Aria2c add URLs.png](../_static/Code_Examples/webui-aria2c-add-uri.png)
144 KB
Loading
120 KB
Loading

0 commit comments

Comments
 (0)