database

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB
}

DB struct

func NewDB

func NewDB() (*DB, error)

NewDB establishes a connection with the database and sets the DB struct

func (*DB) AddItem

func (db *DB) AddItem(items map[string]string)

AddItem takes a map[string]string of episode items to be inserted into the database.

item[rssURL] item[title], item[enclosureURL], item[guid], items[pubdate]

func (*DB) AddPodcast

func (db *DB) AddPodcast(title, rssurl string)

AddPodcast Inserts a new podcast into the database

func (*DB) CatchUp

func (db *DB) CatchUp(id int)

CatchUp Marks all downloaded = false to be downloaded = true

func (*DB) FindAllPodcasts

func (db *DB) FindAllPodcasts() (ids []int, titles []string)

FindAllPodcasts Find all podcasts and their IDs

func (*DB) FindEpisodeTitleByURL

func (db *DB) FindEpisodeTitleByURL(url string) (title string)

FindEpisodeTitleByURL finds episode titles by url

func (*DB) FindEpisodesWithPodcastTitle

func (db *DB) FindEpisodesWithPodcastTitle() (map[string][]string, error)

FindEpisodesWithPodcastTitle Finds episodes with their podcast title and returns a map[string]string

func (*DB) FindNewEpisodes

func (db *DB) FindNewEpisodes() (urls []string, err error)

FindNewEpisodes finds episodes where downloaded = false

func (*DB) FindPodcastPausedState

func (db *DB) FindPodcastPausedState(id int) (paused bool)

FindPodcastPausedState finds out wether or not a podcast is paused

func (*DB) FindPodcastTitle

func (db *DB) FindPodcastTitle(id int) (title string)

FindPodcastTitle looks up a podcast title by its id

func (*DB) FindPodcastTitleByURL

func (db *DB) FindPodcastTitleByURL(url string) (title string)

FindPodcastTitleByURL finds podcast titles by URL

func (*DB) SetDownloadedByURL

func (db *DB) SetDownloadedByURL(url string)

SetDownloadedByURL updates all downloaded columns to be true

func (*DB) TogglePause

func (db *DB) TogglePause(id int) (paused bool)

TogglePause toggles between paused states true and false

type Datastore

type Datastore interface {
	FindEpisodesWithPodcastTitle() (map[string][]string, error)
	FindPodcastTitleByURL(url string) (title string)
	FindEpisodeTitleByURL(url string) (title string)
	FindNewEpisodes() (urls []string, err error)
	FindAllPodcasts() (ids []int, titles []string)
	FindPodcastTitle(id int) (title string)
	SetDownloadedByURL(url string)
	AddPodcast(title, rssurl string)
	AddItem(items map[string]string)
	TogglePause(id int) (paused bool)
	CatchUp(id int)
}

Datastore interface

type Episode

type Episode struct {
	ID           int `sql:"index"`
	PodcastID    int
	Title        string
	EnclosureURL string `sql:"unique_index"`
	Downloaded   bool
	GUID         string `sql:"unique_index"`
	PubDate      string
}

Episode struct

type Podcast

type Podcast struct {
	ID       int `sql:"index"`
	Title    string
	RssURL   string `sql:"unique_index"`
	Paused   bool
	Episodes []Episode
}

Podcast struct

Jump to

Keyboard shortcuts

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