Skip to main content

sharepoint-dl

sharepoint-dl logo

Download videos and files from SharePoint — like yt-dlp for SharePoint.

CI Coverage PyPI Python License: MIT


Why?

  • Microsoft Stream (Classic) was retired — all videos now live in SharePoint / OneDrive
  • Browser downloads fail for large files, offer no resume, and require clicking through menus
  • Enterprise tenants often block direct downloads — sp-dl handles this automatically via adaptive streaming
  • yt-dlp doesn't support SharePoint authentication
  • sp-dl gives you one command to download any file from SharePoint

What It Downloads

Content Source
Videos (.mp4, .mov, .webm) SharePoint document libraries, Stream on SharePoint
Meeting recordings OneDrive / SharePoint auto-saved recordings
Download-blocked videos Enterprise tenants with admin download restrictions
Any file SharePoint document libraries
Shared links Anonymous or org-internal sharing links

Install

pip install sharepoint-dl

Or with pipx for isolated install:

pipx install sharepoint-dl

Quick Start

First time? Run sp-dl quickstart for a step-by-step guide.

  1. Log into SharePoint in your browser
  2. Export cookies to a file using a browser extension like "Get cookies.txt LOCALLY"
  3. Download:
sp-dl download "https://contoso.sharepoint.com/sites/Team/_layouts/15/stream.aspx?id=/sites/Team/Shared%20Documents/demo.mp4" \
  --cookies cookies.txt

Using Device Code (OAuth — for enterprise tenants)

# One-time login (you'll be prompted for your org tenant)
sp-dl auth login --tenant contoso

# Download (uses saved token)
sp-dl download "https://contoso.sharepoint.com/sites/Team/Shared%20Documents/video.mp4"

Download-Blocked Videos (Enterprise Tenants)

Some organizations disable direct file downloads via SharePoint admin policy. sp-dl detects this automatically and switches to parallel adaptive streaming:

# Works even when admin has blocked downloads!
# sp-dl detects the block → prompts OAuth2 login → streams via DASH manifest
sp-dl download "https://contoso-my.sharepoint.com/personal/user/_layouts/15/stream.aspx?id=..." \
  --cookies cookies.txt

How it works:

  1. Detects download-blocked policy from the stream page or 401/403 response
  2. Acquires an OAuth2 token via device code flow (cached per-domain for future use)
  3. Builds a DASH manifest URL via Microsoft's media proxy
  4. Downloads all video/audio segments in parallel (10 concurrent connections)
  5. Muxes audio + video into a single MP4 using ffmpeg

Requires ffmpeg for final muxing: brew install ffmpeg (macOS) or apt install ffmpeg (Linux)

Usage

# Download a video
sp-dl download <URL> --cookies cookies.txt

# Download from a sharing link
sp-dl download "https://contoso.sharepoint.com/:v:/s/Team/EaBcDeFgHiJk" -c cookies.txt

# Show file info without downloading
sp-dl download <URL> --info -c cookies.txt

# JSON metadata
sp-dl download <URL> --json -c cookies.txt

# Custom output path
sp-dl download <URL> -o ~/Videos/meeting.mp4 -c cookies.txt

# Output template
sp-dl download <URL> -o "%(site)s/%(folder)s/%(filename)s" -c cookies.txt

# Limit speed
sp-dl download <URL> --limit-rate 5M -c cookies.txt

# Skip existing files
sp-dl download <URL> --no-overwrites -c cookies.txt

# Batch download (one URL per line)
sp-dl batch urls.txt -c cookies.txt

# Quick start guide
sp-dl quickstart

Supported URL Patterns

Pattern Example
Stream player https://tenant.sharepoint.com/sites/Team/_layouts/15/stream.aspx?id=...
Sharing link https://tenant.sharepoint.com/:v:/s/Team/EncodedToken
Direct path https://tenant.sharepoint.com/sites/Team/Shared%20Documents/file.mp4
OneDrive https://tenant-my.sharepoint.com/personal/user/Documents/file.mp4
Doc.aspx https://tenant.sharepoint.com/sites/Team/_layouts/15/Doc.aspx?sourcedoc={guid}

Authentication Methods

Method Best For Setup
--cookies Quick downloads, read-only users Export cookies from browser (e.g. "Get cookies.txt LOCALLY" extension)
sp-dl auth login Enterprise tenants, download-blocked sites One-time device code login
--client-id --client-secret Service accounts, CI/CD Azure AD admin setup

Enterprise users: When direct downloads are blocked by admin policy, sp-dl automatically falls back to OAuth2 + adaptive streaming. Your first download will prompt for a device code login, and the token is cached for subsequent downloads.

Auth Management

sp-dl auth login --tenant contoso       # Device code login (prompted for tenant)
sp-dl auth login --tenant contoso -i    # Browser-based login
sp-dl auth status                        # Check auth state
sp-dl auth logout                        # Clear tokens

Tip: You can pass a SharePoint URL as the tenant and it will be auto-detected: sp-dl auth login --tenant https://contoso.sharepoint.com

Output Templates

Field Description Example
%(filename)s Original filename training.mp4
%(title)s Name without extension training
%(ext)s Extension mp4
%(site)s SharePoint site Team
%(folder)s Parent folder Recordings
%(date)s Modified date 20260415
%(author)s Created by John Smith

Configuration

Create ~/.config/sp-dl/config.toml:

[defaults]
output_template = "%(filename)s"
cookies_file = "/path/to/cookies.txt"
retries = 5
no_overwrites = false

[auth]
tenant = "contoso.onmicrosoft.com"

Environment variables: SP_DL_COOKIES, SP_DL_TENANT, SP_DL_CLIENT_ID, SP_DL_OUTPUT

Development

git clone https://github.com/bhayanak/sp-dl.git
cd sp-dl
pip install -e ".[dev]"

# Run tests with coverage
pytest --cov=sp_dl -v

# Lint & format
ruff check src/ tests/
ruff format src/ tests/

License

MIT

Metadata

Release files for sharepoint-dl 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharepoint-dl 1.1.0
File Size Uploaded
sharepoint_dl-1.1.0.tar.gz 66.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sharepoint-dl 1.1.0
File Interpreter ABI Platform
sharepoint_dl-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 124.8 kB

Release files / sharepoint_dl-1.1.0.tar.gz

Download URL sharepoint_dl-1.1.0.tar.gz
Size 66.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8b62099e8d4ce5231fe308d8047cb229502b2b1c933fc14c85c7180a94e5d294
BLAKE2b-256 checksum
How to use checksums
3a9b2134891ca470dbaa4e46f5ddb3265aaa67471c87fab2424dbdc27fa831d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

Release files / sharepoint_dl-1.1.0-py3-none-any.whl

Download URL sharepoint_dl-1.1.0-py3-none-any.whl
Size 58.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24d6f720f8a38a239b6c48ce3726d26ef2fefaa640ec1694c887f65895fe3a29
BLAKE2b-256 checksum
How to use checksums
5ff4f4d4e1806c074f619c239e01dd5b9ea3a912b791b36215946768da709a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page