media

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt added in v1.0.0

func AbsInt(a int) int

AbsInt returns the absoulute value of an integer

func IsExistsErr added in v1.0.0

func IsExistsErr(err error) bool

IsExistsErr returns true if the error is of type *ErrExists

func IsMediaError added in v1.0.0

func IsMediaError(err error) bool

IsMediaError returns true if the error is of type *media.Error

func IsSample

func IsSample(m types.Media) bool

IsSample return wether the media is a sample video of the real media. The media is a sample if any of the tags contains "sample" (case insensitive)

func IsUnknown added in v1.0.0

func IsUnknown(err error) bool

IsUnknown returns true if the error is of type *ErrUnknownMedia

func NewExistsErr added in v1.0.0

func NewExistsErr() error

NewExistsErr return a new error indicating a conflict with existing media

func NewFromFilename added in v1.0.0

func NewFromFilename(name string) (types.Media, error)

NewFromFilename parses the filename and returns a media object. The filename (with extenstion) may describe either some video material (.avi, .mkv, .mp4) or a subtitle (.srt).

func NewFromString added in v1.0.0

func NewFromString(str string) (types.Media, error)

NewFromString returns a media object parsed from a string describing the media. This could be the name of a file (without extension). It is assumed the string describes some video material (movie or episode)

func NewLocalFile added in v1.0.0

func NewLocalFile(path string) (types.LocalMedia, error)

NewLocalFile parses a filepath into a local media object. The path may be an absolute or relative path. The filename of the media must contain appropriate information to describe the media file.

func NewLocalSubtitle

func NewLocalSubtitle(path string) (types.LocalSubtitle, error)

NewLocalSubtitle returns a new local subtitle

func NewUnknownErr added in v1.0.0

func NewUnknownErr() error

NewUnknownErr returns a new error indicating unknown media

Types

type Episode added in v1.0.0

type Episode struct {
	Metadata
	TypeNone
	NameX        string
	EpisodeNameX string
	EpisodeX     int
	SeasonX      int
}

Episode represents an episode from a TV show

func NewEpisode

func NewEpisode(filename string) (*Episode, error)

NewEpisode parses media info from a filename (without extension). The filename must describe the episode adequately (e.g. must contain season and episode numbers)

func (*Episode) Episode added in v1.0.0

func (e *Episode) Episode() int

Episode is the episode number in the season

func (*Episode) EpisodeName added in v1.0.0

func (e *Episode) EpisodeName() string

EpisodeName is the name of the episode

func (*Episode) Identity added in v1.0.0

func (e *Episode) Identity() string

Identity returns the identity string of the episode which can be used for hashing, caching ect.

func (*Episode) IsVideo added in v1.0.0

func (e *Episode) IsVideo() bool

IsVideo returns true since an TV episode is also a video

func (*Episode) MarshalJSON added in v1.0.0

func (e *Episode) MarshalJSON() (b []byte, err error)

MarshalJSON returns the JSON representation of an episode

func (*Episode) Merge added in v1.0.0

func (e *Episode) Merge(other types.Media) error

Merge merges metadata from another episode

func (*Episode) Meta added in v1.0.0

func (e *Episode) Meta() types.Metadata

Meta returns the metadata interface for the episode

func (*Episode) Season added in v1.0.0

func (e *Episode) Season() int

Season is the season number of the show

func (*Episode) Similar added in v1.0.0

func (e *Episode) Similar(other types.Media) bool

Similar returns true if other media is also an episode from the same season and with the same episode number

func (*Episode) String added in v1.0.0

func (e *Episode) String() string

func (*Episode) TVShow added in v1.0.0

func (e *Episode) TVShow() string

TVShow is the name of the TV show

func (*Episode) TypeEpisode added in v1.0.0

func (e *Episode) TypeEpisode() (types.Episode, bool)

TypeEpisode returns true since an episode is an episode

type ErrExists added in v1.0.0

type ErrExists struct{}

ErrExists is an error for when media already exists in a library

