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

subject

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 33 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

View Source
const (
	Rename subjOp = iota
)

Variables

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

Functions

func BuildFilter added in v0.0.8

func BuildFilter(s *Subject, ex *Extra)

func BuildFilterPerlReg

func BuildFilterPerlReg(vbs []string) string

func BuildFilterRegs

func BuildFilterRegs(vbs []string) []string

func BuiltinDownloadPrepare added in v0.0.8

func BuiltinDownloadPrepare(s *Subject, ex *Extra) 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 FilterWithCustom added in v0.0.4

func FilterWithCustom(s string, e Extra) bool

func FilterWithCustomReg added in v0.0.4

func FilterWithCustomReg(s string, e Extra) bool

func FilterWithReg added in v0.0.8

func FilterWithReg(s string, c, e string) bool

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 RssReader added in v0.0.8

func RssReader(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 DownloadedInfo added in v0.0.8

type DownloadedInfo struct {
	Size int
	Name int
}

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 FilePath added in v0.0.8

type FilePath struct {
	builtin.FileName
	DirPath string
}

func (FilePath) Dir added in v0.0.8

type FilterVerb added in v0.0.8

type FilterVerb struct {
	Single    bool `json:"single"`
	Contain   any  `json:"contain"`
	Exclusion any  `json:"exclusion"`
}

func NewFilterVerb added in v0.0.8

func NewFilterVerb(single bool, c, e any) *FilterVerb

func (*FilterVerb) Filter added in v0.0.8

func (f *FilterVerb) Filter() rss.FilterFunc

type MagnetUrlSeeker added in v0.0.8

type MagnetUrlSeeker struct {
}

func (*MagnetUrlSeeker) Seek added in v0.0.8

type Manager

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

func (*Manager) Add added in v0.0.4

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

func (*Manager) Exit added in v0.0.4

func (m *Manager) Exit()

func (*Manager) Get added in v0.0.4

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

func (*Manager) List added in v0.0.4

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

func (*Manager) Range added in v0.0.7

func (m *Manager) Range(f func(int, *Subject) bool)

func (*Manager) Remove added in v0.0.4

func (m *Manager) Remove(sid int)

func (*Manager) Sync added in v0.0.4

func (m *Manager) Sync()

type MovieFileOpt added in v0.0.8

type MovieFileOpt struct{}

func (*MovieFileOpt) Name added in v0.0.8

type Operate added in v0.0.7

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

func NewOperate added in v0.0.7

func NewOperate(op subjOp, arg any) Operate

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 RssFileOpt added in v0.0.8

type RssFileOpt struct {
	Renamed string
}

func (*RssFileOpt) Name added in v0.0.8

func (r *RssFileOpt) Name() storage.FilePathMaker
return func(opts storage.FilePathMakerOpts) string {
	var parts []string
	if opts.Info.Name != metainfo.NoName {
		parts = append(parts, opts.Info.Name)
	}
	return filepath.Join(append(parts, opts.File.Path...)...)
}

type RssFileOptStrage added in v0.0.8

type RssFileOptStrage struct {
	Renamed string `json:"renamed"`
}

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"`
	OperationChan chan Operate        `json:"-"`
	// builtin-downloader filed
	BuiltinDownload         bool                                    `json:"builtinDownload"`
	RssTorrentsName         map[string]struct{}                     `json:"rssTorrentsName"`
	RssReader               *rss.Reader                             `json:"-"`
	RssGuids                map[string]struct{}                     `json:"rssGuids"`
	Filter                  *FilterVerb                             `json:"filter"`
	TorrentUrls             map[string]RssFileOptStrage             `json:"torrentUrls"`
	TorrentFinishedUrls     map[string]struct{}                     `json:"torrentFinishedUrls"`
	MonitorchanBuiltin      chan builtin.MonitoredTorrent           `json:"-"`
	PushChanBuiltin         chan builtin.MonitoredTorrent           `json:"-"`
	FinihsedTorrentNameList *util.ListView[builtin.TorrentProgress] `json:"-"`
	TorrentMonitor          *builtin.TorrentProgressMonitor         `json:"-"`
}

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) ElapsedfromFinishedTime added in v0.0.8

func (s *Subject) ElapsedfromFinishedTime(e time.Duration) (bool, error)

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) Loadfields added in v0.0.8

func (s *Subject) Loadfields(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) Rename added in v0.0.7

func (s *Subject) Rename(new string) error

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 TorrFileOpt added in v0.0.8

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

func (*TorrFileOpt) Name added in v0.0.8

func (t *TorrFileOpt) Name() storage.FilePathMaker

Jump to

Keyboard shortcuts

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