db

package
v0.0.0-...-44e2b1c Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB is

Functions

func AddTagToPodcast

func AddTagToPodcast(id, tagId string) error

func CreatePodcast

func CreatePodcast(podcast *Podcast) error

func CreatePodcastItem

func CreatePodcastItem(podcastItem *PodcastItem) error

func CreateTag

func CreateTag(tag *Tag) error

func DeletePodcastById

func DeletePodcastById(id string) error

func DeletePodcastItemById

func DeletePodcastItemById(id string) error

func DeleteTagById

func DeleteTagById(id string) error

func ExecuteAndSaveMigration

func ExecuteAndSaveMigration(name string, query string) error

func ForceSetLastEpisodeDate

func ForceSetLastEpisodeDate(podcastId string)

func GetAllPodcastItems

func GetAllPodcastItems(podcasts *[]PodcastItem) error

func GetAllPodcastItemsAlreadyDownloaded

func GetAllPodcastItemsAlreadyDownloaded() (*[]PodcastItem, error)

func GetAllPodcastItemsByIds

func GetAllPodcastItemsByIds(podcastItemIds []string) (*[]PodcastItem, error)

func GetAllPodcastItemsByPodcastId

func GetAllPodcastItemsByPodcastId(podcastId string, podcastItems *[]PodcastItem) error

func GetAllPodcastItemsByPodcastIds

func GetAllPodcastItemsByPodcastIds(podcastIds []string, podcastItems *[]PodcastItem) error

func GetAllPodcastItemsToBeDownloaded

func GetAllPodcastItemsToBeDownloaded() (*[]PodcastItem, error)

func GetAllPodcastItemsWithoutImage

func GetAllPodcastItemsWithoutImage() (*[]PodcastItem, error)

func GetAllPodcastItemsWithoutSize

func GetAllPodcastItemsWithoutSize() (*[]PodcastItem, error)

func GetAllPodcasts

func GetAllPodcasts(podcasts *[]Podcast, sorting string) error

func GetAllTags

func GetAllTags(sorting string) (*[]Tag, error)

func GetDB

func GetDB() *gorm.DB

Using this function to get a connection, you can create your connection pool here.

func GetEpisodeNumber

func GetEpisodeNumber(podcastItemId, podcastId string) (int, error)

func GetPaginatedPodcastItems

func GetPaginatedPodcastItems(page int, count int, downloadedOnly *bool, playedOnly *bool, fromDate time.Time, podcasts *[]PodcastItem, total *int64) error

func GetPaginatedPodcastItemsNew

func GetPaginatedPodcastItemsNew(queryModel model.EpisodesFilter) (*[]PodcastItem, int64, error)

func GetPaginatedTags

func GetPaginatedTags(page int, count int, tags *[]Tag, total *int64) error

func GetPodcastById

func GetPodcastById(id string, podcast *Podcast) error

func GetPodcastByTitleAndAuthor

func GetPodcastByTitleAndAuthor(title string, author string, podcast *Podcast) error

func GetPodcastByURL

func GetPodcastByURL(url string, podcast *Podcast) error

func GetPodcastEpisodeStats

func GetPodcastEpisodeStats() (*[]PodcastItemStatsModel, error)

func GetPodcastItemById

func GetPodcastItemById(id string, podcastItem *PodcastItem) error

func GetPodcastItemByPodcastIdAndGUID

func GetPodcastItemByPodcastIdAndGUID(podcastId string, guid string, podcastItem *PodcastItem) error

func GetPodcastItemsByPodcastIdAndGUIDs

func GetPodcastItemsByPodcastIdAndGUIDs(podcastId string, guids []string) (*[]PodcastItem, error)

func GetPodcastsByURLList

func GetPodcastsByURLList(urls []string, podcasts *[]Podcast) error

func GetTagsByIds

func GetTagsByIds(ids []string) (*[]Tag, error)

func Init

func Init() (*gorm.DB, error)

Init is used to Initialize Database

func Lock

func Lock(name string, duration int)

func Migrate

func Migrate()

Migrate Database

func RemoveTagFromPodcast

func RemoveTagFromPodcast(id, tagId string) error

func RunMigrations

func RunMigrations()

func SetAllEpisodesToDownload

func SetAllEpisodesToDownload(podcastId string) error

func TogglePodcastPauseStatus

func TogglePodcastPauseStatus(podcastId string, isPaused bool) error

func Unlock

func Unlock(name string)

func UnlockMissedJobs

func UnlockMissedJobs()

func UntagAllByTagId

func UntagAllByTagId(tagId string) error

