🧩
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
  • Invalidate queries
  • Local files
  • Get all
  • Edit
  • Insert
  • AniList
  • Get Token
  • Get Username
  • Auto Downloader Rules
  • Auto Downloader Items
  • Silenced media entries
  • Media fillers
  1. Plugins
  2. APIs

Database

Interact with parts of Seanime's database.

Permission

database permission is required.

my-plugin.json
{
    //...
    "plugin": {
        "permissions": {
            "scopes": ["database"]
        }
    }
}

Invalidate queries

After some database operations you might want to cause the client to automatically refetch certain queries. This is possible using $app.invalidateClientQuery - Helpers

Local files

You can interact with the scanned file entries (also called local files).

Get all

const localFiles = $database.localFiles.getAll()

Edit

// Get all 'One Piece' files
const onePieceLocalFiles = $database
    .localFiles.findBy((lf) => {
        return lf.mediaId === 21
    })
    
// Lock all 'One piece' files
for (const lf of onePieceLocalFiles) {
    lf.locked = true
}

$database.localFiles.save(onePieceLocalFiles)

Note that save only works for existing entries.

Insert

// Inserts a new collection of local files
// This is equivalent to doing a scan
const localFiles = $database.localFiles.insert([
    //...
])

AniList

Get Token

anilist-token permission is required

$database.anilist.getToken()

Get Username

$database.anilist.getUsername()

Auto Downloader Rules

// Get all rules
$database.autoDownloaderRules.getAll()

// Get rules by media ID
const rules = $database.autoDownloaderRules.getByMediaId(21)

for (const rule of rules) {
    rule.enabled = false
    
    // Update a rule
    $database.autoDownloaderRules.update(rule.dbId, rule)
}

// Remove a rule
$database.autoDownloaderRules.remove(ruleDbId)

// Insert a rule
$database.autoDownloaderRules.insert({ 
    //...
})

Auto Downloader Items

In Seanime, an item is usually added by the auto downloader when the user has chosen not to immediately download torrents. It is shown in the queue and lets the user download that torrent later.

// Get all items
$database.autoDownloaderItems.getAll()

// Get items by media ID
const items = $database.autoDownloaderItems.getByMediaId(21)

for (const item of items) {
    // Update an item
    $database.autoDownloaderItems.update(item.dbId, item)
}

// Remove an item
$database.autoDownloaderItems.remove(itemDbId)

// Insert an item
$database.autoDownloaderItems.insert({ 
    //...
})

Silenced media entries

const silencedAnimeIds = $database.silencedMediaEntries.getAllIds()

// Silence an anime
$database.silencedMediaEntries.setSilenced(21, true)

$database.silencedMediaEntries.isSilenced(21) // true

Media fillers

const fillerData = $database.mediaFillers.getAll()

$database.mediaFillers.get(21)
$database.mediaFillers.insert("provider", 21, "slug", ["600"])
$database.mediaFillers.remove(21)

PreviousStorageNextAniList

Last updated 1 month ago