app

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Code generated by github.com/dashotv/golem. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryBool

func QueryBool(c echo.Context, name string) bool

QueryBool retrieves a boolean param from the gin request querystring

func QueryDefaultInteger

func QueryDefaultInteger(c echo.Context, name string, def int) (int, error)

QueryDefaultInt retrieves an integer param from the gin request querystring defaults to def argument if not found

func QueryDefaultString

func QueryDefaultString(c echo.Context, name, def string) string

func QueryInt

func QueryInt(c echo.Context, name string) int

QueryInt retrieves an integer param from the gin request querystring

func QueryParamBool

func QueryParamBool(c echo.Context, name string) bool

QueryParamBool retrieves a boolean param from the gin request querystring

func QueryParamBoolDefault

func QueryParamBoolDefault(c echo.Context, name string, def string) bool

func QueryParamFloatDefault

func QueryParamFloatDefault(c echo.Context, name string, def string) float64

func QueryParamInt

func QueryParamInt(c echo.Context, name string) int

QueryParamInt retrieves an integer param from the gin request querystring

func QueryParamIntDefault

func QueryParamIntDefault(c echo.Context, name string, def string) int

func QueryParamString

func QueryParamString(c echo.Context, name string) string

QueryParamString retrieves a string param from the gin request querystring

func QueryParamStringDefault

func QueryParamStringDefault(c echo.Context, name string, def string) string

func QueryString

func QueryString(c echo.Context, name string) string

QueryString retrieves a string param from the gin request querystring

func Setup

func Setup() error

func Start

func Start() error

func TickTock added in v0.4.1

func TickTock(tag string) func()

func WithTimeout

func WithTimeout(delegate func() interface{}, timeout time.Duration) (ret interface{}, ok bool)

WithTimeout runs a delegate function with a timeout,

Example: Wait for a channel

if value, ok := WithTimeout(func()interface{}{return <- inbox}, time.Second); ok {
    // returned
} else {
    // didn't return
}

Example: To send to a channel

_, ok := WithTimeout(func()interface{}{outbox <- myValue; return nil}, time.Second)
if !ok {
    // didn't send
}

Types

type Application

type Application struct {
	Config    *Config
	Log       *zap.SugaredLogger
	Reader    *reader.Reader
	Rift      *rift.Client
	Processor *Processor

	//golem:template:app/app_partial_definitions
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Routes
	Engine  *echo.Echo
	Default *echo.Group
	Router  *echo.Group

	// Models
	DB *Connector

	// Events
	Events *Events

	// Workers
	Workers *minion.Minion
}

func (*Application) Health

func (a *Application) Health() (map[string]bool, error)

func (*Application) IndexersCreate

func (a *Application) IndexersCreate(c echo.Context, subject *Indexer) error

func (*Application) IndexersCreateHandler

func (a *Application) IndexersCreateHandler(c echo.Context) error

func (*Application) IndexersDelete

func (a *Application) IndexersDelete(c echo.Context, id string) error

func (*Application) IndexersDeleteHandler

func (a *Application) IndexersDeleteHandler(c echo.Context) error

func (*Application) IndexersIndex

func (a *Application) IndexersIndex(c echo.Context, page int, limit int) error

func (*Application) IndexersIndexHandler

func (a *Application) IndexersIndexHandler(c echo.Context) error

Indexers (/indexers)

func (*Application) IndexersRefresh added in v0.4.1

func (a *Application) IndexersRefresh(c echo.Context, id string) error

func (*Application) IndexersRefreshHandler added in v0.4.1

func (a *Application) IndexersRefreshHandler(c echo.Context) error

func (*Application) IndexersSettings

func (a *Application) IndexersSettings(c echo.Context, id string, setting *Setting) error

func (*Application) IndexersSettingsHandler

func (a *Application) IndexersSettingsHandler(c echo.Context) error

func (*Application) IndexersShow

func (a *Application) IndexersShow(c echo.Context, id string) error

func (*Application) IndexersShowHandler

