seadex

package module
v0.0.0-...-cf69bf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 20 Imported by: 0

README


Logo

Go client for the SeaDex API.

SeaDexGo

SeaDexGo is a Go client for the SeaDex API. It provides access to SeaDex entry records, torrent metadata, and backup downloads in a native Go package.

Overview

This package exposes two primary clients:

  • SeaDexEntry for querying SeaDex entries by AniList ID, SeaDex ID, filename, infohash, or custom filters.
  • SeaDexBackup for authenticating with the SeaDex backup service, listing backup files, and downloading archives with integrity validation.

The package is designed for use in Go applications and supports custom HTTP clients for testing or network configuration.

Installation

Install the published module from GitHub:

go get github.com/RAELIE1/seadexgo@latest

If the module is used locally, ensure the module path in go.mod matches the desired import path.

Usage

package main

import (
    "fmt"
    "log"

    seadex "github.com/RAELIE1/seadexgo"
)

func main() {
    client := seadex.NewSeaDexEntry()

    entry, err := client.FromID(165790)
    if err != nil {
        log.Fatalf("failed to load entry: %v", err)
    }

    fmt.Printf("Title ID: %d\n", entry.AnilistID)
    fmt.Printf("Total size: %d\n", entry.Size)
}
Backup client
backup, err := seadex.NewSeaDexBackup("email@example.com", "password")
if err != nil {
    log.Fatalf("backup auth failed: %v", err)
}

files, err := backup.GetBackups()
if err != nil {
    log.Fatalf("failed to list backups: %v", err)
}

fmt.Printf("found %d backups\n", len(files))

CLI

A command-line client is included under cmd/seadexgo.

Install
# from source
make install

# or directly
go install github.com/RAELIE1/seadexgo/cmd/seadexgo@latest
Commands
Command Description
query Look up a single entry by AniList ID, PocketBase record ID, or anime title
search Find entries by PocketBase filter expression, filename, infohash, or dump all
backup List, download, create, or delete SeaDex backups (requires admin credentials)
torrent Inspect file lists and sanitize private .torrent metadata

All commands accept a --json flag to emit machine-readable JSON instead of the default tabular output. A --base-url flag overrides the default https://releases.moe endpoint.

Examples
# Look up by AniList ID
seadexgo query --id 21

# Look up by anime title (resolved via AniList)
seadexgo query --title "Mushishi"

# Look up by PocketBase record ID
seadexgo query --id abc123xyz456

# Find entries matching a custom PocketBase filter
seadexgo search --filter "isBest=true"

# Find entries by torrent filename
seadexgo search --filename "[SubsPlease] Dungeon Meshi - 01 (1080p).mkv"

# Find entries by infohash
seadexgo search --infohash a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2

# Dump every entry as JSON (pipe-friendly)
seadexgo --json search --all | jq '.[].anilist_id'

# List all available backups
export SEADEX_EMAIL=admin@example.com
export SEADEX_PASSWORD=secret
seadexgo backup list

# Download the latest backup to /tmp
seadexgo backup download --dest /tmp

# Download a specific backup, overwriting if it exists
seadexgo backup download --name backup-20240101-120000.zip --dest /tmp --overwrite

# Create a new backup on the server
seadexgo backup create

# Delete a backup
seadexgo backup delete --name backup-20240101-120000.zip

# Print the files contained in a torrent
seadexgo torrent filelist release.torrent

# Remove private tracker metadata and write a sanitized copy
seadexgo torrent sanitize private.torrent --dst public.torrent
Backup credentials

backup subcommands require admin credentials supplied via environment variables:

SEADEX_EMAIL      admin e-mail address
SEADEX_PASSWORD   admin password

Testing

Run the test suite with:

go test ./...

License

Distributed under the MIT License. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBackupBaseURL

func WithBackupBaseURL(baseURL string) func(*SeaDexBackup)

func WithBackupHTTPClient

func WithBackupHTTPClient(client *http.Client) func(*SeaDexBackup)

func WithBaseURL

func WithBaseURL(baseURL string) func(*SeaDexEntry)

func WithHTTPClient

func WithHTTPClient(client *http.Client) func(*SeaDexEntry)

Types

type BackupFile

type BackupFile struct {
	Name         string    `json:"name"`
	Size         int64     `json:"size"`
	ModifiedTime time.Time `json:"modified_time"`
}

func (BackupFile) String

func (b BackupFile) String() string

