database

package
v0.0.0-...-dc3ebaa Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatabaseNotOpened = errors.New("database not opened")

Functions

This section is empty.

Types

type ConnectionInfo

type ConnectionInfo struct {
	Server   string
	Port     int
	Database string
	Username string
	Password string
}

func (*ConnectionInfo) String

func (c *ConnectionInfo) String() string

getConnectionString returns the connection string

type Database

type Database struct {
	ConnectionInfo

	Connection    *sql.DB
	Subscriptions *SubscriptionTable
	Videos        *VideosTable
	Download      *DownloadTable
	Log           *LogTable
}

Database represents connection to the SoftTube database

func NewDatabase

func NewDatabase(server string, port int, database, username, password string) *Database

NewDatabase creates a new database object

func (*Database) Close

func (d *Database) Close()

Close the database

func (*Database) Open

func (d *Database) Open() error

Open the database

type Download

type Download struct {
	ID string
}

Download represents a download request

type DownloadTable

type DownloadTable struct {
	*Table
}

DownloadTable in the SoftTube database

func (DownloadTable) Delete

func (d DownloadTable) Delete(id string) error

Delete the row from the downloaded list

func (DownloadTable) GetAll

func (d DownloadTable) GetAll() ([]Download, error)

GetAll returns all download requests

func (DownloadTable) Insert

func (d DownloadTable) Insert(id string) error

Insert a new download request into the database

type ErrVideo

type ErrVideo struct {
	Message string
	VideoID string
}

func (ErrVideo) Error

func (e ErrVideo) Error() string

type Log

type Log struct {
	ID      int
	Message string
	Type    LogType
}

Log represents a SoftTube log entry

type LogTable

type LogTable struct {
	*Table
}

LogTable is the log table in the database

func (*LogTable) GetLatest

func (l *LogTable) GetLatest() ([]Log, error)

GetLatest returns the version number of a SoftTube database

func (*LogTable) Insert

func (l *LogTable) Insert(logType LogType, logMessage string) error

Insert a new video into the database

type LogType

type LogType int

type Subscription

type Subscription struct {
	ID          string
	Name        string
	Frequency   int
	LastChecked sql.NullTime
	NextUpdate  sql.NullInt32
}

Subscription represents a YouTube subscription in SoftTube

func (Subscription) NeedsUpdate

func (s Subscription) NeedsUpdate() bool

NeedsUpdate returns true if the subscription needs an update

type SubscriptionTable

type SubscriptionTable struct {
	*Table
}

SubscriptionTable in the SoftTube database

func (SubscriptionTable) Get

Get returns a subscription

func (SubscriptionTable) GetAll

func (s SubscriptionTable) GetAll() ([]Subscription, error)

GetAll returns all subscriptions

func (SubscriptionTable) UpdateLastChecked

func (s SubscriptionTable) UpdateLastChecked(subscription *Subscription, interval int) error

UpdateLastChecked updates last_checked and next_update for a subscription

type Table

type Table struct {
	*Database
}

type Version

type Version struct {
	Major    int
	Minor    int
	Revision int
}

Version represents the SoftTube database version

type Video

type Video struct {
	ID               string
	SubscriptionID   string
	SubscriptionName string
	Title            string
	Added            time.Time
	Published        time.Time
	Duration         sql.NullString
	Status           VideoStatusType
	Saved            bool
	Seconds          int
}

Video represents a YouTube video in SoftTube

type VideoStatusType

type VideoStatusType int

type VideosTable

type VideosTable struct {
	*Table
}

VideosTable in the SoftTube database

func (VideosTable) Delete

func (v VideosTable) Delete(id string) error

Delete deletes a video from the database

func (VideosTable) Exists

func (v VideosTable) Exists(videoID string) (bool, error)

Exists returns true if a video already exists in the database

func (VideosTable) Get

func (v VideosTable) Get(id string) (Video, error)

Get a subscription

func (VideosTable) GetStats

func (v VideosTable) GetStats() ([]string, error)

GetStats gets a list of the videos in DB

func (VideosTable) GetStatus

func (v VideosTable) GetStatus(videoID string) (int, error)

GetStatus gets the video status

func (VideosTable) GetVideos

func (v VideosTable) GetVideos(failed, savedView bool) ([]Video, error)

GetVideos gets a list of the latest videos

func (VideosTable) HasVideosToDelete

func (v VideosTable) HasVideosToDelete() bool

HasVideosToDelete returns true if there are videos to delete

func (VideosTable) Insert

func (v VideosTable) Insert(
	id string, subscriptionID string, title string, duration string, published time.Time,
) error

Insert a new video into the database

func (VideosTable) Search

func (v VideosTable) Search(text string) ([]Video, error)

Search searches for videos

func (VideosTable) UpdateDuration

func (v VideosTable) UpdateDuration(videoID string, duration string) error

UpdateDuration updates duration for a video

func (VideosTable) UpdateSave

func (v VideosTable) UpdateSave(id string, saved bool) error

UpdateSave updates the saved flag for a video

func (VideosTable) UpdateStatus

func (v VideosTable) UpdateStatus(id string, status VideoStatusType) error

UpdateStatus updates the status for a video

Jump to

Keyboard shortcuts

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