biigle / volumes

:m: BIIGLE module to create, edit and explore image volumes
0 stars 0 forks source link

Dropbox automatic image discovery #56

Closed dlangenk closed 5 years ago

dlangenk commented 5 years ago

We can use a regex to automatically discover all images inside a shared dropbox folder and there allow to easily use dropbox as storage solution.

Python script:

import requests
import re

url = 'https://www.dropbox.com/sh/ky5f7kohs1rxr1h/AAArN861GFjabaGTxvqPJsgoa?dl=0'

# get everything on the shared page
r = requests.get(url)

# find all links
results = re.findall('https://www.dropbox.com/sh/\S+?\.(?:jpg|jpeg|gif|png)\?dl=0', r.text)

# remove duplicates
print list(set(results))

PHP script (you can probably improve it but at least it works)

$var=file_get_contents("https://www.dropbox.com/sh/ky5f7kohs1rxr1h/AAArN861GFjabaGTxvqPJsgoa?dl=0");
preg_match_all("(https://www.dropbox.com/sh/\S+?\.(?:jpg|jpeg|gif|png)\?dl=0)",$var,$matches);
print_r(str_replace("dl=0","raw=1",array_unique($matches[0])));
mzur commented 5 years ago

We decided not to officially support Dropbox as it is not ideal for storage of remote volumes. It is cumbersome to set up, very slow, tracks every request from BIIGLE and might violate the Dropbox terms of use.