Documentation ¶
Index ¶
- Constants
- Variables
- func AddImdbPrefix(str string) string
- func AddTvdbPrefix(str string) string
- func BuilderAddInt(bld *bytes.Buffer, i int)
- func BuilderAddUint(bld *bytes.Buffer, i uint)
- func ByteReplaceWithByte(s []byte, r rune, t rune) []byte
- func Contains[S ~[]E, E comparable](s S, v E) bool
- func ContainsI(a string, b string) bool
- func ContainsInt(a string, b int) bool
- func DiacriticsReplacer(s string) string
- func GetStringsMap(useseries bool, typestr string) string
- func GetTimeFormat() string
- func GetTimeZone() *time.Location
- func Getrootpath(foldername string) string
- func Getstringarrlength(elems []string) int
- func HasPrefixI(s, prefix string) bool
- func HasSuffixI(s, suffix string) bool
- func IndexI(a string, b string) int
- func IndexILast(a string, b string) int
- func InitLogger(config Config)
- func JoinStrings(elems ...string) string
- func LogDynamic(typev string, msg string, fields ...LogField)
- func LogDynamicSlice(typev string, msg string, staticfields []LogField, fields ...LogField)
- func ParseJson(r io.Reader, obj any) error
- func ParseStringTemplate(message string, messagedata any) (bool, string)
- func ParseToml(r io.Reader, obj any) error
- func Path(s string, allowslash bool) string
- func SlicesContainsI(s []string, v string) bool
- func SlicesContainsPart2I(s []string, v string) bool
- func SplitByFullP(str string, splitby rune) string
- func SplitByLR(str string, splitby byte) (string, string)
- func StringRemoveAllRunes(s string, r rune) string
- func StringRemoveAllRunesMulti(s string, r ...rune) string
- func StringReplaceWith(s string, r rune, t rune) string
- func StringReplaceWithByte(s string, r rune, t rune) []byte
- func StringToFileMode(s string) fs.FileMode
- func StringToInt(s string) int
- func StringToInt64(s string) int64
- func StringToSlug(instr string) string
- func TimeGetNow() time.Time
- func TrimStringInclAfterString(s string, search string) string
- func URLJoinPath(base string, elem ...string) string
- func UnquoteUnescape(s string) string
- type Config
- type LogField
Constants ¶
const ( FilterByID = "id = ?" StrRefreshMovies = "Refresh Movies" StrRefreshMoviesInc = "Refresh Movies Incremental" StrRefreshSeries = "Refresh Series" StrRefreshSeriesInc = "Refresh Series Incremental" StrDebug = "debug" StrDate = "date" StrID = "id" StrURL = "Url" StrQuery = "Query" StrJob = "Job" StrJobLower = "job" StrFile = "File" StrPath = "Path" StrListname = "Listname" StrImdb = "imdb" StrTitle = "Title" StrPriority = "Priority" StrSearchMissingInc = "searchmissinginc" StrSearchMissingFull = "searchmissingfull" StrSearchMissingIncTitle = "searchmissinginctitle" StrSearchMissingFullTitle = "searchmissingfulltitle" StrSearchUpgradeInc = "searchupgradeinc" StrSearchUpgradeFull = "searchupgradefull" StrSearchUpgradeIncTitle = "searchupgradeinctitle" StrSearchUpgradeFullTitle = "searchupgradefulltitle" StrStructure = "structure" StrCheckMissing = "checkmissing" StrCheckMissingFlag = "checkmissingflag" StrUpgradeFlag = "checkupgradeflag" StrReachedFlag = "checkreachedflag" StrClearHistory = "clearhistory" StrRssSeasonsAll = "rssseasonsall" StrSerie = "serie" StrRssSeasons = "rssseasons" StrRss = "rss" Underscore = "_" StrTvdb = "tvdb" StrTt = "tt" StrSeries = "series" CacheDBMedia = "CacheDBMedia" DBCountDBMedia = "DBCountDBMedia" DBCacheDBMedia = "DBCacheDBMedia" CacheMedia = "CacheMedia" DBCountMedia = "DBCountMedia" DBCacheMedia = "DBCacheMedia" CacheHistoryTitle = "CacheHistoryTitle" CacheHistoryUrl = "CacheHistoryUrl" DBHistoriesUrl = "DBHistoriesUrl" DBHistoriesTitle = "DBHistoriesTitle" DBCountHistoriesUrl = "DBCountHistoriesUrl" DBCountHistoriesTitle = "DBCountHistoriesTitle" CacheMediaTitles = "CacheMediaTitles" DBCountDBTitles = "DBCountDBTitles" DBCacheDBTitles = "DBCacheDBTitles" CacheFiles = "CacheFiles" DBCountFiles = "DBCountFiles" DBCacheFiles = "DBCacheFiles" CacheUnmatched = "CacheUnmatched" DBCountUnmatched = "DBCountUnmatched" DBCacheUnmatched = "DBCacheUnmatched" DBCountFilesLocation = "DBCountFilesLocation" DBCountUnmatchedPath = "DBCountUnmatchedPath" DBCountDBTitlesDBID = "DBCountDBTitlesDBID" DBDistinctDBTitlesDBID = "DBDistinctDBTitlesDBID" DBMediaTitlesID = "DBMediaTitlesID" DBFilesQuality = "DBFilesQuality" DBCountFilesByList = "DBCountFilesByList" DBLocationFilesByList = "DBLocationFilesByList" DBIDsFilesByLocation = "DBIDsFilesByLocation" DBCountFilesByMediaID = "DBCountFilesByMediaID" DBCountFilesByLocation = "DBCountFilesByLocation" TableFiles = "TableFiles" TableMedia = "TableMedia" DBCountMediaByList = "DBCountMediaByList" DBIDMissingMediaByList = "DBIDMissingMediaByList" DBUpdateMissing = "DBUpdateMissing" DBListnameByMediaID = "DBListnameByMediaID" DBRootPathFromMediaID = "DBRootPathFromMediaID" DBDeleteFileByIDLocation = "DBDeleteFileByIDLocation" DBCountHistoriesByTitle = "DBCountHistoriesByTitle" DBCountHistoriesByUrl = "DBCountHistoriesByUrl" DBLocationIDFilesByID = "DBLocationIDFilesByID" DBFilePrioFilesByID = "DBFilePrioFilesByID" UpdateMediaLastscan = "UpdateMediaLastscan" DBQualityMediaByID = "DBQualityMediaByID" SearchGenSelect = "SearchGenSelect" SearchGenTable = "SearchGenTable" SearchGenMissing = "SearchGenMissing" SearchGenMissingEnd = "SearchGenMissingEnd" SearchGenReached = "SearchGenReached" SearchGenLastScan = "SearchGenLastScan" SearchGenDate = "SearchGenDate" SearchGenOrder = "SearchGenOrder" CacheMovie = "CacheMovie" CacheSeries = "CacheSeries" CacheDBMovie = "CacheDBMovie" CacheDBSeries = "CacheDBSeries" CacheDBSeriesAlt = "CacheDBSeriesAlt" CacheTitlesMovie = "CacheTitlesMovie" CacheUnmatchedMovie = "CacheUnmatchedMovie" CacheUnmatchedSeries = "CacheUnmatchedSeries" CacheFilesMovie = "CacheFilesMovie" CacheFilesSeries = "CacheFilesSeries" CacheHistoryUrlMovie = "CacheHistoryUrlMovie" CacheHistoryTitleMovie = "CacheHistoryTitleMovie" CacheHistoryUrlSeries = "CacheHistoryUrlSeries" CacheHistoryTitleSeries = "CacheHistoryTitleSeries" )
Variables ¶
var ( V0 uint = 0 StrFeeds = "feeds" StrData = "data" StrDataFull = "datafull" StrMovie = "movie" Log zerolog.Logger //diacriticsReplacer = strings.NewReplacer("ä", "ae", "ö", "oe", "ü", "ue", "Ä", "Ae", "Ö", "Oe", "Ü", "Ue", "ß", "ss") //pathReplacer = strings.NewReplacer(":", "", "*", "", "?", "", "\"", "", "<", "", ">", "", "|", "") ErrNoID = errors.New("no id") ErrNoFiles = errors.New("no files") ErrNotFound = errors.New("not found") Errwrongtype = errors.New("wrong type") ErrRuntime = errors.New("wrong runtime") ErrNotAllowed = errors.New("not allowed") ErrLowerQuality = errors.New("lower quality") ErrOther = errors.New("other error") ErrDisabled = errors.New("disabled") ErrToWait = errors.New("please wait") ErrTooSmall = errors.New("too small") ErrDailyLimit = errors.New("daily limit reached") Errnoresults = errors.New("no results") ErrNotFoundDbmovie = errors.New("dbmovie not found") ErrNotFoundMovie = errors.New("movie not found") ErrNotFoundDbserie = errors.New("dbserie not found") ErrNotFoundSerie = errors.New("serie not found") ErrNotEnabled = errors.New("not enabled") ErrCfgpNotFound = errors.New("cfgpstr not found") ErrNotFoundDBEpisode = errors.New("dbepisode not found") ErrNotFoundEpisode = errors.New("episode not found") ErrListnameEmpty = errors.New("listname empty") ErrTvdbEmpty = errors.New("tvdb empty") ErrImdbEmpty = errors.New("imdb empty") ErrSearchvarEmpty = errors.New("searchvar empty") ErrTracksEmpty = errors.New("tracks empty") PlBuffer = pool.NewPool(100, 0, func(b *bytes.Buffer) {}, func(b *bytes.Buffer) { b.Reset() }) )
Functions ¶
func AddImdbPrefix ¶
AddImdbPrefix prepends the imdb prefix if it doesn't already exist.
func AddTvdbPrefix ¶
AddTvdbPrefix prepends the tvdb prefix if it doesn't already exist.
func BuilderAddInt ¶
BuilderAddInt writes the string representation of the given int to the given bytes.Buffer.
func BuilderAddUint ¶
BuilderAddUint writes the string representation of the unsigned integer i to the buffer bld.
func ByteReplaceWithByte ¶
StringReplaceWith replaces all occurrences of the rune r in s with the rune t. It returns a new string with the replacements.
func Contains ¶
func Contains[S ~[]E, E comparable](s S, v E) bool
Contains reports whether v is contained in s.
func ContainsI ¶
ContainsI checks if string a contains string b, ignoring case. It first checks for a direct match with strings.Contains. If not found, it does a case-insensitive search by looping through a and comparing substrings with EqualFold.
func ContainsInt ¶
ContainsInt checks if the string a contains the string representation of the integer b. It converts b to a string using strconv.Itoa and calls strings.Contains to check for a match.
func DiacriticsReplacer ¶
diacriticsReplacer replaces diacritic marks in the input string s with their ASCII equivalents, based on the provided diacriticsmap. It calls the replacer function to perform the replacements.
func GetStringsMap ¶
GetStringsMap returns the map of strings for the given type based on whether to use the series or movies map. If useseries is true, it returns the mapstringsseries map, otherwise it returns the mapstringsmovies map.
func GetTimeFormat ¶
func GetTimeFormat() string
GetTimeFormat returns the time format string used for formatting logs. This allows checking the current time format.
func GetTimeZone ¶
GetTimeZone returns a pointer to the time.Location representing the timezone used for formatting logs. This allows checking the current timezone.
func Getrootpath ¶
Getrootpath returns the root path of the given folder name by splitting on '/' or '\' and trimming any trailing slashes. If no slashes, it just trims trailing slashes.
func Getstringarrlength ¶
Getstringarrlength returns the total length of all strings in the given string slice elems. It iterates through the slice and sums the individual string lengths.
func HasPrefixI ¶
HasPrefixI checks if string s starts with prefix, ignoring case. It first checks for a direct match with strings.HasPrefix. If not found, it does a case-insensitive check by comparing the substring of s from 0 to len(prefix) with prefix using EqualFold.
func HasSuffixI ¶
HasSuffixI checks if string s ends with suffix, ignoring case. It first checks for a direct match with strings.HasSuffix. If not found, it does a case-insensitive check by comparing the substring of s from len(s)-len(suffix) to len(s) with suffix using EqualFold.
func IndexI ¶
IndexI searches for the first case-insensitive instance of b in a. It returns the index of the first match, or -1 if no match is found.
func IndexILast ¶
IndexILast searches for the last case-insensitive instance of b in a. It returns the index of the last match, or -1 if no match is found.
func InitLogger ¶
func InitLogger(config Config)
InitLogger initializes the global logger based on the provided Config. It sets the log level, output format, rotation options, etc.
func JoinStrings ¶
JoinStrings concatenates any number of strings together. It is optimized to avoid unnecessary allocations when there are few elements.
func LogDynamic ¶
LogDynamic logs a message with dynamic log level and arbitrary fields. It takes the log level type as the first argument, followed by the log message, and finally any number of LogField structs containing the key-value pairs. It allows logging with different levels and custom fields in a flexible way. For typev use one of the following: "info", "debug", "error", "fatal", "warn", "panic"
func LogDynamicSlice ¶
LogDynamicSlice logs a message with dynamic fields and static fields. It allows specifying the log level, message, static fields, and dynamic fields. The static fields are logged on every call, while the dynamic fields can vary per call. For typev use one of the following: "info", "debug", "error", "fatal", "warn", "panic"
func ParseJson ¶
ParseJson decodes the JSON encoded data from the provided reader into the given object. Returns any error encountered during decoding.
func ParseStringTemplate ¶
ParseStringTemplate parses a text/template string into a template.Template, caches it, and executes it with the given data. It returns the executed template string and any error encountered.
func ParseToml ¶
ParseToml decodes the TOML encoded data from the provided reader into the given object. Returns any error encountered during decoding.
func Path ¶
Path sanitizes the given string by cleaning it with path.Clean, unquoting and unescaping it, optionally removing slashes, and replacing invalid characters. It returns the cleaned path string.
func SlicesContainsI ¶
Contains reports whether v is present in s - case insensitive.
func SlicesContainsPart2I ¶
Contains reports whether v is contained in s - case insensitive.
func SplitByFullP ¶
SplitByFullP splits a string into two parts by the first occurrence of the split rune. It returns the part before the split. If the split rune is not found, it returns the original string.
func SplitByLR ¶
SplitByLR splits str into left and right substrings by the last occurrence of splitby byte. It returns the left substring before the split byte and the right substring after. If splitby byte is not found or invalid, an empty string and the original str are returned.
func StringRemoveAllRunes ¶
StringRemoveAllRunes removes all occurrences of the rune r from s.
func StringRemoveAllRunesMulti ¶
StringRemoveAllRunes removes all occurrences of the rune r from s.
func StringReplaceWith ¶
StringReplaceWith replaces all occurrences of the rune r in s with the rune t. It returns a new string with the replacements.
func StringReplaceWithByte ¶
StringReplaceWith replaces all occurrences of the rune r in s with the rune t. It returns a new string with the replacements.
func StringToFileMode ¶
StringToFileMode converts a string representing a file mode in octal to a uint32. It returns 0 if the string is empty or cannot be parsed.
func StringToInt ¶
StringToInt converts the given string to an int. It uses stringToUint64 to convert to a uint64 first, then converts the result to an int.
func StringToInt64 ¶
StringToInt64 converts the given string to an int64. It uses stringToUint64 to convert to a uint64 first, then converts the result to an int64.
func StringToSlug ¶
StringToSlug converts the given string to a slug format by replacing unwanted characters, transliterating accented characters, replacing multiple hyphens with a single hyphen, and trimming leading/trailing hyphens.
func TimeGetNow ¶
TimeGetNow returns the current time in the time zone specified by the global timeZone variable.
func TrimStringInclAfterString ¶
TrimStringInclAfterString truncates the given string s after the first occurrence of the search string. It returns the truncated string.
func URLJoinPath ¶
URLJoinPath joins a base URL path with any number of path elements. It uses url.JoinPath under the hood and discards any errors.
func UnquoteUnescape ¶
UnquoteUnescape unquotes a quoted string and unescapes HTML entities. It first tries to unquote the string as a quoted string literal. If that succeeds and the unquoted string contains HTML entities, it unescapes the HTML entities. If unquoting fails, it just unescapes any HTML entities in the original string.
Types ¶
type Config ¶
type Config struct { // LogLevel sets the minimum enabled logging level. Valid levels are // "debug", "info", "warn", and "error". LogLevel string // LogFileSize is the maximum size in megabytes of the log file before it gets // rotated. It defaults to 10 megabytes. LogFileSize int // LogFileCount is the maximum number of old log files to retain. // The default is 5. LogFileCount int // LogCompress determines if the rotated log files should be compressed // using gzip. The default is false. LogCompress bool // LogColorize enables output with colors LogColorize bool // TimeFormat sets the format for timestamp in logs. Valid formats are // "rfc3339", "iso8601", etc. The default is RFC3339. TimeFormat string // TimeZone sets the time zone to use for timestamps in logs. // The default is to use the local time zone. TimeZone string // LogToFileOnly disables logging to stdout. // If true, logs will only be written to the file and not also stdout. LogToFileOnly bool }
Config defines the configuration options for the logger
type LogField ¶
func NewLogField ¶
NewLogField creates a new LogField struct with the given name and value. LogField is used to represent a key-value pair that can be attached to a log entry.
func NewLogFieldValue ¶
NewLogFieldValue creates a new LogField with the given value.