playlists

package
v0.90.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package playlists manages per-user ordered collections of torrent references. A playlist contains items that reference a magnet + info_hash; resume state lives in the library package so the same content played from search vs. playlist shares its watched position.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	ID         int       `json:"id"`
	PlaylistID int       `json:"playlistId"`
	Position   int       `json:"position"`
	LibraryID  *int      `json:"libraryId,omitempty"`
	Title      string    `json:"title"`
	Magnet     string    `json:"magnet"`
	InfoHash   string    `json:"infoHash"`
	FileIndex  int       `json:"fileIndex"`
	AddedAt    time.Time `json:"addedAt"`
}

Item is one position in a playlist.

type Playlist

type Playlist struct {
	ID          int       `json:"id"`
	UserID      int       `json:"userId"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	ItemCount   int       `json:"itemCount,omitempty"` // populated by List, not Get
}

Playlist is one user-owned ordered collection.

type Store

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

func New

func New(pool *sql.DB) (*Store, error)

New wires the playlists store onto the shared Postgres pool. Schema is applied centrally (internal/db migrations).

func (*Store) AddItem

func (s *Store) AddItem(playlistID, userID int, item Item, includeAll bool) (*Item, error)

AddItem appends an item to the end of the playlist.

func (*Store) Close

func (s *Store) Close()

Close is a no-op: the shared pool's lifecycle is owned by main.

func (*Store) Create

func (s *Store) Create(userID int, name, description string) (*Playlist, error)

Create makes a new empty playlist owned by userID.

func (*Store) Delete

func (s *Store) Delete(id, userID int, includeAll bool) error

Delete drops a playlist (and cascades to items).

func (*Store) Get

func (s *Store) Get(id, userID int, includeAll bool) (*Playlist, error)

Get returns one playlist (without items). Returns nil if not found / not owned.

func (*Store) Items

func (s *Store) Items(playlistID, userID int, includeAll bool) ([]Item, error)

Items returns all items in a playlist, ordered by position.

func (*Store) List

func (s *Store) List(userID int, includeAll bool) ([]Playlist, error)

List returns the user's playlists (or all when includeAll=true), with item counts.

func (*Store) RemoveItem

func (s *Store) RemoveItem(playlistID, itemID, userID int, includeAll bool) error

RemoveItem deletes an item and compacts positions.

func (*Store) Reorder

func (s *Store) Reorder(playlistID, itemID, userID, newPos int, includeAll bool) error

Reorder moves an item to a new position, shifting siblings as needed.

func (*Store) Update

func (s *Store) Update(id, userID int, name, description string, includeAll bool) error

Update renames / re-describes a playlist.

Jump to

Keyboard shortcuts

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