func (*ErrExists) Error added in v1.0.0

func (e *ErrExists) Error() string

type ErrUnknown added in v1.0.0

type ErrUnknown struct{}

ErrUnknown is an error for unrecognized media

func (*ErrUnknown) Error added in v1.0.0

func (e *ErrUnknown) Error() string

type Error added in v1.0.0

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

Error is an error concerning some media

func NewError added in v1.0.0

func NewError(err error, media types.Media) *Error

NewError returns a new erro

func (*Error) Error added in v1.0.0

func (err *Error) Error() string

Error returns the error message of the media error

type File

type File struct {
	os.FileInfo
	types.Media
	FilePath
}

File represents a local media file on disk

func (*File) MarshalJSON

func (f *File) MarshalJSON() (b []byte, err error)

MarshalJSON returns the JSON represnetation of a media file

func (*File) String

func (f *File) String() string

String returns a string representation of the media in the file

type FilePath added in v0.2.0

type FilePath string

FilePath is a string describing a path to a file

func (FilePath) Open added in v1.0.0

func (p FilePath) Open() (io.ReadCloser, error)

Open opens the file and returns a readcloser

func (FilePath) Path added in v0.2.0

func (p FilePath) Path() string

Path return the path to a file

type LocalSubtitle

type LocalSubtitle struct {
	os.FileInfo
	types.Pather
	*Subtitle
}

LocalSubtitle represents a subtitle stored on disk

func (*LocalSubtitle) MarshalJSON

func (l *LocalSubtitle) MarshalJSON() (b []byte, err error)

MarshalJSON returns a JSON representation of the subtitle

type Metadata

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

Metadata provides release information for media

func ParseMetadata

func ParseMetadata(tags string) Metadata

ParseMetadata generates metadata from a string

func ParseMetadataIndex added in v1.0.0

func ParseMetadataIndex(tags string) (int, Metadata)

ParseMetadataIndex generates metadata from a string and returns the index of the first occurrence of metdata information in the string

func (Metadata) AllTags

func (m Metadata) AllTags() []string

AllTags returns all metadata as a list of tags

func (Metadata) Codec

func (m Metadata) Codec() codec.Tag

Codec returns the codec

func (Metadata) Group

func (m Metadata) Group() string

Group returns the release group

func (Metadata) MarshalJSON

func (m Metadata) MarshalJSON() (b []byte, err error)

MarshalJSON returns a JSON representation of metadata

func (Metadata) Misc added in v1.0.0

func (m Metadata) Misc() misc.List

Misc returns miscellaneous media tags for the media

func (Metadata) Quality

func (m Metadata) Quality() quality.Tag

Quality returns the quality of the media

func (Metadata) Source

func (m Metadata) Source() source.Tag

Source returns the source of the media

func (Metadata) String

func (m Metadata) String() string

String return a description of the metadata

type Movie added in v1.0.0

type Movie struct {
	Metadata
	TypeNone
	NameX string
	YearX int
	// contains filtered or unexported fields
}

Movie represents a movie file

func NewMovie

func NewMovie(filename string) (*Movie, error)

NewMovie parses media info from a filename (without extension). The filename must describe the movie adequately (e.g. must contain the release year)

func (*Movie) Identity added in v1.0.0

func (m *Movie) Identity() string

Identity returns an identity string for the movie which can be used for hashing, caching ect.

func (*Movie) IsVideo added in v1.0.0

func (m *Movie) IsVideo() bool

IsVideo returns true, since a movie is also a video

func (*Movie) MarshalJSON added in v1.0.0

func (m *Movie) MarshalJSON() (b []byte, err error)

MarshalJSON return the JSON representation of a movie

func (*Movie) Merge added in v1.0.0

func (m *Movie) Merge(other types.Media) error

Merge merges metadata from another movie into this one

func (*Movie) Meta added in v1.0.0

func (m *Movie) Meta() types.Metadata

Meta returnes the metadata interface for a movie

func (*Movie) MovieName added in v1.0.0

func (m *Movie) MovieName() string

