#!/usr/bin/env cached-nix-shell #!nix-shell -i python3 -p "python3.withPackages(ps: with ps; [ ps.flask ps.requests ])" from flask import Flask, redirect import requests app = Flask(__name__) def get_files(uuid, password): r = requests.get( "https://www.odrive.com/rest/weblink/list_folder", params={"weblinkUri": f"/{uuid}", "password": password}, ) return dict( (item["name"], item["downloadUrl"]) for item in r.json()["data"]["items"] ) @app.route("/") def help(): return """ rclone proxy for odrive

rclone proxy for odrive

Fill the two fields with the UUID (the part after https://www.odrive.com/s/) and the access password. You will be redirected to the proxied directory listing. Point rclone at that URL and it should be able to download the files (rclone copy --http-url "YOUR_URL_HERE" :http: remote:bucket).

""" @app.route("///") def index(uuid, password): res = f'Index of /{uuid}

Index of /{uuid}

'
    for name, url in get_files(uuid, password).items():
        res += f'{name}\n'
    res += "
" return res @app.route("///") def file(uuid, password, name): return redirect(get_files(uuid, password)[name]) app.run()