🧩
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
  • Permission
  • Core Methods
  • getTorrents
  • getActiveTorrents
  • addMagnets
  • removeTorrents
  • pauseTorrents
  • resumeTorrents
  • deselectFiles
  • getFiles
  1. Plugins
  2. UI
  3. Downloading

Torrent Client

Permission

torrent-client permission is required.

my-plugin.json
{
    //...
    "plugin": {
        "permissions": {
            "scopes": ["torrent-client"],
        }
    }
}

Core Methods

getTorrents

getTorrents()

Retrieves a list of all torrents in the torrent client.

Example:

// Get all torrents from the client
try {
  const torrents = await ctx.torrentClient.getTorrents()
  console.log("Retrieved torrents:", torrents)
} catch (error) {
  console.error("Error getting torrents:", error)
}

getActiveTorrents

getActiveTorrents()

Retrieves a list of active torrents (downloading/uploading) from the torrent client.

Example:

// Get only active torrents
try {
  const activeTorrents = await ctx.torrentClient.getActiveTorrents()
  console.log("Active torrents:", activeTorrents)
} catch (error) {
  console.error("Error getting active torrents:", error)
}

addMagnets

addMagnets(magnets, dest)

Adds magnet links to the torrent client.

Parameters:

  • magnets: string[] - Array of magnet links

  • dest: string - Destination path for downloaded files

Example:

// Add magnet links to the torrent client
try {
  await ctx.torrentClient.addMagnets(
    ["magnet:?xt=urn:btih:xxxxxx", "magnet:?xt=urn:btih:yyyyyy"],
    "/downloads/anime"
  )
  console.log("Magnets added successfully")
} catch (error) {
  console.error("Error adding magnets:", error)
}

removeTorrents

removeTorrents(hashes)

Removes torrents from the client.

Parameters:

  • hashes: string[] - Array of torrent hashes to remove

Example:

// Remove torrents from the client
try {
  await ctx.torrentClient.removeTorrents(["abc123def456", "xyz789uvw"])
  console.log("Torrents removed successfully")
} catch (error) {
  console.error("Error removing torrents:", error)
}

pauseTorrents

pauseTorrents(hashes)

Pauses specified torrents.

Parameters:

  • hashes: string[] - Array of torrent hashes to pause

Example:

// Pause specific torrents
try {
  await ctx.torrentClient.pauseTorrents(["abc123def456", "xyz789uvw"])
  console.log("Torrents paused successfully")
} catch (error) {
  console.error("Error pausing torrents:", error)
}

resumeTorrents

resumeTorrents(hashes)

Resumes specified torrents.

Parameters:

  • hashes: string[] - Array of torrent hashes to resume

Example:

// Resume specific torrents
try {
  await ctx.torrentClient.resumeTorrents(["abc123def456", "xyz789uvw"])
  console.log("Torrents resumed successfully")
} catch (error) {
  console.error("Error resuming torrents:", error)
}

deselectFiles

deselectFiles(hash, indices)

Deselects specific files within a torrent.

Parameters:

  • hash: string - Hash of the torrent

  • indices: number[] - Array of file indices to deselect

Example:

// Deselect specific files in a torrent
try {
  await ctx.torrentClient.deselectFiles("abc123def456", [0, 2, 5])
  console.log("Files deselected successfully")
} catch (error) {
  console.error("Error deselecting files:", error)
}

getFiles

getFiles(hash)

Retrieves all files within a specific torrent.

Parameters:

  • hash: string - Hash of the torrent

Example:

// Get all files in a torrent
try {
  const files = await ctx.torrentClient.getFiles("abc123def456")
  console.log("Torrent files:", files)
} catch (error) {
  console.error("Error getting files:", error)
}
PreviousDownloaderNextOther

Last updated 20 days ago