type BadBackupFileError

type BadBackupFileError struct {
	SeaDexError
}

type EntryNotFoundError

type EntryNotFoundError struct {
	SeaDexError
}

type EntryRecord

type EntryRecord struct {
	AnilistID       int             `json:"anilist_id"`
	CollectionID    string          `json:"collection_id"`
	CollectionName  string          `json:"collection_name"`
	Comparisons     []string        `json:"comparisons"`
	CreatedAt       time.Time       `json:"created_at"`
	ID              string          `json:"id"`
	IsIncomplete    bool            `json:"is_incomplete"`
	Notes           string          `json:"notes"`
	TheoreticalBest *string         `json:"theoretical_best"`
	Torrents        []TorrentRecord `json:"torrents"`
	UpdatedAt       time.Time       `json:"updated_at"`
	URL             string          `json:"url"`
	Size            int64           `json:"size"`
}

func Entries

func Entries() ([]EntryRecord, error)

func EntryRecordFromJSON

func EntryRecordFromJSON(data []byte) (EntryRecord, error)

func (EntryRecord) ToDict

func (e EntryRecord) ToDict() map[string]any

func (EntryRecord) ToJSON

func (e EntryRecord) ToJSON() (string, error)

type EntryStream

type EntryStream struct {
	// contains filtered or unexported fields
}

func (*EntryStream) Err

func (s *EntryStream) Err() error

func (*EntryStream) Next

func (s *EntryStream) Next() bool

func (*EntryStream) Value

func (s *EntryStream) Value() EntryRecord

type File

type File struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
}

func (File) String

func (f File) String() string

func (File) ToDict

func (f File) ToDict() map[string]any

type SeaDexBackup

type SeaDexBackup struct {
	// contains filtered or unexported fields
}

func NewSeaDexBackup

func NewSeaDexBackup(email, password string, opts ...func(*SeaDexBackup)) (*SeaDexBackup, error)

func (*SeaDexBackup) BaseURL

func (b *SeaDexBackup) BaseURL() string

func (*SeaDexBackup) Close

func (b *SeaDexBackup) Close()

func (*SeaDexBackup) Create

func (b *SeaDexBackup) Create(filename string) (BackupFile, error)

func (*SeaDexBackup) Delete

func (b *SeaDexBackup) Delete(file BackupFile) error

func (*SeaDexBackup) Download

func (b *SeaDexBackup) Download(file *BackupFile, destination string, overwrite bool) (string, error)

func (*SeaDexBackup) GetBackups

func (b *SeaDexBackup) GetBackups() ([]BackupFile, error)

func (*SeaDexBackup) GetLatestBackup

func (b *SeaDexBackup) GetLatestBackup() (BackupFile, error)

type SeaDexEntry

type SeaDexEntry struct {
	// contains filtered or unexported fields
}

func NewSeaDexEntry

func NewSeaDexEntry(opts ...func(*SeaDexEntry)) *SeaDexEntry

func (*SeaDexEntry) AnilistTitle

func (s *SeaDexEntry) AnilistTitle(searchTerm string) string

func (*SeaDexEntry) BaseURL

func (s *SeaDexEntry) BaseURL() string

func (*SeaDexEntry) Close

func (s *SeaDexEntry) Close()

func (*SeaDexEntry) FromFilename

func (s *SeaDexEntry) FromFilename(filename string) ([]EntryRecord, error)

func (*SeaDexEntry) FromFilenameStream

func (s *SeaDexEntry) FromFilenameStream(filename string) *EntryStream

func (*SeaDexEntry) FromFilter

func (s *SeaDexEntry) FromFilter(filter string) ([]EntryRecord, error)

func (*SeaDexEntry) FromFilterContext

func (s *SeaDexEntry) FromFilterContext(ctx context.Context, filter string) ([]EntryRecord, error)

func (*SeaDexEntry) FromFilterStream

func (s *SeaDexEntry) FromFilterStream(filter string) (*EntryStream, error)

func (*SeaDexEntry) FromID

func (s *SeaDexEntry) FromID(id any) (EntryRecord, error)

func (*SeaDexEntry) FromIDContext

func (s *SeaDexEntry) FromIDContext(ctx context.Context, id any) (EntryRecord, error)

func (*SeaDexEntry) FromInfohash

func (s *SeaDexEntry) FromInfohash(infohash string) ([]EntryRecord, error)