func UpdateLastEpisodeDateForPodcast

func UpdateLastEpisodeDateForPodcast(podcastId string, lastEpisode time.Time) error

func UpdatePodcast

func UpdatePodcast(podcast *Podcast) error

func UpdatePodcastItem

func UpdatePodcastItem(podcastItem *PodcastItem) error

func UpdatePodcastItemFileSize

func UpdatePodcastItemFileSize(podcastItemId string, size int64) error

func UpdateSettings

func UpdateSettings(setting *Setting) error

func UpdateTag

func UpdateTag(tag *Tag) error

Types

type Base

type Base struct {
	ID        string `sql:"type:uuid;primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `gorm:"index"`
}

Base is

func (*Base) BeforeCreate

func (base *Base) BeforeCreate(tx *gorm.DB) error

BeforeCreate

type DownloadStatus

type DownloadStatus int
const (
	NotDownloaded DownloadStatus = iota
	Downloading
	Downloaded
	Deleted
)

type JobLock

type JobLock struct {
	Base
	Date     time.Time
	Name     string
	Duration int
}

func GetLock

func GetLock(name string) *JobLock

func (*JobLock) IsLocked

func (lock *JobLock) IsLocked() bool

type Migration

type Migration struct {
	Base
	Date time.Time
	Name string
}

type Podcast

type Podcast struct {
	Base
	Title string

	Summary string `gorm:"type:text"`

	Author string

	Image string

	URL string

	LastEpisode *time.Time

	PodcastItems []PodcastItem

	Tags []*Tag `gorm:"many2many:podcast_tags;"`

	DownloadedEpisodesCount  int `gorm:"-"`
	DownloadingEpisodesCount int `gorm:"-"`
	AllEpisodesCount         int `gorm:"-"`

	DownloadedEpisodesSize  int64 `gorm:"-"`
	DownloadingEpisodesSize int64 `gorm:"-"`
	AllEpisodesSize         int64 `gorm:"-"`

	IsPaused bool `gorm:"default:false"`
}

Podcast is

type PodcastItem

type PodcastItem struct {
	Base
	PodcastID string
	Podcast   Podcast
	Title     string
	Summary   string `gorm:"type:text"`

	EpisodeType string

	Duration int

	PubDate time.Time

	FileURL string

	GUID  string
	Image string

	DownloadDate   time.Time
	DownloadPath   string
	DownloadStatus DownloadStatus `gorm:"default:0"`

	IsPlayed bool `gorm:"default:false"`

	BookmarkDate time.Time

	LocalImage string

	FileSize int64
}

PodcastItem is

type PodcastItemConsolidateDiskStatsModel

type PodcastItemConsolidateDiskStatsModel struct {
	Downloaded      int64
	Downloading     int64
	NotDownloaded   int64
	Deleted         int64
	PendingDownload int64
}

func GetPodcastEpisodeDiskStats

func GetPodcastEpisodeDiskStats() (PodcastItemConsolidateDiskStatsModel, error)

type PodcastItemDiskStatsModel

type PodcastItemDiskStatsModel struct {
	DownloadStatus DownloadStatus
	Count          int
	Size           int64
}

type PodcastItemStatsModel

type PodcastItemStatsModel struct {
	PodcastID      string
	DownloadStatus DownloadStatus
	Count          int
	Size           int64
}

type Setting

type Setting struct {
	Base
	DownloadOnAdd                 bool `gorm:"default:true"`
	InitialDownloadCount          int  `gorm:"default:5"`
	AutoDownload                  bool `gorm:"default:true"`
	AppendDateToFileName          bool `gorm:"default:false"`
	AppendEpisodeNumberToFileName bool `gorm:"default:false"`
	DarkMode                      bool `gorm:"default:false"`
	DownloadEpisodeImages         bool `gorm:"default:false"`
	GenerateNFOFile               bool `gorm:"default:false"`
	DontDownloadDeletedFromDisk   bool `gorm:"default:false"`
	BaseUrl                       string
	MaxDownloadConcurrency        int `gorm:"default:5"`
	UserAgent                     string
}

func GetOrCreateSetting

func GetOrCreateSetting() *Setting

type Tag

type Tag struct {
	Base
	Label       string
	Description string     `gorm:"type:text"`
	Podcasts    []*Podcast `gorm:"many2many:podcast_tags;"`
}

func GetTagById

func GetTagById(id string) (*Tag, error)

func GetTagByLabel

func GetTagByLabel(label string) (*Tag, error)

Jump to

Keyboard shortcuts

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