func (a *Application) IndexersShowHandler(c echo.Context) error

func (*Application) IndexersUpdate

func (a *Application) IndexersUpdate(c echo.Context, id string, subject *Indexer) error

func (*Application) IndexersUpdateHandler

func (a *Application) IndexersUpdateHandler(c echo.Context) error

func (*Application) ParserBatch added in v0.4.3

func (a *Application) ParserBatch(c echo.Context, batch *Batch) error

GET /parser/batch

func (*Application) ParserBatchHandler added in v0.4.3

func (a *Application) ParserBatchHandler(c echo.Context) error

func (*Application) ParserParse added in v0.4.1

func (a *Application) ParserParse(c echo.Context, title string, type_ string) error

GET /parser/parse

func (*Application) ParserParseHandler added in v0.4.1

func (a *Application) ParserParseHandler(c echo.Context) error

Parser (/parser)

func (*Application) ParserTitle added in v0.4.1

func (a *Application) ParserTitle(c echo.Context, title string, type_ string) error

GET /parser/title ParserTitle parses the only the title of a file and returns just title, season, episode, year.

func (*Application) ParserTitleHandler added in v0.4.1

func (a *Application) ParserTitleHandler(c echo.Context) error

func (*Application) PopularIndex

func (a *Application) PopularIndex(c echo.Context, interval string) error

GET /popular/:interval

func (*Application) PopularIndexHandler

func (a *Application) PopularIndexHandler(c echo.Context) error

func (*Application) PopularMovies added in v0.4.3

func (a *Application) PopularMovies(c echo.Context) error

func (*Application) PopularMoviesHandler added in v0.4.3

func (a *Application) PopularMoviesHandler(c echo.Context) error

Popular (/popular)

func (*Application) ReleasesCreate

func (a *Application) ReleasesCreate(c echo.Context, subject *Release) error

POST /releases/

func (*Application) ReleasesCreateHandler

func (a *Application) ReleasesCreateHandler(c echo.Context) error

func (*Application) ReleasesDelete

func (a *Application) ReleasesDelete(c echo.Context, id string) error

DELETE /releases/:id

func (*Application) ReleasesDeleteHandler

func (a *Application) ReleasesDeleteHandler(c echo.Context) error

func (*Application) ReleasesIndex

func (a *Application) ReleasesIndex(c echo.Context, page int, limit int) error

GET /releases/

func (*Application) ReleasesIndexHandler

func (a *Application) ReleasesIndexHandler(c echo.Context) error

Releases (/releases)

func (*Application) ReleasesSearch

func (a *Application) ReleasesSearch(c echo.Context, page int, limit int, source, kind, resolution, group, website string) error

GET /releases/

func (*Application) ReleasesSearchHandler

func (a *Application) ReleasesSearchHandler(c echo.Context) error

func (*Application) ReleasesSettings

func (a *Application) ReleasesSettings(c echo.Context, id string, setting *Setting) error

PATCH /releases/:id

func (*Application) ReleasesSettingsHandler

func (a *Application) ReleasesSettingsHandler(c echo.Context) error

func (*Application) ReleasesShow

func (a *Application) ReleasesShow(c echo.Context, id string) error

GET /releases/:id

func (*Application) ReleasesShowHandler

func (a *Application) ReleasesShowHandler(c echo.Context) error

func (*Application) ReleasesUpdate

func (a *Application) ReleasesUpdate(c echo.Context, id string, subject *Release) error

PUT /releases/:id

func (*Application) ReleasesUpdateHandler

func (a *Application) ReleasesUpdateHandler(c echo.Context) error

func (*Application) Routes

func (a *Application) Routes()

func (*Application) SourcesCreate

func (a *Application) SourcesCreate(c echo.Context) error

func (*Application) SourcesIndex

func (a *Application) SourcesIndex(c echo.Context, page int, limit int) error

func (*Application) SourcesIndexHandler

func (a *Application) SourcesIndexHandler(c echo.Context) error

Sources (/sources)

