server

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserKey is the session key for user data
	UserKey = "user"
)

Variables

This section is empty.

Functions

func NewServer

func NewServer(cookieSecret string, mainHandler *MainHandler, adminHandler *AdminHandler, filmHandler *FilmHandler, personHandler *PersonHandler, rarbgHandler *RarbgHandler, db OwnerStorer) *gin.Engine

NewServer initializes the server

func RenderHTML

func RenderHTML(c *gin.Context, code int, name string, obj gin.H)

RenderHTML renders HTML pages and adds useful objects for templates

Types

type AdminFilmManager

type AdminFilmManager interface {
	CacheFilms()

	EditFilmWithLink(filmID, inputUrl string) error
}

type AdminHandler

func (AdminHandler) GETAdmin

func (ah AdminHandler) GETAdmin(c *gin.Context)

GETAdmin displays the admin page

func (AdminHandler) GETAdminUser

func (ah AdminHandler) GETAdminUser(c *gin.Context)

GETAdminUser displays the user edit page

func (AdminHandler) GETAdminVolume

func (ah AdminHandler) GETAdminVolume(c *gin.Context)

GETAdminVolume displays the volume edit page

func (AdminHandler) POSTDeleteUser

func (ah AdminHandler) POSTDeleteUser(c *gin.Context)

POSTDeleteUser deletes a user from a POST request

func (AdminHandler) POSTDeleteVolume

func (ah AdminHandler) POSTDeleteVolume(c *gin.Context)

POSTDeleteVolume deletes a volume from a POST request

func (AdminHandler) POSTEditFilmOnline

func (ah AdminHandler) POSTEditFilmOnline(c *gin.Context)

POSTEditFilmOnline handle editing a film from online link

func (AdminHandler) POSTEditUser

func (ah AdminHandler) POSTEditUser(c *gin.Context)

POSTEditUser handles editing (and adding) a user from POST request

func (AdminHandler) POSTEditVolume

func (ah AdminHandler) POSTEditVolume(c *gin.Context)

POSTEditVolume handles editing (and adding) a volume from POST request

func (AdminHandler) POSTReloadCache

func (ah AdminHandler) POSTReloadCache(c *gin.Context)

POSTReloadCache reloads the cache

type AdminUserManager

type AdminUserManager interface {
	GetUsers() ([]model.User, error)
	GetUser(userHexID string) (*model.User, error)

	CreateUser(username, password1, password2 string, isAdmin, isOwner bool) (*model.User, error)

	DeleteUser(userHexID string) error
}

type AdminVolumeManager

type AdminVolumeManager interface {
	GetVolumes() ([]model.Volume, error)
	GetVolume(volumeHexID string) (*model.Volume, error)

	CreateVolume(name, path string, isRecursive bool, mediaType string) error

	DeleteVolume(volumeHexID string) error
}

type FilmHandler

type FilmHandler struct {
	FilmManager
	FilmPersonManager

	Filterer
	FilmPaginater[model.Film]
	// contains filtered or unexported fields
}

func (FilmHandler) GETFilm

func (fh FilmHandler) GETFilm(c *gin.Context)

GETFilm displays information about a film

func (FilmHandler) GETFilmDownload

func (fh FilmHandler) GETFilmDownload(c *gin.Context)

GETFilmDownload downloads a film file

func (FilmHandler) GETFilms

func (fh FilmHandler) GETFilms(c *gin.Context)

GETFilms displays the list of films

func (FilmHandler) GETSubtitleDownload

func (fh FilmHandler) GETSubtitleDownload(c *gin.Context)

GETSubtitleDownload downloads a subtitle file

type FilmManager

type FilmManager interface {
	GetFilm(filmHexID string) (*model.Film, error)
	GetFilmPath(filmHexID, filmIndex string) (string, error)
	GetFilmSubtitlePath(filmHexID, filmIndex, subtitleIndex string) (string, error)

	GetFilms() []model.Film
	GetFilmsFiltered(years []int, genre, country, search string) (films []model.Film)
}

type FilmPaginater added in v1.0.3

type FilmPaginater[T model.Film] interface {
	GetPagination(currentPage int64, items []T) ([]T, []model.Pagination)
}

type FilmPersonManager

type FilmPersonManager interface {
	GetFilmStaff(*model.Film) ([]model.Cast, []model.Person, []model.Person, error)
}

type Filterer

type Filterer interface {
	ParseParamsFilters(params string) (yearFilter string, years []int, genre, country string, page int, err error)
	GetCountryName(code string) string

	GetCountries() []string
	GetDecades() []model.Decade
	GetGenres() []string
}