MovieName is the name of the movie

func (*Movie) Similar added in v1.0.0

func (m *Movie) Similar(other types.Media) bool

Similar returns true if two movies are within 1 year of each other

func (*Movie) String added in v1.0.0

func (m *Movie) String() string

func (*Movie) TypeMovie added in v1.0.0

func (m *Movie) TypeMovie() (types.Movie, bool)

TypeMovie returns true, since a movie is a movie

func (*Movie) Year added in v1.0.0

func (m *Movie) Year() int

Year is the release year of the movie

type Subtitlable added in v1.0.0

type Subtitlable interface {
	IsVideo() bool
}

Subtitlable is an dummy interface for media which supports subtitles

type Subtitle added in v1.0.0

type Subtitle struct {
	TypeNone
	// contains filtered or unexported fields
}

Subtitle represents the information about a subtitle

func NewSubtitle added in v1.0.0

func NewSubtitle(str string) (*Subtitle, error)

NewSubtitle returns subtitle information by parsing the string. The string should describe some video material sufficiently (without extension). If the string ends with a language tag (e.g. .en .es. de) then the language will be parsed

func (*Subtitle) ForMedia added in v1.0.0

func (l *Subtitle) ForMedia() types.Media

ForMedia returns the media the subtitle is matched against

func (*Subtitle) HearingImpaired added in v1.0.0

func (l *Subtitle) HearingImpaired() bool

HearingImpaired returns false since this information in unparseable from a simple filename

func (*Subtitle) Identity added in v1.0.0

func (l *Subtitle) Identity() string

Identity returns the identity string for the media which the subtitle matches

func (*Subtitle) Language added in v1.0.0

func (l *Subtitle) Language() language.Tag

Language returns the language of the subtitle

func (*Subtitle) Merge added in v1.0.0

func (l *Subtitle) Merge(other types.Media) error

Merge merges the media belonging to the subtitle

func (*Subtitle) Meta added in v1.0.0

func (l *Subtitle) Meta() types.Metadata

Meta returns the metadata for media which the subtitle belongs

func (*Subtitle) Similar added in v1.0.0

func (l *Subtitle) Similar(other types.Media) bool

Similar returns true if other media is also a subtitle for the a similar media

func (*Subtitle) String added in v1.0.0

func (l *Subtitle) String() string

String returns the language of the subtitle

func (*Subtitle) TypeSubtitle added in v1.0.0

func (l *Subtitle) TypeSubtitle() (types.Subtitle, bool)

TypeSubtitle returns true, since a subtitle is a subtitle

type TypeNone added in v1.0.0

type TypeNone struct{}

TypeNone represents a media of unknown format. Can be used for embedding into other types to fill common mundane methods

func (TypeNone) TypeEpisode added in v1.0.0

func (t TypeNone) TypeEpisode() (types.Episode, bool)

TypeEpisode return false, since TypeNone is of an unknown media type

func (TypeNone) TypeMovie added in v1.0.0

func (t TypeNone) TypeMovie() (types.Movie, bool)

TypeMovie return false, since TypeNone is of an unknown media type

func (TypeNone) TypeSubtitle added in v1.0.0

func (t TypeNone) TypeSubtitle() (types.Subtitle, bool)

TypeSubtitle return false, since TypeNone is of an unknown media type

type Video added in v1.0.0

type Video struct {
	*File
}

Video represents special media which has subtitles

func NewVideo added in v1.0.0

func NewVideo(file *File) *Video

NewVideo returns a new video struct

func (*Video) ExistingSubtitles added in v1.0.0

func (f *Video) ExistingSubtitles() (types.SubtitleList, error)

ExistingSubtitles returns a list of existing subtitles for the media

func (*Video) SaveSubtitle added in v1.0.0

func (f *Video) SaveSubtitle(r io.Reader, lang language.Tag) (types.LocalSubtitle, error)

SaveSubtitle saves the subtitle for the given media to disk

Directories

Path Synopsis
meta

Jump to

Keyboard shortcuts

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