func (*Application) SourcesParse

func (a *Application) SourcesParse(c echo.Context, id string, categories string) error

func (*Application) SourcesParseHandler

func (a *Application) SourcesParseHandler(c echo.Context) error

func (*Application) SourcesRead

func (a *Application) SourcesRead(c echo.Context, id string, categories string) error

func (*Application) SourcesReadHandler

func (a *Application) SourcesReadHandler(c echo.Context) error

func (*Application) SourcesSearch

func (a *Application) SourcesSearch(c echo.Context, id string, query string, searchType string) error

func (*Application) SourcesSearchHandler

func (a *Application) SourcesSearchHandler(c echo.Context) error

func (*Application) SourcesShow

func (a *Application) SourcesShow(c echo.Context, id string) error

func (*Application) SourcesShowHandler

func (a *Application) SourcesShowHandler(c echo.Context) error

type Batch added in v0.4.3

type Batch struct {
	Type   string   `bson:"type" json:"type"`
	Titles []string `bson:"titles" json:"titles"`
}

type BatchResult added in v0.4.3

type BatchResult struct {
	Title string              `bson:"title" json:"title"`
	Info  *parser.TorrentInfo `bson:"info" json:"info"`
}

type Config

type Config struct {
	Mode   string `env:"MODE" envDefault:"dev"`
	Logger string `env:"LOGGER" envDefault:"dev"`
	Port   int    `env:"PORT" envDefault:"10080"`
	//golem:template:app/config_partial_struct
	// DO NOT EDIT. This section is managed by github.com/dashotv/golem.
	// Models (Database)
	Connections ConnectionSet `env:"CONNECTIONS"`

	// Router Auth
	Auth           bool   `env:"AUTH" envDefault:"false"`
	ClerkSecretKey string `env:"CLERK_SECRET_KEY"`
	ClerkToken     string `env:"CLERK_TOKEN"`

	// Events
	NatsURL string `env:"NATS_URL"`

	// Workers
	MinionConcurrency int    `env:"MINION_CONCURRENCY" envDefault:"10"`
	MinionDebug       bool   `env:"MINION_DEBUG" envDefault:"false"`
	MinionBufferSize  int    `env:"MINION_BUFFER_SIZE" envDefault:"100"`
	MinionURI         string `env:"MINION_URI"`
	MinionDatabase    string `env:"MINION_DATABASE"`
	MinionCollection  string `env:"MINION_COLLECTION"`

	JackettURL string   `env:"JACKETT_URL"`
	JackettKey string   `env:"JACKETT_KEY"`
	NZBGeekURL string   `env:"NZBGEEK_URL"`
	NZBGeekKey string   `env:"NZBGEEK_KEY"`
	RiftURL    string   `env:"RIFT_URL"`
	Words      []string `env:"WORDS"`
}

func (*Config) ConnectionFor

func (c *Config) ConnectionFor(name string) (*Connection, error)

func (*Config) Validate

func (c *Config) Validate() error

type Connection

type Connection struct {
	URI        string `yaml:"uri,omitempty"`
	Database   string `yaml:"database,omitempty"`
	Collection string `yaml:"collection,omitempty"`
}

func (*Connection) UnmarshalText

func (c *Connection) UnmarshalText(text []byte) error

type ConnectionSet

type ConnectionSet map[string]*Connection

func (*ConnectionSet) UnmarshalText

func (c *ConnectionSet) UnmarshalText(text []byte) error

type Connector

type Connector struct {
	Log     *zap.SugaredLogger
	Indexer *grimoire.Store[*Indexer]
	Release *grimoire.Store[*Release]
}

func NewConnector

func NewConnector(app *Application) (*Connector, error)

func (*Connector) IndexerActive

func (c *Connector) IndexerActive() ([]*Indexer, error)

func (*Connector) IndexerByName added in v0.4.1

func (c *Connector) IndexerByName(name string) (*Indexer, error)

func (*Connector) IndexerGet

func (c *Connector) IndexerGet(id string) (*Indexer, error)

