Help us shape the future of Go! Take the 2026 Go Developer Survey

subject

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QbtTag_prefix = "anicat@subj-"
	QbtTag        = QbtTag_prefix + "%d" // identity for each resource
)

qbt tag generation template

View Source
const (
	CHSSubStationReg = "(?i)简体|簡體|简中|簡中|chs"
	CHTSubStationReg = "(?i)繁体|繁體|正體中文|正体中文|繁中|cht"
)
View Source
const (
	CreateViaStr createType = iota
	CreateViaFeed
)
View Source
const (
	CoverFN = "folder.jpg" // adapt infuse
)
View Source
const (
	FolderSuffix = "@anicat"
)

file-related

Variables

View Source
var (
	Delete chan *Pip
	Create chan *Pip
)
View Source
var HOME = CFG.Env.SubjPath
View Source
var Manager = SubjectManager{
	// contains filtered or unexported fields
}

Functions

func BuildFilterPerlReg

func BuildFilterPerlReg(vbs []string) string

func BuildFilterRegs

func BuildFilterRegs(vbs []string) []string

func CaptureEpisNum

func CaptureEpisNum(text string) (string, error)

func CreateSubject

func CreateSubject(n string, ext *Extra) (int, error)

func CreateSubjectViaFeed

func CreateSubjectViaFeed(feed, name string, ext *Extra) (int, error)

CreateSubjectViaFeed use a specified rss-feed url as the resource to create a subject, if arg `name` is not empty,then will use specified name to fetch info, otherwise parse the feed for link or title to fetch it. eg:

	`add --feed <url>`
 we fetch bgmTV link first,if it doesn't exist,then get title

	`add --feed <url> --name <specified-name>`
 use specified name only

func FilterWithRegs

func FilterWithRegs(s string, contains, exclusions []string) bool

func FindLastSeason

func FindLastSeason(p string) (int, error)

func GetSeason

func GetSeason(s *Subject)

func InitTvNfo

func InitTvNfo(p, t string) error

func JellyfinMetaDataHelper

func JellyfinMetaDataHelper(dp, name string, exited chan struct{})

func RmFolder

func RmFolder(s *Subject) error

func Scan

func Scan()

func StartManagement

func StartManagement()

Types

type BgmiTyp

type BgmiTyp int
const (
	TV BgmiTyp = iota
	MOVIE
)

anime type

func (BgmiTyp) String

func (t BgmiTyp) String() string

type Extra

type Extra struct {
	TorrOption struct {
		Index int
	}
	RssOption struct {
		SubtitleGroup  string
		MustContain    string
		MustNotContain string
		UseRegex       bool
		Name           string
	}
}

func (*Extra) NoArgs

func (ex *Extra) NoArgs() bool

type Pip

type Pip struct {
	Arg any
	// contains filtered or unexported fields
}

func NewPip

func NewPip(a any) *Pip

func (*Pip) Error

func (p *Pip) Error() error

type ResourceTyp

type ResourceTyp int

resource type

const (
	RSS ResourceTyp = iota
	Torrent
)

func (ResourceTyp) String

func (t ResourceTyp) String() string

type SubjC

type SubjC struct {
	N string
	Extra
	CreateTyp createType
}

type Subject

type Subject struct {
	SubjId      int         `json:"subjId"`
	FolderName  string      `json:"folderName"` // source from tmdb
	Name        string      `json:"name"`
	OriginName  string      `json:"originName"`
	Path        string      `json:"path"`
	Finished    bool        `json:"finished"`
	Episode     int         `json:"episode"`
	ResourceTyp ResourceTyp `json:"resourceTyp"`
	ResourceUrl string      `json:"resourceUrl"`
	Typ         BgmiTyp     `json:"typ"`
	FolderTime  string      `json:"folderTime"` // source from tmdb
	StartTime   string      `json:"startTime"`
	EndTime     string      `json:"endTime"`
	Alias       string      `json:"alias"`
	Season      string      `json:"season"`
	Part        string      `json:"part"` // eg: pt1、pt2
	// used while `ResourceTyp` is `Torrent`
	TorrentHash string `json:"torrentHash"`
	// manager use ctx cancel func to Exit goroutine running the current subject.
	// when delete a subject manager,should run the cancel func and if a goroutine is running
	// for this subject it will Exit.
	// Context is hold by subject-running goroutine
	// while subject-running goroutine Exit actively func should be called
	Exit context.CancelFunc `json:"-"`
	// before detector-goroutine push to subject,Check if this channel is closed.
	// before exit Exited channel should be closed
	Exited chan struct{} `json:"-"`
	// While detector-goroutine detected that the resource downloader of the subject is completed
	// it will send downLoad message to subject-running goroutine
	// received and push to terminal
	PushChan chan qbt.Torrent `json:"-"`
	// The anime series of this project has already ended and all episodes have been downloaded.
	// while init,if this flag is true then there is no need to start a goroutine to run it
	// exit actively flag should be set to true
	Terminate bool `json:"terminate"`
	// a Set store all pushed renamed episodes,avoid duplicate push.
	// content will like be `xxx S01E01,xxx S01E05...`
	Pushed      map[string]string   `json:"pushed"`
	RssTorrents map[string]struct{} `json:"rssTorrents"`
}

Subject as a basic object of each bangumi program will load it from OS file and manage them it will be refreshed to OS file after some of the fields have updating

func (*Subject) FetchInfo

func (s *Subject) FetchInfo() error

func (*Subject) GetPart

func (s *Subject) GetPart()

func (*Subject) GetSeasonAndPart

func (s *Subject) GetSeasonAndPart() string

func (*Subject) Loadfileds

func (subj *Subject) Loadfileds(tips map[string]string) error

func (*Subject) QbtCateg

func (s *Subject) QbtCateg() string

func (*Subject) QbtTag

func (s *Subject) QbtTag() string

QbtTag The tag used when adding a torrent with qbt can be used to monitor the downloader status of resources related to this subject file.

func (*Subject) RmRes

func (s *Subject) RmRes() error

func (*Subject) RssDLSynced

func (s *Subject) RssDLSynced() (bool, error)

RssDLSynced called only when the subject epis is fin

func (*Subject) RssPath

func (s *Subject) RssPath() string

type SubjectManager

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

func (*SubjectManager) Add

func (m *SubjectManager) Add(s *Subject)

func (*SubjectManager) Clear

func (m *SubjectManager) Clear()

func (*SubjectManager) Get

func (m *SubjectManager) Get(sid int) *Subject

func (*SubjectManager) List

func (m *SubjectManager) List() (ls []Subject)

func (*SubjectManager) Remove

func (m *SubjectManager) Remove(sid int)

func (*SubjectManager) Sync

func (m *SubjectManager) Sync()

Jump to

Keyboard shortcuts

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