#!/usr/bin/python3importdropboximporturllib.requestfromtqdmimporttqdm# https://www.dropbox.com/developers/apps# `Choose the type of access you need`:# - `App folder`# `Permissions`:# - `files.metadata.read`# Then `Settings` > `Generate access token`.ACCESS_TOKEN='CENSORED'# May have 2 random parts delimited by `/` or just have a second part being `h`.FOLDER='CENSORED'RLKEY='CENSORED'dbx=dropbox.Dropbox(ACCESS_TOKEN)BASE_URL=f'https://www.dropbox.com/scl/fo/{FOLDER}'url=f'{BASE_URL}?rlkey={RLKEY}'shared_link=dropbox.files.SharedLink(url=url)result=dbx.files_list_folder(path='',shared_link=shared_link)forentryintqdm(result.entries):entryName=entry.nameifentryName.endswith('.ARW'):downloadUrl=f'{BASE_URL}/{entryName}?rlkey={RLKEY}&dl=1'# Avoid file injection.fileName=''.join(characterforcharacterinentryNameif(character.isalnum()orcharacter=='.'))urllib.request.urlretrieve(downloadUrl,fileName)
`download_dropbox.py`:
```py
#!/usr/bin/python3
import dropbox
import urllib.request
from tqdm import tqdm
# https://www.dropbox.com/developers/apps
# `Choose the type of access you need`:
# - `App folder`
# `Permissions`:
# - `files.metadata.read`
# Then `Settings` > `Generate access token`.
ACCESS_TOKEN = 'CENSORED'
# May have 2 random parts delimited by `/` or just have a second part being `h`.
FOLDER = 'CENSORED'
RLKEY = 'CENSORED'
dbx = dropbox.Dropbox(ACCESS_TOKEN)
BASE_URL = f'https://www.dropbox.com/scl/fo/{FOLDER}'
url = f'{BASE_URL}?rlkey={RLKEY}'
shared_link = dropbox.files.SharedLink(url = url)
result = dbx.files_list_folder(path = '', shared_link=shared_link)
for entry in tqdm(result.entries):
entryName = entry.name
if entryName.endswith('.ARW'):
downloadUrl = f'{BASE_URL}/{entryName}?rlkey={RLKEY}&dl=1'
# Avoid file injection.
fileName = ''.join(character for character in entryName if (character.isalnum() or character == '.'))
urllib.request.urlretrieve(downloadUrl, fileName)
```
Related to [Benjamin_Loison/wget/issues/1](https://codeberg.org/Benjamin_Loison/wget/issues/1).
Above script seems limited to 500 entries. To download all Dropbox files can use:
```bash
wget https://CENSORED.dl.dropboxusercontent.com/zip_download_get/CENSORED
```
Related to [issues/59#issue-1243](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/59#issue-1243).
Traceback (most recent call last):
File "./download_dropbox.py", line 25, in <module>
result = dbx.files_list_folder(path = '', shared_link=shared_link, limit = 10 ** 6)
File "/home/bloison/.local/lib/python3.6/site-packages/dropbox/base.py", line 2148, in files_list_folder
include_non_downloadable_files)
File "/home/bloison/.local/lib/python3.6/site-packages/dropbox/files.py", line 3678, in __init__
self.limit = limit
File "/home/bloison/.local/lib/python3.6/site-packages/stone/backends/python_rsrc/stone_base.py", line 81, in __set__
value = self.validator.validate(value)
File "/home/bloison/.local/lib/python3.6/site-packages/stone/backends/python_rsrc/stone_validators.py", line 652, in validate
return self.validator.validate(val)
File "/home/bloison/.local/lib/python3.6/site-packages/stone/backends/python_rsrc/stone_validators.py", line 172, in validate
% (val, self.minimum, self.maximum))
stone.backends.python_rsrc.stone_validators.ValidationError: 1000000 is not within range [1, 2000]
print(len(result.entries))
1282
```python
help(dbx.files_list_folder)
```
```python
result = dbx.files_list_folder(path = '', shared_link=shared_link, limit = 2_000)
```
```
Traceback (most recent call last):
File "./download_dropbox.py", line 25, in <module>
result = dbx.files_list_folder(path = '', shared_link=shared_link, limit = 10 ** 6)
File "/home/bloison/.local/lib/python3.6/site-packages/dropbox/base.py", line 2148, in files_list_folder
include_non_downloadable_files)
File "/home/bloison/.local/lib/python3.6/site-packages/dropbox/files.py", line 3678, in __init__
self.limit = limit
File "/home/bloison/.local/lib/python3.6/site-packages/stone/backends/python_rsrc/stone_base.py", line 81, in __set__
value = self.validator.validate(value)
File "/home/bloison/.local/lib/python3.6/site-packages/stone/backends/python_rsrc/stone_validators.py", line 652, in validate
return self.validator.validate(val)
File "/home/bloison/.local/lib/python3.6/site-packages/stone/backends/python_rsrc/stone_validators.py", line 172, in validate
% (val, self.minimum, self.maximum))
stone.backends.python_rsrc.stone_validators.ValidationError: 1000000 is not within range [1, 2000]
```
```python
print(len(result.entries))
```
```
1282
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
download_dropbox.py:Related to Benjamin_Loison/wget/issues/1.
Above script seems limited to 500 entries. To download all Dropbox files can use:
Related to issues/59#issue-1243.