func (*Connector) IndexerList

func (c *Connector) IndexerList(page, limit int) ([]*Indexer, int64, error)

func (*Connector) ReleaseGet

func (c *Connector) ReleaseGet(id string) (*Release, error)

func (*Connector) ReleaseList

func (c *Connector) ReleaseList(page, limit int) ([]*Release, int64, error)

func (*Connector) ReleaseSetting

func (c *Connector) ReleaseSetting(id, setting string, value bool) error

func (*Connector) ReleasesAll

func (c *Connector) ReleasesAll() ([]*Release, error)

func (*Connector) ReleasesPopular

func (c *Connector) ReleasesPopular(interval string) (map[string][]*Popular, error)

func (*Connector) ReleasesPopularMovies added in v0.4.1

func (c *Connector) ReleasesPopularMovies() ([]*PopularMovie, error)

func (*Connector) ReleasesPopularType

func (c *Connector) ReleasesPopularType(ctx context.Context, t string, date time.Time, limit int) ([]*Popular, error)

type Count

type Count struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Count) Inc

func (c *Count) Inc()

type Events

type Events struct {
	App      *Application
	Merc     *mercury.Mercury
	Log      *zap.SugaredLogger
	Releases chan *Release
}

func NewEvents

func NewEvents(app *Application) (*Events, error)

func (*Events) Send

func (e *Events) Send(topic EventsTopic, data any) error

func (*Events) Start

func (e *Events) Start() error

type EventsChannel

type EventsChannel string

type EventsTopic

type EventsTopic string

type H

type H map[string]any

stolen from gin gonic H is a shortcut for map[string]any

func (H) MarshalXML

func (h H) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML allows type H to be used with xml.Marshal.

type Indexer

type Indexer struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Name        string    `bson:"name" json:"name"`
	URL         string    `bson:"url" json:"url"`
	Active      bool      `bson:"active" json:"active"`
	Categories  []int     `bson:"categories" json:"categories"`
	ProcessedAt time.Time `bson:"processed_at" json:"processed_at"`
}

type ParseActive

type ParseActive struct {
	minion.WorkerDefaults[*ParseActive]
}

func (*ParseActive) Kind

func (j *ParseActive) Kind() string

func (*ParseActive) Work

func (j *ParseActive) Work(ctx context.Context, job *minion.Job[*ParseActive]) error

type ParseIndexer

type ParseIndexer struct {
	minion.WorkerDefaults[*ParseIndexer]
	ID    string `bson:"id" json:"id"`
	Title string `bson:"title" json:"title"`
}

func (*ParseIndexer) Kind

func (j *ParseIndexer) Kind() string

func (*ParseIndexer) Work

func (j *ParseIndexer) Work(ctx context.Context, job *minion.Job[*ParseIndexer]) error

type ParseRift

type ParseRift struct {
	minion.WorkerDefaults[*ParseRift]
}

func (*ParseRift) Kind

func (j *ParseRift) Kind() string

func (*ParseRift) Work

func (j *ParseRift) Work(ctx context.Context, job *minion.Job[*ParseRift]) error

type ParseRiftAll

type ParseRiftAll struct {
	minion.WorkerDefaults[*ParseRiftAll]
}

func (*ParseRiftAll) Kind

func (j *ParseRiftAll) Kind() string

func (*ParseRiftAll) Work

func (j *ParseRiftAll) Work(ctx context.Context, job *minion.Job[*ParseRiftAll]) error
type Popular struct {
	Title string `bson:"_id" json:"title"`
	Year  int    `bson:"year" json:"year"`
	Type  string `bson:"type" json:"type"`
	Count int    `bson:"count" json:"count"`
}

type PopularMovie added in v0.4.1

type PopularMovie struct {
	ID       *PopularMovieId `bson:"_id" json:"id"`
	Count    int             `bson:"count" json:"count"`
	Verified int             `bson:"verified" json:"verified"`
}

type PopularMovieId added in v0.4.1

