🧩
Seanime Extensions
🧩
Seanime Extensions
  • Seanime
    • Getting started
    • Core APIs
    • Changelog
  • Content Providers
    • Write, test, share
    • Anime torrent provider
    • Manga provider
    • Online streaming provider
  • Plugins
    • Introduction
    • Write, test, share
    • APIs
      • Helpers
      • Store
      • Storage
      • Database
      • AniList
      • System
        • Permissions
        • OS
        • Filepath
        • Commands
        • Buffers, I/O
        • MIME
    • UI
      • Basics
      • User Interface
        • Tray
        • Toast
        • Screen
        • Command Palette
        • Action
        • DOM
      • Anime/Library
        • Anime
        • Playback
        • Continuity
        • Auto Downloader
        • Auto Scanner
        • Filler Manager
        • External Player Link
      • Downloading
        • Downloader
        • Torrent Client
      • Other
        • Manga
        • Discord
        • MPV
    • Hooks
    • Example
  • Frequently asked
    • Feature requests
Powered by GitBook
On this page
  1. Plugins
  2. UI
  3. Downloading

Downloader

OS-agnostic API for downloading files asynchronously.

Permission

system permission is required.

my-plugin.json
{
    //...
    "plugin": {
        "permissions": {
            "scopes": ["system"],
            "allow": {
                "writePaths": ["$DOWNLOAD/**/*"]
            }
        }
    }
}

//...

// Destination file
// Note that $DOWNLOAD is in the allow list
const filePath = $filepath.Join($osExtra.downloadDir(), "file.zip")
const downloadUrl = "http://example.com/download/file.zip"

// Start a download
const downloadID = ctx.downloader.download(downloadUrl, filePath);

// Track progress
const cancelWatch = ctx.downloader.watch(downloadID, (progress) => {
	console.log("Download progress:", 
		progress.percentage.toFixed(2), "%, ", 
		"Speed:", (progress.speed / 1024).toFixed(2), "KB/s, ",
		"Downloaded:", (progress.totalBytes / 1024).toFixed(2), "KB"
	);
	
	if (progress.status === "completed") {
		// download completed
	} else if (progress.status === "error") {
		// something went wrong
	}
});

// Cancel at any time
ctx.downloader.cancel(downloadID)
PreviousDownloadingNextTorrent Client

Last updated 24 days ago