Documentation
¶
Overview ¶
movies
Index ¶
- Constants
- Variables
- func AppendCache(a string, v string)
- func AppendCacheMap(useseries bool, query string, v string)
- func AppendCacheThreeString(a string, v DbstaticThreeStringTwoInt)
- func AppendCacheTwoInt(a string, v DbstaticOneStringTwoInt)
- func AppendCacheTwoString(a string, v DbstaticTwoStringOneInt)
- func ArrStructContains(s []DbstaticTwoUint, v DbstaticTwoUint) bool
- func ArrStructContainsString(s []string, v string) bool
- func Backup(backupPath *string, maxbackups int) error
- func CacheOneStringTwoIntIndexFunc(s string, f func(*DbstaticOneStringTwoInt) bool) bool
- func CacheOneStringTwoIntIndexFuncRet(s string, id uint, listname string) uint
- func CacheOneStringTwoIntIndexFuncStr(useseries bool, query string, i uint) string
- func CacheThreeStringIntIndexFunc(s string, u *string) uint
- func CacheThreeStringIntIndexFuncGetYear(s string, i uint) uint16
- func CheckcachedTitleHistory(useseries bool, file *string) bool
- func CheckcachedURLHistory(useseries bool, file *string) bool
- func ChecknzbtitleB(movietitle, movietitlesluga, nzbtitle string, allowpm1 bool, yearu uint16) bool
- func ClearCaches()
- func CloseImdb()
- func DBClose()
- func DBIntegrityCheck() string
- func DBQuickCheck() string
- func DeleteRow(table, where string, args ...any) (sql.Result, error)
- func ExchangeImdbDB()
- func Exec1(querystring string, arg any)
- func Exec1Err(querystring string, arg any) error
- func Exec2(querystring string, arg, arg2 any)
- func ExecN(querystring string, args ...any)
- func ExecNErr(querystring string, args ...any) error
- func ExecNMap(useseries bool, query string, args ...any)
- func ExecNid(querystring string, args ...any) (int64, error)
- func FilterDbstaticTwoStringOneInt(s []DbstaticTwoStringOneInt, id uint) iter.Seq[DbstaticTwoStringOneInt]
- func GetCachedStringArr(key string, checkexpire bool, retry bool) []string
- func GetDBStaticOneStringOneIntIdx(tbl []DbstaticOneStringOneUInt, v string) int
- func GetDBStaticTwoStringIdx1(tbl []DbstaticTwoString, v string) int
- func GetMediaListIDGetListname(cfgp *config.MediaTypeConfig, mediaid *uint) int
- func GetMediaQualityConfigP(cfgp *config.MediaTypeConfig, mediaid *uint) *config.QualityConfig
- func GetMutex() *sync.RWMutex
- func GetSluggedMap(slugged bool, typestr string) string
- func GetVersion() string
- func Getdatarow0(imdb bool, querystring string) uint
- func Getdatarow1[o bool | int | uint | uint16 | string](imdb bool, querystring string, arg any) o
- func Getdatarow2[o uint | string](imdb bool, querystring string, arg any, arg2 *string) o
- func Getdatarow2any[o uint | string](imdb bool, querystring string, arg any, arg2 any) o
- func Getdatarow3[o uint | string](imdb bool, querystring string, arg, arg2, arg3 *string) o
- func GetdatarowArgs(querystring string, arg any, objs ...any)
- func GetdatarowArgsImdb(querystring string, arg any, objs ...any)
- func GetdatarowN(imdb bool, querystring string, args ...any) uint
- func GetdatarowNArg(imdb bool, querystring string, args []any) uint
- func Getdb(imdb bool) *sqlx.DB
- func Getqualityidxbyname(tbl []Qualities, cfgp *config.MediaTypeConfig, reso bool) int
- func Getrows0[t any](imdb bool, size uint, querystring string) []t
- func Getrows1[t any](imdb bool, size uint, querystring string, arg any) []t
- func Getrows1size[t any](imdb bool, sizeq, querystring string, arg any) []t
- func Getrows2size(imdb bool, sizeq, querystring string, arg, arg2 any) []string
- func GetrowsN[t any](imdb bool, size uint, querystring string, args ...any) []t
- func GetrowsNuncached[t DbstaticTwoUint | DbstaticOneStringOneUInt | uint](size uint, querystring string, args []any) []t
- func InitCache()
- func InitDB(dbloglevel string) error
- func InitImdbdb() error
- func InsertArray(table string, columns []string, values ...any) (sql.Result, error)
- func InvalidateImdbStmt()
- func NewCache(cleaningInterval, extension time.Duration)
- func OpenImdbdb()
- func RefreshCached(key string, force bool)
- func RefreshMediaCacheDB(useseries bool, force bool)
- func RefreshMediaCacheList(useseries bool, force bool)
- func RefreshMediaCacheTitles(useseries bool, force bool)
- func Refreshfilescached(useseries bool, force bool)
- func Refreshhistorycachetitle(useseries bool, force bool)
- func Refreshhistorycacheurl(useseries bool, force bool)
- func Refreshunmatchedcached(useseries bool, force bool)
- func RegexGetMatchesFind(key, matchfor string, mincount int) bool
- func RegexGetMatchesStr1Str2(cached bool, key, matchfor string) (string, string)
- func RunRetRegex(key string, matchfor string, useall bool) []int
- func Scanrows0dyn(imdb bool, querystring string, obj any)
- func Scanrows1dyn(imdb bool, querystring string, obj, arg any)
- func Scanrows2dyn(imdb bool, querystring string, obj, arg, arg2 any)
- func Scanrows3dyn(imdb bool, querystring string, obj, arg *uint, arg2, arg3 *string)
- func ScanrowsNArr(imdb bool, querystring string, obj any, args []any)
- func SetRegexp(key string, duration time.Duration) regexp.Regexp
- func SetVars()
- func SetVersion(str string)
- func SlicesCacheContains(useseries bool, query, v string) bool
- func SlicesCacheContainsDelete(s, v string)
- func SlicesCacheContainsI(useseries bool, query string, w *string) bool
- func StructscanT[t any](imdb bool, size uint, querystring string, args ...any) []t
- func UpdateArray(table string, columns []string, where string, args ...any) (sql.Result, error)
- func Upgrade(_ *gin.Context)
- func UpgradeDB() error
- func UpgradeIMDB()
- type DBGlobal
- type Dbmovie
- type DbmovieTitle
- type Dbserie
- type DbserieAlternate
- type DbserieEpisode
- type DbstaticOneIntOneBool
- type DbstaticOneStringOneInt
- type DbstaticOneStringOneUInt
- type DbstaticOneStringTwoInt
- type DbstaticThreeString
- type DbstaticThreeStringTwoInt
- type DbstaticTwoString
- type DbstaticTwoStringOneInt
- type DbstaticTwoStringOneRInt
- type DbstaticTwoUint
- type FilePrio
- type ImdbAka
- type ImdbRatings
- type ImdbTitle
- type IndexerFail
- type JobHistory
- type Movie
- type MovieFile
- type MovieFileUnmatched
- type MovieHistory
- type ParseInfo
- func (m *ParseInfo) AddUnmatched(cfgp *config.MediaTypeConfig, listname *string, err error)
- func (m *ParseInfo) CacheThreeStringIntIndexFuncGetImdb()
- func (m *ParseInfo) Checktitle(cfgp *config.MediaTypeConfig, qualcfg *config.QualityConfig, title string) bool
- func (m *ParseInfo) Cleanimdbdbmovie()
- func (m *ParseInfo) ClearArr()
- func (m *ParseInfo) Close()
- func (m *ParseInfo) ExecParsed(cfgp *config.MediaTypeConfig, err error, listname *string)
- func (m *ParseInfo) FindDbserieByName(slugged bool)
- func (m *ParseInfo) FindDbserieByNameWithSlug(title string)
- func (m *ParseInfo) Findmoviedbidbytitle(slugged bool)
- func (m *ParseInfo) GenerateIdentifierString()
- func (m *ParseInfo) Getepisodestoimport() error
- func (m *ParseInfo) Getqualityidxbyid(tbl []Qualities, i uint8) int
- func (m *ParseInfo) Gettypeids(id uint8) uint
- func (m *ParseInfo) MovieFindDBIDByImdbParser()
- func (m *ParseInfo) Parsegroup(name string, onlyifempty bool)
- func (m *ParseInfo) ParsegroupEntry(group string)
- func (m *ParseInfo) Parseresolution() string
- func (m *ParseInfo) RegexGetMatchesStr1(cfgp *config.MediaTypeConfig)
- func (m *ParseInfo) SetDBEpisodeIDfromM()
- func (m *ParseInfo) SetEpisodeIDfromM()
- func (m *ParseInfo) StripTitlePrefixPostfixGetQual(quality *config.QualityConfig)
- type Qualities
- type Querywithargs
- type RSSHistory
- type ResultMovies
- type ResultSerieEpisodes
- type ResultSeries
- type Serie
- type SerieEpisode
- type SerieEpisodeFile
- type SerieEpisodeHistory
- type SerieFileUnmatched
Constants ¶
const ( QueryDbseriesGetIdentifiedByID = "select lower(identifiedby) from dbseries where id = ?" QueryDbserieEpisodesGetSeasonEpisodeByDBID = "select season, episode from dbserie_episodes where dbserie_id = ?" QueryDbserieEpisodesCountByDBID = "select count() from dbserie_episodes where dbserie_id = ?" QuerySeriesCountByDBID = "select count() from series where dbserie_id = ?" QueryUpdateHistory = "update job_histories set ended = datetime('now','localtime') where id = ?" QueryCountMoviesByDBIDList = "select count() from movies where dbmovie_id = ? and listname = ? COLLATE NOCASE" QuerySeriesGetIDByDBIDListname = "select id from series where dbserie_id = ? and listname = ? COLLATE NOCASE" QueryDbseriesGetIDByTvdb = "select id from dbseries where thetvdb_id = ?" QueryMoviesGetIDByDBIDListname = "select id from movies where dbmovie_id = ? and listname = ? COLLATE NOCASE" QueryDbmovieTitlesGetTitleByIDLmit1 = "select title from dbmovie_titles where dbmovie_id = ? limit 1" QuerySerieEpisodesGetDBSerieEpisodeIDByID = "select dbserie_episode_id from serie_episodes where id = ?" QuerySerieEpisodesGetDBSerieIDByID = "select dbserie_id from serie_episodes where id = ?" QuerySerieEpisodesGetSerieIDByID = "select serie_id from serie_episodes where id = ?" QueryDBSerieEpisodeGetIDByDBSerieIDIdentifierDot = "select id from dbserie_episodes where dbserie_id = ? and identifier=REPLACE(?,'.','-') COLLATE NOCASE" QueryDBSerieEpisodeGetIDByDBSerieIDIdentifierDash = "select id from dbserie_episodes where dbserie_id = ? and identifier=REPLACE(?,' ','-') COLLATE NOCASE" )
Variables ¶
var ( DBConnect DBGlobal DBVersion = "1" DBLogLevel = "Info" )
Functions ¶
func AppendCache ¶
AppendCache appends the given value v to the cached array for the given key a. If the cached array for the given key does not exist, this function does nothing. If the given value is already present in the cached array, this function does nothing.
func AppendCacheMap ¶
AppendCacheMap appends a value to the cache map for the given query string. If useseries is true, it appends to the logger.Mapstringsseries map, otherwise it appends to the logger.Mapstringsmovies map. The value is appended using the AppendCache function.
func AppendCacheThreeString ¶
func AppendCacheThreeString(a string, v DbstaticThreeStringTwoInt)
AppendCacheThreeString appends the given DbstaticThreeStringTwoInt value v to the cached array for the given key a. If the cached array for the given key does not exist, this function does nothing. If the given value is already present in the cached array, this function does nothing.
func AppendCacheTwoInt ¶
func AppendCacheTwoInt(a string, v DbstaticOneStringTwoInt)
AppendCacheTwoInt appends the given DbstaticOneStringTwoInt value v to the cached array for the given key a. If the cached array for the given key does not exist, this function does nothing. If the given value is already present in the cached array, this function does nothing.
func AppendCacheTwoString ¶
func AppendCacheTwoString(a string, v DbstaticTwoStringOneInt)
AppendCacheTwoString appends the given DbstaticTwoStringOneInt value v to the cached array for the given key a. If the cached array for the given key does not exist, this function does nothing. If the given value is already present in the cached array, this function does nothing.
func ArrStructContains ¶
func ArrStructContains(s []DbstaticTwoUint, v DbstaticTwoUint) bool
ArrStructContains checks if the given slice s contains the value v. The comparison is performed using the comparable constraint, which allows comparing values of the same type. If the values are of a custom struct type, the comparison is performed by checking if all fields of the struct are equal.
func ArrStructContainsString ¶
ArrStructContainsString checks if the given slice s contains the string value v. It iterates over the slice and returns true if a match is found, false otherwise.
func CacheOneStringTwoIntIndexFunc ¶
func CacheOneStringTwoIntIndexFunc(s string, f func(*DbstaticOneStringTwoInt) bool) bool
CacheOneStringTwoIntIndexFunc looks up the cached one string two int array identified by s and calls the passed in function f on each element. Returns true if f returns true for any element.
func CacheOneStringTwoIntIndexFuncRet ¶
CacheOneStringTwoIntIndexFuncRet searches the cached one string two int array identified by s by applying the passed in function f to each element. If f returns true for any element, the Num2 field of that element is returned. If no match is found, 0 is returned.
func CacheOneStringTwoIntIndexFuncStr ¶
CacheOneStringTwoIntIndexFuncStr looks up the cached one string, two int array identified by s and returns the string value for the entry where the second int matches the passed in uint i. It stores the returned string in listname. If no match is found, it sets listname to an empty string.
func CacheThreeStringIntIndexFunc ¶
CacheThreeStringIntIndexFunc looks up the cached three string, two int array identified by s and returns the second int value for the entry where the third string matches the string str. Returns 0 if no match found.
func CacheThreeStringIntIndexFuncGetYear ¶
CacheThreeStringIntIndexFuncGetYear looks up the cached three string, two int array identified by s and returns the first int value for the entry where the second int matches the int str. Returns 0 if no match found.
func CheckcachedTitleHistory ¶
CheckcachedMovieTitleHistory checks if the given movie title exists in the movie_histories table. It first checks the file cache if enabled, otherwise queries the database. Returns true if the title exists, false otherwise.
func CheckcachedURLHistory ¶
CheckcachedMovieUrlHistory checks if the given movie URL exists in the movie_histories table. It first checks the file cache if enabled, otherwise queries the database. Returns true if the URL exists, false otherwise.
func ChecknzbtitleB ¶
ChecknzbtitleB checks if the nzbtitle matches the movietitle and year. It compares the movietitle and nzbtitle directly, and also tries appending/removing the year, converting to slugs, etc. It is used to fuzzy match nzb titles to movie info during parsing.
func ClearCaches ¶
func ClearCaches()
ClearCaches iterates over the cached string, three string two int, and two string int arrays, sets the Expire field on each cached array object to two hours in the past based on the config cache duration, and updates the cache with the expired array object. This effectively clears those cached arrays by expiring all entries.
func DBClose ¶
func DBClose()
DBClose closes any open database connections to the data.db and imdb.db SQLite databases. It is intended to be called when the application is shutting down to cleanly close the connections.
func DBIntegrityCheck ¶
func DBIntegrityCheck() string
DBIntegrityCheck checks the database integrity using the PRAGMA integrity_check statement. It logs informational messages before and after running the statement. The string result from running the statement is returned.
func DBQuickCheck ¶
func DBQuickCheck() string
DBQuickCheck checks the database for errors using the PRAGMA quick_check statement. It logs informational messages before and after running the statement. The string result from running the statement is returned.
func DeleteRow ¶
DeleteRow deletes rows from the given database table that match the provided WHERE clause and arguments. It returns the sql.Result and error from the query execution. The table parameter specifies the table name to delete from. The where parameter allows specifying a WHERE condition to filter the rows to delete. The args parameters allow providing arguments to replace any ? placeholders in the where condition.
func ExchangeImdbDB ¶
func ExchangeImdbDB()
ExchangeImdbDB exchanges the imdb.db file with a temp copy. It first checks if the main imdb.db file exists, locks the db, makes the main file writable, deletes it, renames the temp copy to the main name, unlocks the db, and logs the result.
func Exec1 ¶
Exec1 executes the given SQL query string with the provided argument and returns the result and any error. The function acquires a read/write lock before executing the query to ensure thread-safety. If an error occurs during the execution, it is logged.
func Exec1Err ¶
Exec1Err executes the given SQL query string with the provided argument and returns any error that occurred. The function acquires a read/write lock before executing the query to ensure thread-safety. If an error occurs during the execution, it is returned.
func Exec2 ¶
Exec2 executes the given SQL query string with the provided arguments arg and arg2. It acquires a read/write lock before executing the query to ensure thread-safety, and releases the lock when the query is complete. If an error occurs during the execution, it is logged using the exec function.
func ExecN ¶
ExecN executes the given query string with the provided arguments, and returns the result or any error. It acquires a read/write lock before executing the query to ensure thread-safety, and releases the lock when the query is complete. If the query fails due to the database being closed, it removes the query from the cache to prevent future failed attempts. If the query fails for any other reason, it logs the error.
func ExecNErr ¶
ExecNErr executes the given SQL query string with the provided arguments and returns any error that occurred. The function acquires a read/write lock before executing the query to ensure thread-safety. If an error occurs during the execution, it is returned.
func ExecNMap ¶
ExecNMap executes a database query using the provided query string and arguments. If useseries is true, it uses the query string from the logger.Mapstringsseries map, otherwise it uses the query string from the logger.Mapstringsmovies map. The function acquires a read/write lock before executing the query and releases it after the query is executed. If an error occurs during the query execution, it is logged using the logExecError function.
func ExecNid ¶
ExecNid executes the given querystring with multiple arguments, returns the generated ID from the insert statement, handles errors.
func FilterDbstaticTwoStringOneInt ¶
func FilterDbstaticTwoStringOneInt(s []DbstaticTwoStringOneInt, id uint) iter.Seq[DbstaticTwoStringOneInt]
FilterDbstaticTwoStringOneInt filters a slice of DbstaticTwoStringOneInt structs by the provided id. It returns a sequence that yields the filtered elements.
func GetCachedStringArr ¶
GetCachedStringArr retrieves the cached array of strings associated with the given key. If no cached object is found for the key, or the cached object has expired, it returns nil. The checkexpire parameter determines whether to check if the cached object has expired. The retry parameter determines whether to refresh the cached object if it is empty or the zero value.
func GetDBStaticOneStringOneIntIdx ¶
func GetDBStaticOneStringOneIntIdx(tbl []DbstaticOneStringOneUInt, v string) int
GetDbStaticOneStringOneIntIdx searches tbl for an element where Str equals v, and returns the index of that element, or -1 if not found.
func GetDBStaticTwoStringIdx1 ¶
func GetDBStaticTwoStringIdx1(tbl []DbstaticTwoString, v string) int
GetDbStaticTwoStringIdx1 returns the index of the DbstaticTwoString element with Str1 equal to v, or -1 if not found.
func GetMediaListIDGetListname ¶
func GetMediaListIDGetListname(cfgp *config.MediaTypeConfig, mediaid *uint) int
GetMediaListIDMovies returns the index of the media list with the given name in cfgp for the movie with the given ID. It returns -1 if cfgp is nil, listname is empty, or no list with that name exists.
func GetMediaQualityConfigP ¶
func GetMediaQualityConfigP(cfgp *config.MediaTypeConfig, mediaid *uint) *config.QualityConfig
GetMediaQualityConfigP returns the QualityConfig from cfgp for the media with the given ID. It first checks if there is a quality profile set for that media in the database. If not, it returns the default QualityConfig from cfgp.
func GetSluggedMap ¶
GetSluggedMap returns the appropriate SQL query string based on whether the caller wants to use a slugged or default lookup. The returned string can be used to query the database for a record matching the provided type string.
func GetVersion ¶
func GetVersion() string
GetVersion returns the current database version string stored in the DBVersion global variable.
func Getdatarow0 ¶
Getdatarow0 is a generic function that executes a SQL query with the provided arguments and returns the result as a value of type uint. It uses the GlobalCache to cache the prepared statement for the given query string and database connection.
The function takes the following arguments: - imdb: a boolean indicating whether to use the "imdb" database connection or the default one. - querystring: the SQL query to execute.
The function returns a value of type uint, which is the result of the SQL query.
func Getdatarow1 ¶
Getdatarow1 is a generic function that executes a SQL query with the provided arguments and returns the result as a value of type o. It uses the GlobalCache to cache the prepared statement for the given query string and database connection.
The function takes the following arguments: - imdb: a boolean indicating whether to use the "imdb" database connection or the default one. - querystring: the SQL query to execute. - args: the argument to pass to the SQL query.
The function returns a value of type o, which is the result of the SQL query.
func Getdatarow2 ¶
Getdatarow2 is a generic function that executes a SQL query with the provided arguments and returns the result as a value of type o. It uses the GlobalCache to cache the prepared statement for the given query string and database connection.
The function takes the following arguments: - imdb: a boolean indicating whether to use the "imdb" database connection or the default one. - querystring: the SQL query to execute. - arg: the first argument to pass to the SQL query. - arg2: the second argument to pass to the SQL query.
The function returns a value of type o, which is the result of the SQL query.
func Getdatarow2any ¶
Getdatarow2any is a generic function that executes a SQL query with the provided arguments and returns the result as a value of type o. It uses the GlobalCache to cache the prepared statement for the given query string and database connection.
The function takes the following arguments: - imdb: a boolean indicating whether to use the "imdb" database connection or the default one. - querystring: the SQL query to execute. - arg: the first argument to pass to the SQL query. - arg2: the second argument to pass to the SQL query.
The function returns a value of type o, which is the result of the SQL query.
func Getdatarow3 ¶
Getdatarow3 executes the given querystring with the provided arguments and scans the result into the given object, handling locking, logging errors, and returning the scanned object. The imdb parameter specifies whether to use the imdb database connection. The arg, arg2, and arg3 parameters are pointers to strings that are used as arguments to the SQL query.
func GetdatarowArgs ¶
GetdatarowArgs executes the given querystring with the provided argument and scans the result into the given slice of objects, handling locking, logging errors, and returning the scanned objects.
func GetdatarowArgsImdb ¶
GetdatarowArgsImdb executes the given querystring with the provided argument and scans the result into the given slice of objects, handling locking, logging errors, and returning the scanned objects. This version of the function uses the "imdb" database connection instead of the default one.
func GetdatarowN ¶
GetdatarowN executes the given querystring with the provided arguments and scans the result into the given object, handling locking, logging errors, and returning the scanned object. The imdb parameter specifies whether to use the imdb database connection.
func GetdatarowNArg ¶
GetdatarowNArg is a generic function that executes a SQL query with the provided arguments and returns the result as a value of type O. It uses the GlobalCache to cache the prepared statement for the given query string and database connection.
The function takes the following arguments: - imdb: a boolean indicating whether to use the "imdb" database connection or the default one. - querystring: the SQL query to execute. - args: the arguments to pass to the SQL query.
The function returns a value of type O, which is the result of the SQL query.
func Getdb ¶
getdb returns the database connection to use based on the imdb parameter. If imdb is true, it returns the dbImdb connection, otherwise it returns the dbData connection.
func Getqualityidxbyname ¶
func Getqualityidxbyname(tbl []Qualities, cfgp *config.MediaTypeConfig, reso bool) int
Getqualityidxbyname searches the given quality table tbl by name and returns the index of the matching entry, or -1 if no match is found.
func Getrows0 ¶
Getrows0 executes the given querystring against the database, scans the result rows into a slice of the generic type T, handles locking, logging errors, and returns the slice. The size parameter limits the number of rows scanned. If imdb is true, the query will be executed against the imdb database, otherwise the main database.
func Getrows1 ¶
Getrows1 executes the given querystring with a single argument against the database, scans the result rows into a slice of the generic type T, handles locking, logging errors, and returns the slice. The size parameter limits the number of rows scanned. If imdb is true, the query will be executed against the imdb database, otherwise the main database.
func Getrows1size ¶
Getrows1size executes the given querystring with the provided argument against the database, scans the result rows into a slice of the generic type T, handles locking, logging errors, and returns the slice. The sizeq parameter limits the number of rows scanned. If imdb is true, the query will be executed against the imdb database, otherwise the main database.
func Getrows2size ¶
Getrows2size executes the given querystring with the provided arguments against the database, scans the result rows into a slice of strings, handles locking, logs errors, and returns the slice. The size parameter limits the number of rows scanned. If imdb is true, the query will be executed against the imdb database, otherwise the main database.
func GetrowsN ¶
GetrowsN executes the given querystring with multiple arguments against the database, scans the result rows into a slice of the generic type T, handles locking, logging errors, and returns the slice. The size parameter limits the number of rows scanned. If imdb is true, the query will be executed against the imdb database, otherwise the main database.
func GetrowsNuncached ¶
func GetrowsNuncached[t DbstaticTwoUint | DbstaticOneStringOneUInt | uint](size uint, querystring string, args []any) []t
GetrowsNuncached executes a SQL query and returns the results as a slice of the specified type T. It acquires a read lock on the readWriteMu mutex before executing the query, and releases the lock when the function returns. If the query executes successfully, it calls queryGenericsT to convert the rows to the specified type and returns the slice. If the query fails with an error other than sql.ErrNoRows, it logs the error using logger.LogDynamicany. If the query fails with sql.ErrNoRows, it returns a nil slice.
func InitCache ¶
func InitCache()
InitCache initializes the global cache by creating a new Cache instance with the provided expiration times and logger. It is called on startup to initialize the cache before it is used.
func InitDB ¶
InitDB initializes a connection to the data.db SQLite database. It creates the file if it does not exist and sets database connection parameters.
func InitImdbdb ¶
func InitImdbdb() error
InitImdbdb initializes a connection to the imdb.db SQLite database. It creates the file if it does not exist.
func InsertArray ¶
InsertArray inserts a row into the given database table, with the provided columns and values. The number of columns must match the number of value parameters. It handles building the SQL insert statement from the parameters, executing the insert, and returning the result or any error.
func InvalidateImdbStmt ¶
func InvalidateImdbStmt()
InvalidateImdbStmt iterates over the cache.items sync.Map and deletes any cached items that have the imdb field set to true. This is likely used to invalidate any cached IMDB-related data when needed.
func NewCache ¶
NewRegex creates a new GlobalcacheRegex instance. cleaningInterval specifies the interval to clean up expired regex entries. extension specifies the default expiration duration to use for cached regexes. log is the logger used for logging. It initializes the cache and starts a goroutine to clean up expired entries based on the cleaningInterval.
func OpenImdbdb ¶
func OpenImdbdb()
OpenImdbdb opens a connection to the imdb.db SQLite database. It creates the file if it does not exist.
func RefreshCached ¶
RefreshCached refreshes the cached data for the specified key. It calls the appropriate refresh function based on the key, such as RefreshMediaCache, RefreshMediaCacheTitles, Refreshunmatchedcached, Refreshfilescached, or Refreshhistorycache.
func RefreshMediaCacheDB ¶
RefreshMediaCache refreshes the media caches for movies and series. It will refresh the caches based on the useseries parameter: - if useseries is false, it will refresh the movie caches - if useseries is true, it will refresh the series caches It locks access to the caches while refreshing to prevent concurrent access issues.
func RefreshMediaCacheList ¶
RefreshMediaCacheList refreshes the media caches for movies and series. It will refresh the caches based on the useseries parameter: - if useseries is false, it will refresh the movie caches - if useseries is true, it will refresh the series caches It locks access to the caches while refreshing to prevent concurrent access issues.
func RefreshMediaCacheTitles ¶
RefreshMediaCacheTitles refreshes the cached media title arrays for movies or series. It handles locking and unlocking the cache mutex. The useseries parameter determines if it refreshes the cache for series or movies.
func Refreshfilescached ¶
Refreshfilescached refreshes the cached file location arrays for movies or series. It handles locking and unlocking the cache mutex. The useseries parameter determines if it refreshes the cache for series or movies.
func Refreshhistorycachetitle ¶
Refreshhistorycachetitle refreshes the cached history title arrays for movies or series. It handles locking and unlocking the cache mutex. The useseries parameter determines if it refreshes the cache for series or movies. The force parameter determines if the cache should be refreshed regardless of the last scan time.
func Refreshhistorycacheurl ¶
Refreshhistorycacheurl refreshes the cached history URL arrays for movies or series. It handles locking and unlocking the cache mutex. The useseries parameter determines if it refreshes the cache for series or movies. The force parameter determines if the cache should be refreshed regardless of the last scan time.
func Refreshunmatchedcached ¶
Refreshunmatchedcached refreshes the cached string array of unmatched files for movies or series. It handles locking and unlocking the cache mutex. The useseries parameter determines if it refreshes the cache for series or movies.
func RegexGetMatchesFind ¶
RegexGetMatchesFind checks if the regular expression matches the input string at least mincount times. It returns true if there are at least mincount matches, false otherwise. The regular expression is retrieved from the global cache.
func RegexGetMatchesStr1Str2 ¶
RegexGetMatchesStr1Str2 returns the first and second submatches found in the input string 'matchfor' using the regular expression stored in the cache under the key 'key'. If 'cached' is true, the cached regular expression is used, otherwise a new one is compiled. The function returns the first and second submatches as strings, or empty strings if no matches or less than two submatches are found.
func RunRetRegex ¶
RunRetRegex returns the indexes of the last submatch found in matchfor using the compiled regular expression stored in the global cache under key. If useall is true, it returns the indexes of the last submatch from all matches found, otherwise it returns the indexes of the first submatch. If no matches are found, it returns nil.
func Scanrows0dyn ¶
Scanrows0dyn executes a SQL query and scans the result into the provided object. The query string and arguments are passed as parameters. If the query fails, the error is logged and returned. The function acquires a read lock on the readWriteMu mutex before executing the query, and releases it when the function returns.
func Scanrows1dyn ¶
Scanrows1dyn executes a SQL query and scans the result into the provided object. The query string and arguments are passed as parameters. If the query fails, the error is logged and returned. The function acquires a read lock on the readWriteMu mutex before executing the query, and releases it when the function returns.
func Scanrows2dyn ¶
Scanrows2dyn executes a SQL query and scans the result into the provided object. The query string and arguments are passed as parameters. If the query fails, the error is logged and returned. The function acquires a read lock on the readWriteMu mutex before executing the query, and releases it when the function returns.
func Scanrows3dyn ¶
Scanrows3dyn executes a SQL query and scans the result into the provided object. The query string and arguments are passed as parameters. If the query fails, the error is logged and returned. The function acquires a read lock on the readWriteMu mutex before executing the query, and releases it when the function returns.
func ScanrowsNArr ¶
ScanrowsNArr executes a SQL query and scans the result into the provided object. It uses the GlobalCache to retrieve a prepared statement for the given query string, and then executes the query with the provided arguments, scanning the result into the provided object. If an error occurs during the query execution or scanning, it is logged and returned.
func SetRegexp ¶
SetRegexp sets a regular expression in the global cache with the given key and duration. The regular expression is returned, which can be used for matching.
func SetVars ¶
func SetVars()
GetVars populates the global regex variables from the database. It retrieves the quality regexes from the database and processes them to populate: - DBConnect.GetresolutionsIn - DBConnect.GetqualitiesIn - DBConnect.GetcodecsIn - DBConnect.GetaudiosIn It also processes the config regex settings, and splits the regex strings to populate: - DBConnect.AudioStrIn - DBConnect.CodecStrIn - DBConnect.QualityStrIn - DBConnect.ResolutionStrIn.
func SetVersion ¶
func SetVersion(str string)
SetVersion sets the global DBVersion variable to the given version string.
func SlicesCacheContains ¶
SlicesCacheContains checks if the cached string array identified by s contains the value v. It iterates over the array and returns true if a match is found.
func SlicesCacheContainsDelete ¶
func SlicesCacheContainsDelete(s, v string)
SlicesCacheContainsDelete removes an element matching v from the cached string array identified by s. It acquires a lock, defers unlocking, and iterates over the array to find a match. When found, it uses slices.Delete to remove the element while preserving order, updates the cache, and returns.
func SlicesCacheContainsI ¶
SlicesCacheContainsI checks if string v exists in the cached string array identified by s using a case-insensitive comparison. It gets the cached array, iterates over it, compares each element to v with EqualFold, and returns true if a match is found.
func StructscanT ¶
StructscanT executes a SQL query and scans the result into a slice of the provided struct type. It takes a boolean indicating whether the query is for an IMDB database, the expected size of the result set, the SQL query string, and any arguments for the query. It returns a slice of the provided struct type containing the scanned rows. The function acquires a read lock on the readWriteMu mutex, executes the query, and scans the results into the provided struct type. If an error occurs during the query or scanning, it is logged and the function returns nil.
func UpdateArray ¶
UpdateArray updates rows in the given database table by setting the provided columns to the corresponding value parameters. It builds the SQL UPDATE statement dynamically based on the parameters. The optional where parameter allows specifying a WHERE clause to filter the rows to update. It handles executing the statement and returning the result or any error.
func UpgradeDB ¶
func UpgradeDB() error
UpgradeDB initializes the database schema and upgrades to the latest version. It returns an error if migration fails.
func UpgradeIMDB ¶
func UpgradeIMDB()
UpgradeIMDB migrates the imdb database to the latest version. It initializes a database migration manager, pointing it to the migration scripts. It then runs the Up() method to apply any necessary changes. Any errors are printed.
Types ¶
type DBGlobal ¶
type DBGlobal struct {
// AudioStrIn is a globally accessible slice of audio strings
AudioStrIn []string
// CodecStrIn is a globally accessible slice of codec strings
CodecStrIn []string
// QualityStrIn is a globally accessible slice of quality strings
QualityStrIn []string
// ResolutionStrIn is a globally accessible slice of resolution strings
ResolutionStrIn []string
// GetqualitiesIn is a globally accessible slice of Qualities structs
GetqualitiesIn []Qualities
// GetresolutionsIn is a globally accessible slice of Qualities structs
GetresolutionsIn []Qualities
// GetcodecsIn is a globally accessible slice of Qualities structs
GetcodecsIn []Qualities
// GetaudiosIn is a globally accessible slice of Qualities structs
GetaudiosIn []Qualities
}
dbGlobal stores globally accessible slices and arrays.
type Dbmovie ¶
type Dbmovie struct {
Genres string
OriginalLanguage string `db:"original_language"`
OriginalTitle string `db:"original_title"`
Overview string
Title string
SpokenLanguages string `db:"spoken_languages"`
Status string
Tagline string
ImdbID string `db:"imdb_id"`
FreebaseMID string `db:"freebase_m_id"`
FreebaseID string `db:"freebase_id"`
FacebookID string `db:"facebook_id"`
InstagramID string `db:"instagram_id"`
TwitterID string `db:"twitter_id"`
URL string
Backdrop string
Poster string
Slug string
ReleaseDate sql.NullTime `db:"release_date" json:"release_date" time_format:"2006-01-02" time_utc:"1"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
Popularity float32
VoteAverage float32 `db:"vote_average"`
Budget int
Revenue int
Runtime int
TraktID int `db:"trakt_id"`
MoviedbID int `db:"moviedb_id"`
ID uint
VoteCount int32 `db:"vote_count"`
Year uint16
Adult bool
}
func GetDbmovieByID ¶
GetDbmovieByID retrieves a Dbmovie by ID. It takes a uint ID and returns a Dbmovie struct and error. It executes a SQL query using the structscanG function to select the dbmovie data and scan it into the Dbmovie struct. Returns an error if there was a problem retrieving the data.
func QueryDbmovie ¶
func QueryDbmovie(qu Querywithargs, args ...any) []Dbmovie
QueryDbmovie queries the dbmovies table using the provided Querywithargs struct and arguments. It sets the query size and limit, table name, default columns to select, builds the query if needed, and executes the query using QueryStaticArrayN, returning a slice of Dbmovie structs.
func (*Dbmovie) GetDbmovieByIDP ¶
GetDbmovieByIDP retrieves a Dbmovie by ID. It takes a uint ID and a pointer to a Dbmovie struct to scan the result into. It executes a SQL query using the structscan function to select the dbmovie data and scan it into the Dbmovie struct. Returns an error if there was a problem retrieving the data.
func (*Dbmovie) GetImdbRating ¶
GetImdbRating queries the imdb_ratings table to get the average rating and number of votes for the given IMDb ID. It populates the rating fields on the Dbmovie struct if they are empty or overwrite is true.
func (*Dbmovie) GetImdbTitle ¶
GetImdbTitle queries the imdb_titles table to populate movie details from IMDb. It takes the IMDb id pointer, movie struct pointer, and a boolean overwrite flag. It will populate the movie struct with data from IMDb if fields are empty or overwrite is true. This handles setting the title, year, adult flag, genres, original title, runtime, slug, url, vote average, and vote count.
func (*Dbmovie) MovieFindDBIDByImdbParser ¶
func (movie *Dbmovie) MovieFindDBIDByImdbParser()
MovieFindDBIDByImdbParser sets the ID field of the Dbmovie struct based on the ImdbID field. If the ImdbID is empty, the ID is set to 0 and the function returns. If the UseMediaCache setting is true, the ID is set by calling CacheThreeStringIntIndexFunc with the ImdbID. Otherwise, the ID is set by executing a SQL query to select the id from the dbmovies table where the imdb_id matches the ImdbID.
func (*Dbmovie) MovieGetImdbMetadata ¶
movieGetImdbMetadata fetches movie metadata from IMDB. It takes a pointer to a Dbmovie struct and a bool indicating whether to overwrite existing data. It adds the "tt" prefix to the IMDB ID if missing, fetches the title from the IMDB API, and clears temporary variables.
type DbmovieTitle ¶
type DbmovieTitle struct {
Title string
Slug string
Region string
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
DbmovieID uint `db:"dbmovie_id"`
}
func QueryDbmovieTitle ¶
func QueryDbmovieTitle(qu Querywithargs, args ...any) []DbmovieTitle
QueryDbmovieTitle queries the dbmovie_titles table using the provided Querywithargs struct and arguments. It sets the query size and limit, table name, default columns to select, builds the query if needed, and executes the query using QueryStaticArrayN, returning a slice of DbmovieTitle structs.
type Dbserie ¶
type Dbserie struct {
Seriename string
Aliases string
Season string
Status string
Firstaired string
Network string
Runtime string
Language string
Genre string
Overview string
Rating string
Siterating string
SiteratingCount string `db:"siterating_count"`
Slug string
ImdbID string `db:"imdb_id"`
FreebaseMID string `db:"freebase_m_id"`
FreebaseID string `db:"freebase_id"`
Facebook string
Instagram string
Twitter string
Banner string
Poster string
Fanart string
Identifiedby string
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
TraktID int `db:"trakt_id"`
ThetvdbID int `db:"thetvdb_id"`
TvrageID int `db:"tvrage_id"`
ID uint
}
func GetDbserieByID ¶
GetDbserieByID retrieves a Dbserie by ID. It takes a uint ID and returns a Dbserie struct and error. It executes a SQL query using the structscanG function to select the dbserie data and scan it into the Dbserie struct. Returns an error if there was a problem retrieving the data.
func QueryDbserie ¶
func QueryDbserie(qu Querywithargs, args ...any) []Dbserie
QueryDbserie queries the dbseries table using the provided Querywithargs struct and arguments. It sets the query size and limit, table name, default columns to select, builds the query if needed, and executes the query using QueryStaticArrayN, returning a slice of Dbserie structs.
func (*Dbserie) GetDbserieByIDP ¶
GetDbserieByIDP retrieves a Dbserie by ID. It takes a uint ID and a pointer to a Dbserie struct to scan the result into. It executes a SQL query using the structscan function to select the dbserie data and scan it into the Dbserie struct. Returns an error if there was a problem retrieving the data.
type DbserieAlternate ¶
type DbserieAlternate struct {
Title string
Slug string
Region string
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
DbserieID uint `db:"dbserie_id"`
}
func QueryDbserieAlternates ¶
func QueryDbserieAlternates(qu Querywithargs, args ...any) []DbserieAlternate
QueryDbserieAlternates queries the dbserie_alternates table based on the provided Querywithargs struct and arguments. It sets the query size limit from the Limit field if greater than 0. It sets the default columns to query. It builds the query string if not already set. It executes the query using QueryStaticArrayN to return a slice of DbserieAlternate structs.
type DbserieEpisode ¶
type DbserieEpisode struct {
Episode string
Season string
Identifier string
Title string
Overview string
Poster string
FirstAired sql.NullTime `db:"first_aired" json:"first_aired" time_format:"2006-01-02" time_utc:"1"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
Runtime int
ID uint
DbserieID uint `db:"dbserie_id"`
}
func QueryDbserieEpisodes ¶
func QueryDbserieEpisodes(qu Querywithargs, args ...any) []DbserieEpisode
QueryDbserieEpisodes queries the dbserie_episodes table based on the provided Querywithargs struct and arguments. It sets the query size limit from the Limit field if greater than 0. It sets the default columns to query. It builds the query string if not already set. It executes the query using QueryStaticArrayN to return a slice of DbserieEpisode structs.
func (*DbserieEpisode) GetDbserieEpisodesByIDP ¶
func (u *DbserieEpisode) GetDbserieEpisodesByIDP(id *uint) error
GetDbserieEpisodesByIDP retrieves a DbserieEpisode by ID. It takes a uint ID and a pointer to a DbserieEpisode struct to scan the result into. It executes a SQL query using the structscan function to select the dbserie episode data and scan it into the DbserieEpisode struct. Returns an error if there was a problem retrieving the data.
type DbstaticOneIntOneBool ¶
type DbstaticOneStringOneInt ¶
type DbstaticOneStringTwoInt ¶
type DbstaticOneStringTwoInt struct {
Str string `db:"str"`
Num1 uint `db:"num1"`
Num2 uint `db:"num2"`
}
func GetCachedTwoIntArr ¶
func GetCachedTwoIntArr(key string, checkexpire bool, retry bool) []DbstaticOneStringTwoInt
GetCachedTwoIntArr retrieves the cached array of DbstaticOneStringTwoInt objects associated with the given key. If no cached object is found for the key, or the cached object has expired, it returns nil. The checkexpire parameter determines whether to check if the cached object has expired. The retry parameter determines whether to refresh the cached object if it is empty or the zero value.
type DbstaticThreeString ¶
type DbstaticThreeStringTwoInt ¶
type DbstaticThreeStringTwoInt struct {
Str1 string `db:"str1"`
Str2 string `db:"str2"`
Str3 string `db:"str3"`
Num1 int `db:"num1"`
Num2 uint `db:"num2"`
}
func GetCachedThreeStringArr ¶
func GetCachedThreeStringArr(key string, checkexpire bool, retry bool) []DbstaticThreeStringTwoInt
GetCachedThreeStringArr retrieves the cached array of DbstaticThreeStringTwoInt objects associated with the given key. If no cached object is found for the key, or the cached object has expired, it returns nil. The checkexpire parameter determines whether to check if the cached object has expired. The retry parameter determines whether to refresh the cached object if it is empty or the zero value.
type DbstaticTwoString ¶
type DbstaticTwoStringOneInt ¶
type DbstaticTwoStringOneInt struct {
Str1 string `db:"str1"`
Str2 string `db:"str2"`
Num uint `db:"num"`
}
func GetCachedTwoStringArr ¶
func GetCachedTwoStringArr(key string, checkexpire bool, retry bool) []DbstaticTwoStringOneInt
GetCachedTwoStringArr retrieves the cached array of DbstaticTwoStringOneInt objects associated with the given key. If no cached object is found for the key, or the cached object has expired, it returns nil. The checkexpire parameter determines whether to check if the cached object has expired. The retry parameter determines whether to refresh the cached object if it is empty or the zero value.
func GetDbstaticTwoStringOneInt ¶
func GetDbstaticTwoStringOneInt(s []DbstaticTwoStringOneInt, id uint) []DbstaticTwoStringOneInt
func Getentryalternatetitlesdirect ¶
func Getentryalternatetitlesdirect(dbid *uint, useseries bool) []DbstaticTwoStringOneInt
Getentryalternatetitlesdirect retrieves a slice of DbstaticTwoStringOneInt objects that represent alternate titles for the movie with the given database ID. If the UseMediaCache setting is enabled, it will retrieve the titles from the cache. Otherwise, it will retrieve the titles directly from the database.
func (*DbstaticTwoStringOneInt) ChecknzbtitleC ¶
func (movie *DbstaticTwoStringOneInt) ChecknzbtitleC(nzbtitle string, allowpm1 bool, yearu uint16) bool
ChecknzbtitleC checks if the given nzbtitle matches the title or alternate title of the movie. It also allows checking for the movie title with the year before and after the given year.
type DbstaticTwoUint ¶
type ImdbRatings ¶
type ImdbTitle ¶
type ImdbTitle struct {
Tconst string
TitleType string `db:"title_type"`
PrimaryTitle string `db:"primary_title"`
Slug string
OriginalTitle string `db:"original_title"`
Genres string
EndYear int `db:"end_year"`
RuntimeMinutes int `db:"runtime_minutes"`
StartYear uint16 `db:"start_year"`
IsAdult bool `db:"is_adult"`
}
type IndexerFail ¶
type JobHistory ¶
type JobHistory struct {
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
JobType string `db:"job_type"`
JobCategory string `db:"job_category"`
JobGroup string `db:"job_group"`
Started sql.NullTime
Ended sql.NullTime
ID uint
}
func QueryJobHistory ¶
func QueryJobHistory(qu Querywithargs, args ...any) []JobHistory
QueryJobHistory retrieves JobHistory records matching the query arguments. It takes a Querywithargs struct to define the query parameters. It returns a slice of JobHistory structs matching the query.
type Movie ¶
type Movie struct {
QualityProfile string `db:"quality_profile"`
Listname string
Rootpath string
Lastscan sql.NullTime
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
DbmovieID uint `db:"dbmovie_id"`
Blacklisted bool
QualityReached bool `db:"quality_reached"`
Missing bool
DontUpgrade bool `db:"dont_upgrade"`
DontSearch bool `db:"dont_search"`
}
func GetMovies ¶
func GetMovies(qu Querywithargs, args ...any) (*Movie, error)
GetMovies retrieves a Movie struct based on the provided Querywithargs. It sets the query table and columns. It builds the query if not already set. It executes the query and scans the result into a Movie struct. Returns the Movie struct and any error.
func QueryMovies ¶
QueryMovies retrieves all Movie records matching the given listname. It takes a string containing the listname to search for. It returns a slice of Movie structs matching the listname.
func (*Movie) GetMoviesByIDP ¶
GetMoviesByIDP retrieves a Movie by ID. It takes a uint ID and a pointer to a Movie struct to scan the result into. It executes a SQL query using the structscan function to select the movie data and scan it into the Movie struct. Returns an error if there was a problem retrieving the data.
type MovieFile ¶
type MovieFile struct {
Location string
Filename string
Extension string
QualityProfile string `db:"quality_profile"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ResolutionID uint `db:"resolution_id"`
QualityID uint `db:"quality_id"`
CodecID uint `db:"codec_id"`
AudioID uint `db:"audio_id"`
MovieID uint `db:"movie_id"`
DbmovieID uint `db:"dbmovie_id"`
ID uint
Height uint16
Width uint16
Proper bool
Extended bool
Repack bool
}
type MovieFileUnmatched ¶
type MovieFileUnmatched struct {
Listname string
Filepath string
ParsedData string `db:"parsed_data"`
LastChecked sql.NullTime `db:"last_checked"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
}
func QueryMovieFileUnmatched ¶
func QueryMovieFileUnmatched(qu Querywithargs, args ...any) []MovieFileUnmatched
QueryMovieFileUnmatched retrieves MovieFileUnmatched records matching the query arguments. It takes a Querywithargs struct to define the query parameters. It returns a slice of MovieFileUnmatched structs matching the query.
type MovieHistory ¶
type MovieHistory struct {
Title string
URL string
Indexer string
HistoryType string `db:"type"`
Target string
QualityProfile string `db:"quality_profile"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DownloadedAt time.Time `db:"downloaded_at"`
ID uint
ResolutionID uint `db:"resolution_id"`
QualityID uint `db:"quality_id"`
CodecID uint `db:"codec_id"`
AudioID uint `db:"audio_id"`
MovieID uint `db:"movie_id"`
DbmovieID uint `db:"dbmovie_id"`
Blacklisted bool
}
type ParseInfo ¶
type ParseInfo struct {
Episodes []DbstaticTwoUint `json:"-"`
// Languages is a list of language codes
Languages []string `json:"languages,omitempty"`
Str string // used internally
// File is the path to the media file
File string
// SeasonStr is the season number as a string, if applicable
SeasonStr string `json:"seasonstr,omitempty"`
// EpisodeStr is the episode number as a string, if applicable
EpisodeStr string `json:"episodestr,omitempty"`
// Title is the title of the media
Title string
// Resolution is the video resolution
Resolution string `json:"resolution,omitempty"`
// Quality is the video quality description
Quality string `json:"quality,omitempty"`
// Codec is the video codec
Codec string `json:"codec,omitempty"`
// Audio is the audio description
Audio string `json:"audio,omitempty"`
RuntimeStr string `json:"-"`
TempTitle string
// Identifier is an identifier string
Identifier string `json:"identifier,omitempty"`
// Date is the release date
Date string `json:"date,omitempty"`
// Imdb is the IMDB ID
Imdb string `json:"imdb,omitempty"`
// Tvdb is the TVDB ID
Tvdb string `json:"tvdb,omitempty"`
// Priority is the priority for downloading
Priority int `json:"priority,omitempty"`
// Season is the season number, if applicable
Season int `json:"season,omitempty"`
// Episode is the episode number, if applicable
Episode int `json:"episode,omitempty"`
// Runtime is the runtime in minutes
Runtime int `json:"runtime,omitempty"`
// ListID is the ID of the list this came from
ListID int
FirstIDX int
FirstYearIDX int
// Height is the video height in pixels
Height int `json:"height,omitempty"`
// Width is the video width in pixels
Width int `json:"width,omitempty"`
TempID uint
// ResolutionID is the database ID of the resolution
ResolutionID uint `json:"resolutionid,omitempty"`
// QualityID is the database ID of the quality
QualityID uint `json:"qualityid,omitempty"`
// CodecID is the database ID of the codec
CodecID uint `json:"codecid,omitempty"`
// AudioID is the database ID of the audio
AudioID uint `json:"audioid,omitempty"`
// DbmovieID is the database ID of the movie
DbmovieID uint `json:"dbmovieid,omitempty"`
// MovieID is the application ID of the movie
MovieID uint `json:"movieid,omitempty"`
// DbserieID is the database ID of the TV series
DbserieID uint `json:"dbserieid,omitempty"`
// DbserieEpisodeID is the database ID of the episode
DbserieEpisodeID uint `json:"dbserieepisodeid,omitempty"`
// SerieID is the application ID of the TV series
SerieID uint `json:"serieid,omitempty"`
// SerieEpisodeID is the application ID of the episode
SerieEpisodeID uint `json:"serieepisodeid,omitempty"`
// Year is the year of release
Year uint16 `json:"year,omitempty"`
// Extended is a flag indicating if it is an extended version
Extended bool `json:"extended,omitempty"`
// Proper is a flag indicating if it is a proper release
Proper bool `json:"proper,omitempty"`
// Repack is a flag indicating if it is a repack release
Repack bool `json:"repack,omitempty"`
}
ParseInfo is a struct containing parsed information about media files.
func (*ParseInfo) AddUnmatched ¶
func (m *ParseInfo) AddUnmatched(cfgp *config.MediaTypeConfig, listname *string, err error)
AddUnmatched adds an unmatched file to the database. If the file is already in the cache, it returns without adding it. Otherwise, it inserts a new record into the appropriate table (movie_file_unmatcheds or serie_file_unmatcheds) with the file path, list name, and parsed data.
func (*ParseInfo) CacheThreeStringIntIndexFuncGetImdb ¶
func (m *ParseInfo) CacheThreeStringIntIndexFuncGetImdb()
CacheThreeStringIntIndexFuncGetImdb retrieves the IMDB value from a cached array of DbstaticThreeStringTwoInt objects that match the provided string and uint values. If a matching object is found, the IMDB value is stored in the ParseInfo struct. If no matching object is found, this method does nothing.
func (*ParseInfo) Checktitle ¶
func (m *ParseInfo) Checktitle(cfgp *config.MediaTypeConfig, qualcfg *config.QualityConfig, title string) bool
Checktitle checks if the given wanted title and year match the parsed title and year from the media file. It compares the wanted title against any alternate titles for the media entry from the database. Returns true if the title is unwanted and should be skipped.
func (*ParseInfo) Cleanimdbdbmovie ¶
func (m *ParseInfo) Cleanimdbdbmovie()
Ceanimdbdbmovie clears the Imdb and DbmovieID fields in the FileParser struct to empty values. This is used to reset the state when a lookup fails.
func (*ParseInfo) ClearArr ¶
func (m *ParseInfo) ClearArr()
ClearArr resets the Languages field of the ParseInfo struct to nil, effectively clearing the array.
func (*ParseInfo) Close ¶
func (m *ParseInfo) Close()
Close resets the ParseInfo struct to its initial state by setting the Languages field to nil and initializing the struct to its zero value.
func (*ParseInfo) ExecParsed ¶
func (m *ParseInfo) ExecParsed(cfgp *config.MediaTypeConfig, err error, listname *string)
ExecParsed adds an unmatched file to the database or updates an existing unmatched file record. It constructs a string representation of the parsed file information and inserts a new record or updates an existing record in the appropriate table (movie_file_unmatcheds or serie_file_unmatcheds).
func (*ParseInfo) FindDbserieByName ¶
FindDbserieByName looks up the database series ID by the title of the media. It first checks the media cache for the series ID, and if not found, it attempts to find the series ID by the title or a slugged version of the title. If the series ID is still not found, it checks the alternate titles in the database. This function is used to populate the DbserieID field on the ParseInfo struct.
func (*ParseInfo) FindDbserieByNameWithSlug ¶
FindDbserieByNameWithSlug attempts to find a database series by the provided title string. It first trims any leading or trailing whitespace from the title, then calls FindDbserieByName with the trimmed title. If no series is found, it calls FindDbserieByName again with the slugged version of the title.
func (*ParseInfo) Findmoviedbidbytitle ¶
Findmoviedbidbytitle queries the database to find the movie ID for the given title. If the UseMediaCache setting is enabled, it retrieves the movie ID from the cache using the Getdbmovieidbytitleincache method. Otherwise, it queries the dbmovies table directly to find the movie ID for the given title, and if not found, it queries the dbmovie_titles table. If a movie ID is found, it attempts to retrieve the IMDB title using the Moviegetimdbtitleparser method. If the IMDB title is not found, the DbmovieID is set to 0.
func (*ParseInfo) GenerateIdentifierString ¶
func (m *ParseInfo) GenerateIdentifierString()
GenerateIdentifierString generates an identifier string for a movie or episode in the format "S{season}E{episode}", where {season} and {episode} are the season and episode numbers formatted as strings.
func (*ParseInfo) Getepisodestoimport ¶
Getepisodestoimport retrieves a slice of DbstaticTwoUint values representing the episode IDs to import for the given series ID and database series ID. If the episode array is empty, it returns an ErrNotFoundEpisode error. If there is only one episode and the SerieEpisodeID and DbserieEpisodeID are set, it returns a single-element slice with those values. Otherwise, it populates the episode IDs into the returned slice.
func (*ParseInfo) Getqualityidxbyid ¶
Getqualityidxbyid searches the given quality table tbl by ID and returns the index of the matching entry, or -1 if no match is found.
func (*ParseInfo) Gettypeids ¶
Gettypeids searches through the provided qualitytype slice to find a match for the given input string inval. It checks the Strings and Regex fields of each QualitiesRegex struct, returning the ID if a match is found. 0 is returned if no match is found.
func (*ParseInfo) MovieFindDBIDByImdbParser ¶
func (m *ParseInfo) MovieFindDBIDByImdbParser()
MovieFindDBIDByImdbParser queries the database to find the movie ID for the given IMDB ID. If the IMDB ID is empty, it sets the DbmovieID to 0 and returns. If the UseMediaCache setting is enabled, it uses the CacheThreeStringIntIndexFunc to retrieve the movie ID from the cache. Otherwise, it queries the dbmovies table directly to find the movie ID for the given IMDB ID.
func (*ParseInfo) Parsegroup ¶
Parsegroup parses a group of strings from the input string and updates the corresponding fields in the ParseInfo struct. The function takes a name string, a boolean onlyifempty, and a slice of group strings as input. It searches for each group string in the input string and extracts the matched substring. If the matched substring is not empty and is not part of a larger word, the function updates the corresponding field in the ParseInfo struct based on the name parameter. If onlyifempty is true, the function will only update the field if it is currently empty. The function supports the following names: "audio", "codec", "quality", "resolution", "extended", "proper", and "repack".
func (*ParseInfo) ParsegroupEntry ¶
ParsegroupEntry parses a group of characters from the input string and updates the corresponding fields in the ParseInfo struct. The function takes a name string and a group string as input. It searches for the group string in the input string and extracts the matched substring. If the matched substring is not empty and is not part of a larger word, the function updates the corresponding field in the ParseInfo struct based on the name parameter. The function supports the following names: "audio", "codec", "quality", "resolution", "extended", "proper", and "repack".
func (*ParseInfo) Parseresolution ¶
Parseresolution returns a string representation of the video resolution based on the height and width of the video. The resolution is determined by the following rules: - If the height is 360, the resolution is "360p" - If the height is greater than 1080, the resolution is "2160p" - If the height is greater than 720, the resolution is "1080p" - If the height is greater than 576, the resolution is "720p" - If the height is greater than 480, the resolution is "576p" - If the height is greater than 368, the resolution is "480p" - If the height is greater than 360, the resolution is "368p" - If the width is 720 and the height is at least 576, the resolution is "576p" - If the width is 720 and the height is less than 576, the resolution is "480p" - If the width is 1280, the resolution is "720p" - If the width is 1920, the resolution is "1080p" - If the width is 3840, the resolution is "2160p" - If the height and width do not match any of the above cases, the resolution is "Unknown Resolution".
func (*ParseInfo) RegexGetMatchesStr1 ¶
func (m *ParseInfo) RegexGetMatchesStr1(cfgp *config.MediaTypeConfig)
RegexGetMatchesStr1 extracts the series name from the filename by using a regular expression match. It looks for the series name substring in the filename, trims extra characters, and calls findDbserieByName to look up the series ID.
func (*ParseInfo) SetDBEpisodeIDfromM ¶
func (m *ParseInfo) SetDBEpisodeIDfromM()
SetDBEpisodeIDfromM sets the DbserieEpisodeID field on the FileParser struct by looking up the episode ID in the database based on the season, episode, and identifier fields. It first tries looking up by season and episode number strings, then falls back to the identifier.
func (*ParseInfo) SetEpisodeIDfromM ¶
func (m *ParseInfo) SetEpisodeIDfromM()
SetEpisodeIDfromM sets the SerieEpisodeID field of the ParseInfo struct based on the SerieID and DbserieEpisodeID fields. If SerieID or DbserieEpisodeID is 0, SerieEpisodeID is set to 0. Otherwise, it queries the database to find the corresponding serie_episodes record and sets SerieEpisodeID.
func (*ParseInfo) StripTitlePrefixPostfixGetQual ¶
func (m *ParseInfo) StripTitlePrefixPostfixGetQual(quality *config.QualityConfig)
StripTitlePrefixPostfixGetQual removes any prefix and suffix from the title string that match the configured title strip patterns, and returns the resulting title. This is used to normalize the title for search and matching purposes.
type Qualities ¶
type Qualities struct {
Name string
Regex string
Strings string
StringsLower string
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
QualityType int `db:"type"`
Priority int
Regexgroup int
ID uint
UseRegex bool `db:"use_regex"`
}
type 1 reso 2 qual 3 codec 4 audio.
func (*Qualities) Gettypeidprioritysingle ¶
func (qual *Qualities) Gettypeidprioritysingle(qualitystringtype string, reorder *config.QualityConfig) int
Gettypeidprioritysingle returns the priority for the given Qualities struct after applying any reorder rules that match the given quality string type and name. It checks each QualityReorderConfig in the reordergroup, looking for matches on ReorderType and Name. If found, it will update the priority based on Newpriority.
type Querywithargs ¶
type Querywithargs struct {
// QueryString is the base SQL query
QueryString string
// Select is the columns to select
Select string
// Table is the main table in the query
Table string
// InnerJoin is any inner join statements
InnerJoin string
// Where is the WHERE clause
Where string
// OrderBy is the ORDER BY clause
OrderBy string
// Limit is the LIMIT clause value
Limit uint
// Offset is the OFFSET clause value
Offset int
// contains filtered or unexported fields
}
Querywithargs is a struct to hold query arguments.
type RSSHistory ¶
type ResultMovies ¶
type ResultMovies struct {
Dbmovie
Listname string
QualityProfile string `db:"quality_profile"`
Rootpath string
Lastscan sql.NullTime
DbmovieID uint `db:"dbmovie_id"`
Blacklisted bool
QualityReached bool `db:"quality_reached"`
Missing bool
}
func QueryResultMovies ¶
func QueryResultMovies(qu Querywithargs, args ...any) []ResultMovies
QueryResultMovies retrieves ResultMovies records matching the query arguments. It takes a Querywithargs struct to define the query parameters. It returns a slice of ResultMovies structs matching the query.
type ResultSerieEpisodes ¶
type ResultSerieEpisodes struct {
DbserieEpisode
Listname string
Rootpath string
QualityProfile string `db:"quality_profile"`
Lastscan sql.NullTime
DbserieEpisodeID uint `db:"dbserie_episode_id"`
Blacklisted bool
QualityReached bool `db:"quality_reached"`
Missing bool
}
func QueryResultSerieEpisodes ¶
func QueryResultSerieEpisodes(qu Querywithargs, args ...any) []ResultSerieEpisodes
QueryResultSerieEpisodes retrieves ResultSerieEpisodes records matching the query arguments. It takes a Querywithargs struct to define the query parameters. It returns a slice of ResultSerieEpisodes structs matching the query.
type ResultSeries ¶
type ResultSeries struct {
Dbserie
Listname string
Rootpath string
DbserieID uint `db:"dbserie_id"`
}
func QueryResultSeries ¶
func QueryResultSeries(qu Querywithargs, args ...any) []ResultSeries
QueryResultSeries retrieves ResultSeries records matching the query arguments. It takes a Querywithargs struct to define the query parameters. It returns a slice of ResultSeries structs matching the query.
type Serie ¶
type Serie struct {
Listname string
Rootpath string
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
DbserieID uint `db:"dbserie_id"`
DontUpgrade bool `db:"dont_upgrade"`
DontSearch bool `db:"dont_search"`
SearchSpecials bool `db:"search_specials"`
IgnoreRuntime bool `db:"ignore_runtime"`
}
func GetSeries ¶
func GetSeries(qu Querywithargs, args ...any) (*Serie, error)
GetSeries retrieves a Serie struct based on the provided Querywithargs. It sets the query table and columns. It builds the query if not already set. It executes the query and scans the result into a Serie struct. Returns the Serie struct and any error.
func (*Serie) GetSerieByIDP ¶
GetSerieByIDP retrieves a Serie by ID. It takes a uint ID and a pointer to a Serie struct to scan the result into. It executes a SQL query using the structscan function to select the serie data and scan it into the Serie struct. Returns an error if there was a problem retrieving the data.
type SerieEpisode ¶
type SerieEpisode struct {
QualityProfile string `db:"quality_profile"`
Lastscan sql.NullTime
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DbserieEpisodeID uint `db:"dbserie_episode_id"`
SerieID uint `db:"serie_id"`
DbserieID uint `db:"dbserie_id"`
ID uint
Blacklisted bool
QualityReached bool `db:"quality_reached"`
Missing bool
DontUpgrade bool `db:"dont_upgrade"`
DontSearch bool `db:"dont_search"`
IgnoreRuntime bool `db:"ignore_runtime"`
}
func GetSerieEpisodes ¶
func GetSerieEpisodes(qu Querywithargs, args ...any) (*SerieEpisode, error)
GetSerieEpisodes retrieves a SerieEpisode struct based on the provided Querywithargs. It sets the query table and columns. It builds the query if not already set. It executes the query and scans the result into a SerieEpisode struct. Returns a SerieEpisode struct and any error.
func QuerySerieEpisodes ¶
func QuerySerieEpisodes(args *string) []SerieEpisode
QuerySerieEpisodes retrieves all SerieEpisode records for the given series listname. It takes a pointer to a string containing the listname to search for. It returns a slice of SerieEpisode structs matching the listname.
func (*SerieEpisode) GetSerieEpisodesByIDP ¶
func (u *SerieEpisode) GetSerieEpisodesByIDP(id *uint) error
GetSerieEpisodesByIDP retrieves a SerieEpisode by ID. It takes a uint ID and a pointer to a SerieEpisode struct to scan the result into. It executes a SQL query using the structscan function to select the serie episode data and scan it into the SerieEpisode struct. Returns an error if there was a problem retrieving the data.
type SerieEpisodeFile ¶
type SerieEpisodeFile struct {
Location string
Filename string
Extension string
QualityProfile string `db:"quality_profile"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
ResolutionID uint `db:"resolution_id"`
QualityID uint `db:"quality_id"`
CodecID uint `db:"codec_id"`
AudioID uint `db:"audio_id"`
SerieID uint `db:"serie_id"`
SerieEpisodeID uint `db:"serie_episode_id"`
DbserieEpisodeID uint `db:"dbserie_episode_id"`
DbserieID uint `db:"dbserie_id"`
Height uint16
Width uint16
Proper bool
Extended bool
Repack bool
}
type SerieEpisodeHistory ¶
type SerieEpisodeHistory struct {
Title string
URL string
Indexer string
SerieType string `db:"type"`
Target string
QualityProfile string `db:"quality_profile"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DownloadedAt time.Time `db:"downloaded_at"`
ID uint
ResolutionID uint `db:"resolution_id"`
QualityID uint `db:"quality_id"`
CodecID uint `db:"codec_id"`
AudioID uint `db:"audio_id"`
SerieID uint `db:"serie_id"`
SerieEpisodeID uint `db:"serie_episode_id"`
DbserieEpisodeID uint `db:"dbserie_episode_id"`
DbserieID uint `db:"dbserie_id"`
Blacklisted bool
}
type SerieFileUnmatched ¶
type SerieFileUnmatched struct {
Listname string
Filepath string
ParsedData string `db:"parsed_data"`
LastChecked sql.NullTime `db:"last_checked"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID uint
}
func QuerySerieFileUnmatched ¶
func QuerySerieFileUnmatched(qu Querywithargs, args ...any) []SerieFileUnmatched
QuerySerieFileUnmatched retrieves SerieFileUnmatched records matching the query arguments. It takes a Querywithargs struct to define the query parameters. It returns a slice of SerieFileUnmatched structs matching the query.