type PopularMovieId struct {
	Title string `bson:"title" json:"title"`
	Year  int    `bson:"year" json:"year"`
}

type PopularResponse

type PopularResponse struct {
	Tv     []*Popular `bson:"tv" json:"tv"`
	Anime  []*Popular `bson:"anime" json:"anime"`
	Movies []*Popular `bson:"movies" json:"movies"`
}

type Processor

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

func (*Processor) Parse

func (p *Processor) Parse(source string, categories []int) ([]*Release, error)

func (*Processor) Process

func (p *Processor) Process(source string, list []*newznab.NZB) ([]*Release, error)

type Release

type Release struct {
	grimoire.Document `bson:",inline"` // includes default model settings
	//ID        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	//CreatedAt time.Time          `bson:"created_at" json:"created_at"`
	//UpdatedAt time.Time          `bson:"updated_at" json:"updated_at"`
	Type        string              `bson:"type" json:"type"`
	Source      string              `bson:"source" json:"source"`
	Title       string              `bson:"title" json:"title"`
	Year        int                 `bson:"year" json:"year"`
	Description string              `bson:"description" json:"description"`
	Size        int64               `bson:"size" json:"size"`
	View        string              `bson:"view" json:"view"`
	Download    string              `bson:"download" json:"download"`
	Infohash    string              `bson:"infohash" json:"infohash"`
	Season      int                 `bson:"season" json:"season"`
	Episode     int                 `bson:"episode" json:"episode"`
	Volume      int                 `bson:"volume" json:"volume"`
	Group       string              `bson:"group" json:"group"`
	Website     string              `bson:"website" json:"website"`
	Verified    bool                `bson:"verified" json:"verified"`
	Widescreen  bool                `bson:"widescreen" json:"widescreen"`
	Unrated     bool                `bson:"unrated" json:"unrated"`
	Uncensored  bool                `bson:"uncensored" json:"uncensored"`
	Bluray      bool                `bson:"bluray" json:"bluray"`
	ThreeD      bool                `bson:"threeD" json:"threeD"`
	Resolution  string              `bson:"resolution" json:"resolution"`
	Encodings   []string            `bson:"encodings" json:"encodings"`
	Quality     string              `bson:"quality" json:"quality"`
	Raw         *newznab.NZB        `bson:"raw" json:"raw"`
	Info        *parser.TorrentInfo `bson:"info" json:"info"`
	Downloader  string              `bson:"downloader" json:"downloader"`
	Checksum    string              `bson:"checksum" json:"checksum"`
	PublishedAt time.Time           `bson:"published_at" json:"published_at"`
}

func (*Release) Created

func (r *Release) Created(ctx context.Context) error

func (*Release) Updated

func (r *Release) Updated(ctx context.Context, result *mongo.UpdateResult) error

type Response

type Response struct {
	Error   bool        `json:"error"`
	Message string      `json:"message,omitempty"`
	Result  interface{} `json:"result,omitempty"`
	Total   int64       `json:"total,omitempty"`
}

type RunicSourceSimple

type RunicSourceSimple struct {
	Name string `json:"name"`
	Type string `json:"type"`
	URL  string `json:"url"`
}

type Setting

type Setting struct {
	Name  string `json:"name"`
	Value bool   `json:"value"`
}

type SettingsBatch

type SettingsBatch struct {
	IDs   []string `json:"ids"`
	Name  string   `json:"name"`
	Value bool     `json:"value"`
}

type UpdateIndexes

type UpdateIndexes struct {
	minion.WorkerDefaults[*UpdateIndexes]
}

func (*UpdateIndexes) Kind

func (j *UpdateIndexes) Kind() string

func (*UpdateIndexes) Timeout

func (j *UpdateIndexes) Timeout(job *minion.Job[*UpdateIndexes]) time.Duration

func (*UpdateIndexes) Work

func (j *UpdateIndexes) Work(ctx context.Context, job *minion.Job[*UpdateIndexes]) error

Jump to

Keyboard shortcuts

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