func (*SeaDexEntry) FromInfohashStream

func (s *SeaDexEntry) FromInfohashStream(infohash string) (*EntryStream, error)

func (*SeaDexEntry) FromTitle

func (s *SeaDexEntry) FromTitle(title string) (EntryRecord, error)

func (*SeaDexEntry) FromTitleContext

func (s *SeaDexEntry) FromTitleContext(ctx context.Context, title string) (EntryRecord, error)

func (*SeaDexEntry) Iterator

func (s *SeaDexEntry) Iterator() ([]EntryRecord, error)

func (*SeaDexEntry) IteratorStream

func (s *SeaDexEntry) IteratorStream() *EntryStream

type SeaDexError

type SeaDexError struct {
	Message string
}

func (*SeaDexError) Error

func (e *SeaDexError) Error() string

type SeaDexTorrent

type SeaDexTorrent struct {
	// contains filtered or unexported fields
}

func NewSeaDexTorrent

func NewSeaDexTorrent(filePath string) (*SeaDexTorrent, error)

func (*SeaDexTorrent) File

func (t *SeaDexTorrent) File() string

func (*SeaDexTorrent) FileList

func (t *SeaDexTorrent) FileList() ([]File, error)

func (*SeaDexTorrent) IsPrivate

func (t *SeaDexTorrent) IsPrivate() bool

func (*SeaDexTorrent) Sanitize

func (t *SeaDexTorrent) Sanitize(destination string, overwrite bool) (string, error)

type Tag

type Tag string
const (
	TagDolbyVision       Tag = "Dolby Vision"
	TagHDR               Tag = "HDR"
	TagDebandRequired    Tag = "Deband Required"
	TagDebandRecommended Tag = "Deband Recommended"
	TagYUV444P           Tag = "YUV444P"
	TagPatchRequired     Tag = "Patch Required"
	TagMisplacedSpecial  Tag = "Misplaced Special"
	TagVFR               Tag = "VFR"
	TagIncomplete        Tag = "Incomplete"
	TagBroken            Tag = "Broken"
)

func ParseTag

func ParseTag(s string) (Tag, error)

type TorrentRecord

type TorrentRecord struct {
	CollectionID   string    `json:"collection_id"`
	CollectionName string    `json:"collection_name"`
	CreatedAt      time.Time `json:"created_at"`
	IsDualAudio    bool      `json:"is_dual_audio"`
	Files          []File    `json:"files"`
	ID             string    `json:"id"`
	Infohash       *string   `json:"infohash"`
	IsBest         bool      `json:"is_best"`
	ReleaseGroup   string    `json:"release_group"`
	Tags           []Tag     `json:"tags"`
	Tracker        Tracker   `json:"tracker"`
	UpdatedAt      time.Time `json:"updated_at"`
	URL            string    `json:"url"`
	GroupedURL     *string   `json:"grouped_url"`
	Size           int64     `json:"size"`
}

func TorrentRecordFromJSON

func TorrentRecordFromJSON(data []byte) (TorrentRecord, error)

func (TorrentRecord) ToDict

func (t TorrentRecord) ToDict() map[string]any

func (TorrentRecord) ToJSON

func (t TorrentRecord) ToJSON() (string, error)

type Tracker

type Tracker string
const (
	TrackerNyaa            Tracker = "Nyaa"
	TrackerAnimeTosho      Tracker = "AnimeTosho"
	TrackerAniDex          Tracker = "AniDex"
	TrackerRuTracker       Tracker = "RuTracker"
	TrackerOther           Tracker = "Other"
	TrackerAnimeBytes      Tracker = "AB"
	TrackerBeyondHD        Tracker = "BeyondHD"
	TrackerPassThePopcorn  Tracker = "PassThePopcorn"
	TrackerBroadcastTheNet Tracker = "BroadcastTheNet"
	TrackerHDBits          Tracker = "HDBits"
	TrackerBlutopia        Tracker = "Blutopia"
	TrackerAither          Tracker = "Aither"
	TrackerOtherPrivate    Tracker = "OtherPrivate"
)

func ParseTracker

func ParseTracker(s string) (Tracker, error)

func (Tracker) IsPrivate

func (t Tracker) IsPrivate() bool

func (Tracker) IsPublic

func (t Tracker) IsPublic() bool

func (Tracker) URL

func (t Tracker) URL() string

Directories

Path Synopsis
cmd
seadexgo command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL