Documentation ¶
Index ¶
- Variables
- func ClearRegisteredModules()
- func GetDetails(v Detailable, log *logrus.Entry) error
- func GetTorrents(v Torrentable, log *logrus.Entry) error
- func RegisterModule(m Module)
- type BaseVideo
- func (bv *BaseVideo) GetFile() *File
- func (bv *BaseVideo) GetSubtitles() []*Subtitle
- func (bv *BaseVideo) GetTorrents() []*Torrent
- func (bv *BaseVideo) SetFile(f File)
- func (bv *BaseVideo) SetMetadata(metadata *VideoMetadata)
- func (bv *BaseVideo) SetSubtitles(subtitles []*Subtitle)
- func (bv *BaseVideo) SetTorrents(torrents []*Torrent)
- type Calendar
- type Detailable
- type Detailer
- type Downloader
- type Explorer
- type File
- func (f *File) Exists() bool
- func (f *File) Ext() string
- func (f *File) Filename() string
- func (f *File) Guess(movieConf MovieConfig, showConf ShowConfig, log *logrus.Entry) (Video, error)
- func (f *File) GuessMetadata(log *logrus.Entry) (*VideoMetadata, error)
- func (f *File) Ignore() error
- func (f *File) IgnorePath() string
- func (f *File) IsExcluded() bool
- func (f *File) IsIgnored() bool
- func (f *File) IsSymlink() bool
- func (f *File) IsVideo() bool
- func (f *File) MovieFanartPath() string
- func (f *File) MovieThumbPath() string
- func (f *File) NfoPath() string
- func (f *File) PathWithoutExt() string
- func (f *File) SubtitlePath(lang Language) string
- type FileConfig
- type FsNotifier
- type FsNotifierCtx
- type Guesser
- type LangInfo
- type Language
- type Module
- type ModuleStatus
- type ModuleType
- type Movie
- type MovieConfig
- type Notifier
- type Quality
- type Searcher
- type Show
- type ShowCalendar
- type ShowCalendarEpisode
- type ShowConfig
- type ShowEpisode
- type ShowSeason
- type Subtitlable
- type Subtitle
- type Subtitler
- type Torrent
- type TorrentResult
- type TorrentState
- type TorrentStatus
- type Torrentable
- type Torrenter
- type Video
- type VideoMetadata
- type VideoType
- type WishedMovie
- type WishedShow
- type Wishlist
- type WishlistConfig
- type Wishlister
Constants ¶
This section is empty.
Variables ¶
var ( ErrCalendarNotFound = errors.New("polochon: calendar not found") ErrCalendarModuleNotFound = errors.New("polochon: calendar module not found") )
Calendar error
var ( ErrGuessingVideo = errors.New("polochon: failed to guess video") ErrGuessingMetadata = errors.New("polochon: failed to guess metadata") )
Guess errors
var ( ErrMissingSubtitleLang = errors.New("polochon: no subtitle lang") ErrMissingSubtitlePath = errors.New("polochon: no subtitle path") ErrMissingSubtitleData = errors.New("polochon: no subtitle data") )
Subtitle errors
var ( // ErrDuplicateTorrent returned when the torrent is already added ErrDuplicateTorrent = errors.New("Torrent already added") )
var ErrGettingDetails = errors.New("polochon: failed to get details")
ErrGettingDetails is returned if polochon failed to get details of the video
var ErrNoSubtitleFound = errors.New("polochon: no subtitle found")
ErrNoSubtitleFound trigger when no subtitle found
var (
ErrNotAvailable = errors.New("modules: function not available")
)
Modules error
var (
ErrTorrentNotFound = errors.New("torrenter: failed to find torrent")
)
Torrenter error
Functions ¶
func ClearRegisteredModules ¶
func ClearRegisteredModules()
ClearRegisteredModules clears the registered modules from polochon. This function exists for test purposes only. Do not use this unless you know what you're doing.
func GetDetails ¶
func GetDetails(v Detailable, log *logrus.Entry) error
GetDetails helps getting infos for a Detailable object If there is an error, it will be of type *errors.Collector
func GetTorrents ¶
func GetTorrents(v Torrentable, log *logrus.Entry) error
GetTorrents helps getting the torrent files for a movie
func RegisterModule ¶
func RegisterModule(m Module)
RegisterModule is a function used by the module to register themselves
Types ¶
type BaseVideo ¶
type BaseVideo struct { File VideoMetadata Subtitles []*Subtitle `json:"subtitles"` Torrents []*Torrent `json:"torrents"` }
BaseVideo holds common characteristics of videos
func (*BaseVideo) GetSubtitles ¶
GetSubtitles implements the Video interface
func (*BaseVideo) GetTorrents ¶
GetTorrents implements the Video interface
func (*BaseVideo) SetMetadata ¶
func (bv *BaseVideo) SetMetadata(metadata *VideoMetadata)
SetMetadata implements the Video interface
func (*BaseVideo) SetSubtitles ¶
SetSubtitles implements the Video interface
func (*BaseVideo) SetTorrents ¶
SetTorrents implements the Video interface
type Detailable ¶
type Detailable interface {
GetDetailers() []Detailer
}
Detailable represents a ressource which can be detailed
type Downloader ¶
type Downloader interface { Module Download(*Torrent) error Remove(*Torrent) error List() ([]*Torrent, error) }
Downloader represent a interface for any downloader
type Explorer ¶
type Explorer interface { Module AvailableMovieOptions() []string GetMovieList(option string, log *logrus.Entry) ([]*Movie, error) AvailableShowOptions() []string GetShowList(option string, log *logrus.Entry) ([]*Show, error) }
Explorer is the interface explore new videos from different sources
type File ¶
type File struct { FileConfig `json:"-"` Path string `json:"-"` Size int64 `json:"size"` }
File handles polochon files
func NewFileWithConfig ¶
func NewFileWithConfig(path string, conf FileConfig) *File
NewFileWithConfig returns a new file from a path
func (*File) Guess ¶
func (f *File) Guess(movieConf MovieConfig, showConf ShowConfig, log *logrus.Entry) (Video, error)
Guess video information from file
func (*File) GuessMetadata ¶
func (f *File) GuessMetadata(log *logrus.Entry) (*VideoMetadata, error)
GuessMetadata guesses the metadata of a file
func (*File) Ignore ¶
Ignore create a ".ignore" file next to the file to indicate that it is ignored
func (*File) IgnorePath ¶
IgnorePath is an helper to get the ignore file path
func (*File) IsExcluded ¶
IsExcluded returns true if the file contains an excluded word
func (*File) MovieFanartPath ¶
MovieFanartPath returns the movie fanart path
func (*File) MovieThumbPath ¶
MovieThumbPath returns the movie thumb path
func (*File) PathWithoutExt ¶
PathWithoutExt returns the file path without the file extension
func (*File) SubtitlePath ¶
SubtitlePath is an helper to get the subtitle path from the filename
type FileConfig ¶
type FileConfig struct { ExcludeFileContaining []string VideoExtensions []string AllowedExtensionsToDelete []string Guessers []Guesser // contains filtered or unexported fields }
FileConfig represents the configuration for a file
func (*FileConfig) IsVideo ¶
func (fc *FileConfig) IsVideo(filename string) bool
IsVideo returns true if the file is considered a video based on the extension of the file
type FsNotifier ¶
type FsNotifier interface { Module Watch(watchPath string, ctx FsNotifierCtx, log *logrus.Entry) error }
FsNotifier is an interface to notify on filesystem change
type FsNotifierCtx ¶
FsNotifierCtx is the context of the notifier
type Guesser ¶
type Guesser interface { Module Guess(File, MovieConfig, ShowConfig, *logrus.Entry) (Video, error) GuessMetadata(*File, *logrus.Entry) (*VideoMetadata, error) }
Guesser is an interface which allows to get informations to create a video from a file
type LangInfo ¶
type LangInfo struct {
ShortForm string
}
LangInfo represents differents infos of a Lang
type Module ¶
type Module interface { Init(params []byte) error Name() string Status() (ModuleStatus, error) }
Module type, all modules must implement it
type ModuleStatus ¶
type ModuleStatus string
ModuleStatus holds modules status
const ( StatusOK ModuleStatus = "ok" StatusNotImplemented ModuleStatus = "not_implemented" StatusFail ModuleStatus = "fail" )
Available modules statuses
type ModuleType ¶
type ModuleType string
ModuleType holds modules type
const ( TypeTorrenter ModuleType = "torrenter" TypeDetailer ModuleType = "detailer" TypeGuesser ModuleType = "guesser" TypeFsNotifier ModuleType = "fsnotifier" TypeNotifier ModuleType = "notifier" TypeSubtitler ModuleType = "subtitler" TypeWishlister ModuleType = "wishlister" TypeDownloader ModuleType = "downloader" TypeCalendar ModuleType = "calendar" TypeExplorer ModuleType = "explorer" TypeSearcher ModuleType = "searcher" )
Available modules types
type Movie ¶
type Movie struct { MovieConfig `json:"-"` BaseVideo ImdbID string `json:"imdb_id"` OriginalTitle string `json:"original_title"` Plot string `json:"plot"` Rating float32 `json:"rating"` Runtime int `json:"runtime"` SortTitle string `json:"sort_title"` Tagline string `json:"tag_line"` Thumb string `json:"thumb"` Fanart string `json:"fanart"` Title string `json:"title"` TmdbID int `json:"tmdb_id"` Votes int `json:"votes"` Year int `json:"year"` Genres []string `json:"genres"` }
Movie represents a movie
func NewMovieFromFile ¶
func NewMovieFromFile(movieConfig MovieConfig, file File) *Movie
NewMovieFromFile returns a new movie from a file
type MovieConfig ¶
type MovieConfig struct { Torrenters []Torrenter Detailers []Detailer Subtitlers []Subtitler Explorers []Explorer Searchers []Searcher }
MovieConfig represents the configuration for a movie
func (*MovieConfig) GetDetailers ¶
func (m *MovieConfig) GetDetailers() []Detailer
GetDetailers implements the Detailable interface
func (*MovieConfig) GetExplorers ¶
func (m *MovieConfig) GetExplorers() []Explorer
GetExplorers implements the Explorer interface
func (*MovieConfig) GetSearchers ¶
func (m *MovieConfig) GetSearchers() []Searcher
GetSearchers implements the Searcher interface
func (*MovieConfig) GetSubtitlers ¶
func (m *MovieConfig) GetSubtitlers() []Subtitler
GetSubtitlers implements the Subtitlable interface
func (*MovieConfig) GetTorrenters ¶
func (m *MovieConfig) GetTorrenters() []Torrenter
GetTorrenters implements the Torrentable interface
type Quality ¶
type Quality string
Quality represents the qualities of a video
const ( Quality480p Quality = "480p" Quality720p Quality = "720p" Quality1080p Quality = "1080p" Quality2160p Quality = "2160p" Quality3D Quality = "3D" )
Possible qualities
func StringToQuality ¶
StringToQuality returns a Quality from a string
type Searcher ¶
type Searcher interface { Module SearchMovie(key string, log *logrus.Entry) ([]*Movie, error) SearchShow(key string, log *logrus.Entry) ([]*Show, error) }
Searcher is the interface to search shows or movies from different sources
type Show ¶
type Show struct { ShowConfig `json:"-"` Title string `json:"title"` Rating float32 `json:"rating"` Plot string `json:"plot"` URL string `json:"-"` TvdbID int `json:"tvdb_id"` ImdbID string `json:"imdb_id"` Year int `json:"year"` FirstAired *time.Time `json:"first_aired"` Banner string `json:"-"` Fanart string `json:"-"` Poster string `json:"-"` Episodes []*ShowEpisode `json:"-"` }
Show represents a tv show
func NewShowFromEpisode ¶
func NewShowFromEpisode(e *ShowEpisode) *Show
NewShowFromEpisode will return a show from an episode
func (*Show) GetCalendar ¶
func (s *Show) GetCalendar(log *logrus.Entry) (*ShowCalendar, error)
GetCalendar gets the calendar for the show If there is an error, it will be of type *errors.Error
type ShowCalendar ¶
type ShowCalendar struct { ImdbID string Episodes []*ShowCalendarEpisode }
ShowCalendar holds the calendar for a show
func NewShowCalendar ¶
func NewShowCalendar(imdbID string) *ShowCalendar
NewShowCalendar returns a new show calendar
type ShowCalendarEpisode ¶
ShowCalendarEpisode holds the episode calendar infos
func (*ShowCalendarEpisode) IsAvailable ¶
func (sc *ShowCalendarEpisode) IsAvailable() bool
IsAvailable tells if the episode is currently available
func (*ShowCalendarEpisode) IsOlder ¶
func (sc *ShowCalendarEpisode) IsOlder(ws *WishedShow) bool
IsOlder returns true if the given show is older than the calendar episode
type ShowConfig ¶
type ShowConfig struct { Calendar Calendar Detailers []Detailer Subtitlers []Subtitler Torrenters []Torrenter Explorers []Explorer Searchers []Searcher }
ShowConfig represents the configuration for a show and its show episodes
func (*ShowConfig) GetDetailers ¶
func (s *ShowConfig) GetDetailers() []Detailer
GetDetailers implements the Detailable interface
func (*ShowConfig) GetExplorers ¶
func (s *ShowConfig) GetExplorers() []Explorer
GetExplorers implements the Explorer interface
func (*ShowConfig) GetSearchers ¶
func (s *ShowConfig) GetSearchers() []Searcher
GetSearchers implements the Searcher interface
func (*ShowConfig) GetSubtitlers ¶
func (s *ShowConfig) GetSubtitlers() []Subtitler
GetSubtitlers implements the Subtitlable interface
func (*ShowConfig) GetTorrenters ¶
func (s *ShowConfig) GetTorrenters() []Torrenter
GetTorrenters implements the Torrentable interface
type ShowEpisode ¶
type ShowEpisode struct { ShowConfig `json:"-"` BaseVideo Title string `json:"title"` ShowTitle string `json:"show_title"` Season int `json:"season"` Episode int `json:"episode"` TvdbID int `json:"tvdb_id"` Aired string `json:"aired"` Plot string `json:"plot"` Runtime int `json:"runtime"` Thumb string `json:"thumb"` Rating float32 `json:"rating"` ShowImdbID string `json:"show_imdb_id"` ShowTvdbID int `json:"show_tvdb_id"` EpisodeImdbID string `json:"imdb_id"` Show *Show `json:"-"` }
ShowEpisode represents a tvshow episode
func NewShowEpisode ¶
func NewShowEpisode(showConf ShowConfig) *ShowEpisode
NewShowEpisode returns a new show episode
func NewShowEpisodeFromFile ¶
func NewShowEpisodeFromFile(showConf ShowConfig, file File) *ShowEpisode
NewShowEpisodeFromFile returns a new show episode from a file
type ShowSeason ¶
type ShowSeason struct { ShowConfig `json:"-"` ShowImdbID string `json:"show_imdb_id"` Season int `json:"season"` Banner string `json:"-"` Fanart string `json:"-"` Poster string `json:"-"` }
ShowSeason represents a show season
func NewShowSeason ¶
func NewShowSeason(conf ShowConfig) *ShowSeason
NewShowSeason returns a new show season
type Subtitlable ¶
Subtitlable represents a ressource which can be subtitled
type Subtitle ¶
type Subtitle struct { File // Embedded is true if the subtitle is embedded in the video file Embedded bool `json:"embedded"` Data []byte `json:"-"` Lang Language `json:"lang"` Video Video `json:"-"` }
Subtitle represents a subtitle
func GetSubtitle ¶
GetSubtitle gets the subtitles of a video in the given languages
func NewSubtitleFromVideo ¶
NewSubtitleFromVideo returns a subtitle from a video
type Subtitler ¶
type Subtitler interface { Module GetSubtitle(interface{}, Language, *logrus.Entry) (*Subtitle, error) }
Subtitler all subtitler must implement it
type Torrent ¶
type Torrent struct { ImdbID string `json:"imdb_id"` Type VideoType `json:"type"` Season int `json:"season"` Episode int `json:"episode"` Quality Quality `json:"quality"` Result *TorrentResult `json:"result"` Status *TorrentStatus `json:"status"` }
Torrent represents a torrent file
func ChooseTorrentFromQualities ¶
ChooseTorrentFromQualities chooses the best torrent matching the given qualities
func FilterTorrents ¶
FilterTorrents filters the torrents to keep only the best ones
func (*Torrent) HasVideo ¶
HasVideo returns true if the torrent has enough information to return a video
func (*Torrent) RatioReached ¶
RatioReached tells if the given ratio has been reached
type TorrentResult ¶
type TorrentResult struct { Name string `json:"name"` URL string `json:"url"` Seeders int `json:"seeders"` Leechers int `json:"leechers"` Source string `json:"source"` UploadUser string `json:"upload_user"` Size int `json:"size"` }
TorrentResult represents a torrent result from a search
type TorrentState ¶
type TorrentState string
TorrentState represents the torrent state
const ( TorrentStateStopped TorrentState = "stopped" TorrentStatePending TorrentState = "pending" TorrentStateChecking TorrentState = "checking" TorrentStateDownloadPending TorrentState = "download_pending" TorrentStateDownloading TorrentState = "downloading" TorrentStateSeedPending TorrentState = "seed_pending" TorrentStateSeeding TorrentState = "seeding" )
Possible torrent statuses
type TorrentStatus ¶
type TorrentStatus struct { ID string `json:"id"` Name string `json:"name"` Ratio float32 `json:"ratio"` IsFinished bool `json:"is_finished"` FilePaths []string `json:"file_paths"` DownloadRate int `json:"download_rate"` UploadRate int `json:"upload_rate"` TotalSize int `json:"total_size"` DownloadedSize int `json:"downloaded_size"` UploadedSize int `json:"uploaded_size"` PercentDone float32 `json:"percent_done"` State TorrentState `json:"state"` }
TorrentStatus represents the status of the downloaded torrent
type Torrentable ¶
type Torrentable interface {
GetTorrenters() []Torrenter
}
Torrentable represents a resource which can be torrented
type Torrenter ¶
type Torrenter interface { Module GetTorrents(interface{}, *logrus.Entry) error SearchTorrents(string) ([]*Torrent, error) }
Torrenter is an interface which allows to get torrent for a movie or a show
type Video ¶
type Video interface { Subtitlable Detailable Torrentable SetFile(f File) GetFile() *File SetMetadata(*VideoMetadata) SetSubtitles([]*Subtitle) GetSubtitles() []*Subtitle SetTorrents([]*Torrent) GetTorrents() []*Torrent }
Video represents a generic video type
type VideoMetadata ¶
type VideoMetadata struct { DateAdded time.Time `json:"date_added"` Quality Quality `json:"quality"` ReleaseGroup string `json:"release_group"` AudioCodec string `json:"audio_codec"` VideoCodec string `json:"video_codec"` Container string `json:"container"` EmbeddedSubtitles []Language `json:"embedded_subtitles"` }
VideoMetadata represents the metadata of a video
func (*VideoMetadata) Update ¶
func (v *VideoMetadata) Update(metadata *VideoMetadata)
Update updates the metadata with new values
type WishedMovie ¶
WishedMovie represents a wished movie and its expected qualities
type WishedShow ¶
type WishedShow struct { ImdbID string `json:"imdb_id"` Season int `json:"season_from"` Episode int `json:"episode_from"` Qualities []Quality `json:"qualities"` }
WishedShow represents a wished show, its expected qualities and the season / episode to start tracking
type Wishlist ¶
type Wishlist struct { WishlistConfig `xml:"-" json:"-"` Movies []*WishedMovie `json:"movies"` Shows []*WishedShow `json:"shows"` // contains filtered or unexported fields }
Wishlist represents a user wishlist
func NewWishlist ¶
func NewWishlist(wishlistConfig WishlistConfig, log *logrus.Entry) *Wishlist
NewWishlist returns a new wishlist
func (*Wishlist) AddMovie ¶
func (w *Wishlist) AddMovie(movie *WishedMovie) error
AddMovie helps add a movie to the movie list, if the movie is already in the list, nothing happens
func (*Wishlist) AddShow ¶
func (w *Wishlist) AddShow(show *WishedShow) error
AddShow adds a show to the show list, if the show is already in the list, the oldest is kept or added
type WishlistConfig ¶
type WishlistConfig struct { Wishlisters []Wishlister ShowDefaultQualities []Quality `yaml:"show_default_qualities"` MovieDefaultQualities []Quality `yaml:"movie_default_qualities"` }
WishlistConfig represents the wishlist configurations
type Wishlister ¶
type Wishlister interface { Module GetMovieWishlist(*logrus.Entry) ([]*WishedMovie, error) GetShowWishlist(*logrus.Entry) ([]*WishedShow, error) }
Wishlister is an interface which defines the behavior of the wishlister modules