database

package
v0.0.0-...-41e9194 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 connections string

type Database

type Database struct {
	ConnectionInfo

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

Database : A 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 : Close the database

func (*Database) Open

func (d *Database) Open() error

Open : Open the database

type Download

type Download struct {
	ID string
}

Download : Represents a download request

type DownloadTable

type DownloadTable struct {
	*Table
}

DownloadTable : VideosTable in the SoftTube database

func (DownloadTable) Delete

func (d DownloadTable) Delete(id string) error

Delete : Deletes 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 : Insert a new download request into the database

type Log

type Log struct {
	ID      int
	Message string
	Type    LogType
}

Log : Represents a SoftTube log entry

type LogTable

type LogTable struct {
	*Table
}

LogTable : The version table in the database

func (*LogTable) GetLatest

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

GetLatest : Get the version number of a SoftTube database

func (*LogTable) Insert

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

Insert : 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 : Does the subscription need an update?

type SubscriptionTable

type SubscriptionTable struct {
	*Table
}

SubscriptionTable : 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 : Update 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 VersionTable

type VersionTable struct {
	*Table
}

VersionTable : The version table in the database

func (VersionTable) Get

func (v VersionTable) Get() (Version, error)

Get : Get the version number of a SoftTube database

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
}

Video : Represents a YouTube video in SoftTube

type VideoStatusType

type VideoStatusType int

type VideosTable

type VideosTable struct {
	*Table
}

VideosTable : VideosTable in the SoftTube database

func (VideosTable) Delete

func (v VideosTable) Delete(id string) error

Delete : Delete a video from the database

func (VideosTable) Exists

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

Exists : Does a video already exist in the database?

func (VideosTable) Get

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

Get : Returns a subscription

func (VideosTable) GetStatus

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

GetStatus : Get 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) Insert

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

Insert : 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 : Update duration for a video

func (VideosTable) UpdateSave

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

UpdateSave : Update saved flag for a video

func (VideosTable) UpdateStatus

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

UpdateStatus : Update the status for a video

Jump to

Keyboard shortcuts

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