sharefetch
Download a SharePoint Online or OneDrive for Business folder tree to a local directory, resumably and with content-level verification.
$ sharefetch "https://contoso.sharepoint.com/sites/Example/Shared Documents/Logs" --dest D:/archive
INFO sharefetch.cli To sign in, use a web browser to open the page https://login.microsoft.com/device and enter the code J7QK4RN2P to authenticate.
INFO sharefetch.cli signed in as user@contoso.com
INFO sharefetch.cli resolved to the Shared Documents library, folder 'Logs'
INFO sharefetch.cli enumeration complete: 15 file(s) in 0 folder(s), 11049892 byte(s)
INFO sharefetch.cli Logs/Q3 Summary.pdf: starting, 2939254 byte(s)
INFO sharefetch.cli Logs/Q3 Summary.pdf: complete, verification passed
INFO sharefetch.cli Logs/Change Register.xlsx: complete, verification passed
INFO sharefetch.cli run finished: 15 transferred, 0 already present, 0 skipped, 0 failed, 15 verified, 11049892 byte(s) transferred
INFO sharefetch.cli manifest: D:\archive\manifest.csv
Installation
$ pip install sharefetch
Python 3.10 or later. Windows is the target platform, because path handling and the token cache are Windows-specific.
From a clone:
$ git clone https://github.com/Indspl0it/sharefetch.git
$ cd sharefetch
$ pip install -e .
Two commands are installed, sharefetch for the terminal and sharefetch-gui for a window.
Usage
The folder URL from the browser address bar is the only argument.
$ sharefetch "https://contoso.sharepoint.com/sites/Example/Shared Documents/Logs"
A device code appears on the first run. Entering it at the verification page on any device starts the transfer. Later runs use the cached token and print no code.
Choose a destination and slow the transfer down:
$ sharefetch "<url>" --dest D:/archive --delay 2 --limit-rate 500
Report what a run would transfer, without transferring it:
$ sharefetch "<url>" --dry-run
Take part of a tree:
$ sharefetch "<url>" --include "*.pdf" --exclude "*/Archive/*" --max-depth 2
Re-check an existing download, without touching the network:
$ sharefetch "<url>" --dest D:/archive --verify-only
Run it again after an interruption. It reconciles against the disk, resumes the partial file from where it stopped, and skips everything already verified:
$ sharefetch "<url>" --dest D:/archive
Accepted URLs
Six forms are accepted, so whichever one the browser produced will work.
# library view with an id parameter
https://contoso.sharepoint.com/sites/Example/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2FExample%2FShared%20Documents%2FLogs
# direct folder path
https://contoso.sharepoint.com/sites/Example/Shared Documents/Logs
# teams-backed site
https://contoso.sharepoint.com/teams/Workgroup/Shared Documents/Notes
# subsite
https://contoso.sharepoint.com/sites/Parent/Child/Shared Documents/Reports
# personal OneDrive
https://contoso-my.sharepoint.com/personal/user_contoso_com/Documents/Archive
# sharing link, which needs --dest
https://contoso.sharepoint.com/:f:/s/Example/EhT7abc
Command line options
$ sharefetch <url> [options]
# where the tree lands
--dest DIR # default: a folder named after the addressed folder
# required for a sharing link
--ignore-free-space # skip the capacity check made before transferring
# network behaviour
--connections N # 1 or 2, higher is rejected at parse time (default: 1)
--delay SECONDS # pause between requests, 0.0 to 60.0, shared by
# every worker (default: 0.5)
--limit-rate KBPS # transfer ceiling in KB/s (default: none)
--chunk-size KIB # read size, 64 to 4096 (default: 256)
# what to transfer
--include GLOB # only items matching the glob, repeatable
--exclude GLOB # drop matching items, applied after --include
--max-depth N # 0 is the addressed folder alone (default: unlimited)
# run mode
--resume # continue from the state file (default)
--restart # transfer every item again, removing nothing
--dry-run # enumerate and report, writing no file content
--verify-only # check the tree on disk, no sign-in and no network
# sign-in
--reauth # ignore the cached token, force a new device code
--tenant ID # tenant GUID or domain (default: organizations)
--client-id GUID # application to sign in as
# (default: d3590ed6-52b3-4102-aeff-aad2292ab01c,
# a Microsoft first-party public client)
# output
--log-file PATH # write the log here as well as to stderr
# the device code is never written to it
--verbose # log at DEBUG in place of INFO
--version # print the version and exit
Exit codes: 0 every item complete and verified, 1 finished with failed or
skipped items, 2 fatal during setup, 130 interrupted.
Licence
MIT. See LICENSE.
Metadata
Release files for sharefetch 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sharefetch-1.0.0.tar.gz | 180.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sharefetch-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 291.8 kB