type MainCacher

type MainCacher interface {
	GetCachedPath(filePath string) string
}

type MainHandler

type MainHandler struct {
	MainCacher
	MainUserManager
}

func NewMainHandler

func NewMainHandler(mc MainCacher, mum MainUserManager) *MainHandler

func (MainHandler) Error404

func (mh MainHandler) Error404(c *gin.Context)

Error404 displays the 404 page

func (MainHandler) GETCache

func (mh MainHandler) GETCache(c *gin.Context)

GETCache serves the cached file

func (MainHandler) GETIndex

func (mh MainHandler) GETIndex(c *gin.Context)

GETIndex displays the index page

func (MainHandler) GETLogin

func (mh MainHandler) GETLogin(c *gin.Context)

GETLogin displays the registration page

func (MainHandler) GETLogout

func (mh MainHandler) GETLogout(c *gin.Context)

GETLogout logs out the user and redirects to index

func (MainHandler) GETSettings

func (mh MainHandler) GETSettings(c *gin.Context)

GETSettings displays the user settings page

func (MainHandler) GETStart

func (mh MainHandler) GETStart(c *gin.Context)

GetStart allows regsitration of first user (admin & owner)

func (MainHandler) POSTLogin

func (mh MainHandler) POSTLogin(c *gin.Context)

POSTLogin handles login from POST request

func (MainHandler) POSTSetPassword

func (mh MainHandler) POSTSetPassword(c *gin.Context)

POSTSetPassword handles changing password from POST request

func (MainHandler) POSTStart

func (mh MainHandler) POSTStart(c *gin.Context)

POSTStart handles registration (only available for first account)

type MainUserManager

type MainUserManager interface {
	IsOwnerPresent() (bool, error)
	CreateOwner(username, password1, password2 string) (*model.User, error)
	CheckLogin(username, password string) (user *model.User, err error)
	SetUserPassword(username, oldPassword, password1, password2 string) error
}

type OwnerStorer

type OwnerStorer interface {
	IsOwnerPresent() (bool, error)
}

type PersonFilmManager

type PersonFilmManager interface {
	GetFilmsWithActor(actorID int64) (films []model.Film)
	GetFilmsWithDirector(directorID int64) (films []model.Film)
	GetFilmsWithWriter(writerID int64) (films []model.Film)
}

type PersonHandler

func (PersonHandler) GETActor

func (ph PersonHandler) GETActor(c *gin.Context)

GETActor displays the actor's bio and the films they star in

func (PersonHandler) GETDirector

func (ph PersonHandler) GETDirector(c *gin.Context)

HandleGetDirector displays the directors's bio and the films they directed

func (PersonHandler) GETPeople

func (ph PersonHandler) GETPeople(c *gin.Context)

HandleGETFilms displays the list of people

func (PersonHandler) GETPerson

func (ph PersonHandler) GETPerson(c *gin.Context)

GETPerson displays the actor's bio and the films they star in

func (PersonHandler) GETWriter

func (ph PersonHandler) GETWriter(c *gin.Context)

HandleGetWriter displays the writer's bio and the films they wrote

type PersonManager

type PersonManager interface {
	GetPeople() []model.Person

	GetPerson(personHexID string) (*model.Person, error)
}

type PersonPaginater added in v1.0.3

type PersonPaginater[T model.Person] interface {
	GetPagination(currentPage int64, items []T) ([]T, []model.Pagination)
}

type RarbgHandler added in v1.1.0

type RarbgHandler struct {
	TorrentStorer
	// contains filtered or unexported fields
}

func NewRarbgHandler added in v1.1.0

func NewRarbgHandler(ts TorrentStorer, torznabAPIKey string) *RarbgHandler

func (RarbgHandler) GETTorrents added in v1.1.0

func (rh RarbgHandler) GETTorrents(c *gin.Context)

GETTorrents displays the list of torrents

func (RarbgHandler) GETTorznab added in v1.1.0

func (rh RarbgHandler) GETTorznab(c *gin.Context)

type TorrentStorer added in v1.1.0

type TorrentStorer interface {
	SearchTorrents(ctx context.Context, search, category string, page uint) ([]model.RarbgTorrent, error)
	GetTorrents(ctx context.Context, imdbID string, offset, limit int64) ([]model.RarbgTorrent, error)
	GetAllTVTorrents(ctx context.Context, offset, limit int64) (torrents []model.RarbgTorrent, err error)
	GetTVTorrents(ctx context.Context, imdbID, season, episode string, offset, limit int64) (torrents []model.RarbgTorrent, err error)
}

Jump to

Keyboard shortcuts

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