Metadata-Version: 2.4
Name: sharefetch
Version: 1.1.0
Summary: Resumable, rate-limited downloads from Microsoft Graph drives.
Author-email: Santhosh <santhoshmlaa@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/Indspl0it/sharefetch
Project-URL: Repository, https://github.com/Indspl0it/sharefetch
Project-URL: Issues, https://github.com/Indspl0it/sharefetch/issues
Keywords: sharepoint,onedrive,microsoft-graph,download,resumable,device-code,oauth2
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Environment :: Win32 (MS Windows)
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Communications :: File Sharing
Classifier: Topic :: System :: Archiving :: Mirroring
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests==2.32.3
Requires-Dist: msal==1.39.0
Requires-Dist: msal-extensions[portalocker]==1.3.1
Provides-Extra: dev
Requires-Dist: pytest==8.4.2; extra == "dev"
Requires-Dist: pytest-cov==7.0.0; extra == "dev"
Requires-Dist: ruff==0.15.12; extra == "dev"
Requires-Dist: build==1.3.0; extra == "dev"
Dynamic: license-file

# sharefetch

Download a SharePoint Online or OneDrive for Business folder tree to a local directory, resumably and with content-level verification.

![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)![License: MIT](https://img.shields.io/badge/license-MIT-green)

```console
$ 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

```console
$ 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:

```console
$ 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.

```console
$ 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:

```console
$ sharefetch "<url>" --dest D:/archive --delay 2 --limit-rate 500
```

Report what a run would transfer, without transferring it:

```console
$ sharefetch "<url>" --dry-run
```

Take part of a tree:

```console
$ sharefetch "<url>" --include "*.pdf" --exclude "*/Archive/*" --max-depth 2
```

Re-check an existing download, without touching the network:

```console
$ 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:

```console
$ 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

```console
$ 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](LICENSE).
