Documentation ¶
Index ¶
- Variables
- func AirDateWithAiredCheck(dt string, dateFormat string, allowSameDay bool) (airDate time.Time, isAired bool)
- func ApplyColor(text string, color string) (coloredText string)
- func Bod(t time.Time) time.Time
- func Copy(src, dst string, followSymlinks bool) (string, error)
- func CopyFile(src, dst string, followSymlinks bool) error
- func CopyMode(src, dst string, followSymlinks bool) error
- func CopyTree(src, dst string, options *CopyTreeOptions) error
- func DecodeFileURL(u string) (ret string)
- func Difference(arrs ...interface{}) (reflect.Value, bool)
- func Distinct(arr interface{}) (reflect.Value, bool)
- func EffectiveDir(p string) string
- func EncodeFileURL(u string) (ret string)
- func FileExists(name string) bool
- func FileWithoutExtension(name string) string
- func FreeMemory()
- func FreeMemoryGC()
- func GetRealPath(path string) (ret string)
- func GetTimeFromFile(timeFile string) (time.Time, error)
- func HasAudioExt(filename string) bool
- func HasSubtitlesExt(filename string) bool
- func IntSliceContains(ary []int, q int) bool
- func IsAudioExt(ext string) bool
- func IsNetworkPath(path string) bool
- func IsSpecialPath(path string) bool
- func IsSubtitlesExt(ext string) bool
- func IsSymlink(fi os.FileInfo) bool
- func IsTimePassed(last time.Time, period time.Duration) bool
- func IsValidPath(path string) bool
- func IsWritablePath(path string) error
- func Max(a, b int) int
- func Min(a, b int) int
- func Move(src, dst string) (string, error)
- func NowInt() int
- func NowInt64() int64
- func NowPlusSecondsInt(seconds int) int
- func PathExists(path string) bool
- func RandomString(length int) string
- func SetTimeIntoFile(timeFile string) (time.Time, error)
- func StrInterfaceToInt(t interface{}) (i int)
- func StringSliceContains(ary []string, q string) bool
- func ToFileName(filename string) string
- func TrailerURL(u string) (ret string)
- func UTCBod() time.Time
- type AlreadyExistsError
- type CopyTreeOptions
- type Locker
- type NotADirectoryError
- type RateLimiter
- type SameFileError
- type SpecialFileError
- type Unlocker
Constants ¶
This section is empty.
Variables ¶
var ( ErrExceeded = errors.New("Rate-Limit Exceeded") ErrNotFound = errors.New("Not Found") )
ErrExceeded should be returned if we need to rerun the function
Functions ¶
func AirDateWithAiredCheck ¶
func AirDateWithAiredCheck(dt string, dateFormat string, allowSameDay bool) (airDate time.Time, isAired bool)
AirDateWithAiredCheck returns the aired date and flag if it was already aired
func ApplyColor ¶
ApplyColor applies a color to a text to use in Kodi skin
func Copy ¶
Copy data and mode bits ("cp src dst"). Return the file's destination.
The destination may be a directory.
If followSymlinks is false, symlinks won't be followed. This resembles GNU's "cp -P src dst".
If source and destination are the same file, a SameFileError will be raised.
func CopyFile ¶
CopyFile Copy data from src to dst
If followSymlinks is not set and src is a symbolic link, a new symlink will be created instead of copying the file it points to.
func CopyMode ¶
CopyMode bits from src to dst.
If followSymlinks is false, symlinks aren't followed if and only if both `src` and `dst` are symlinks. If `lchmod` isn't available and both are symlinks this does nothing. (I don't think lchmod is available in Go)
func DecodeFileURL ¶
DecodeFileURL decodes file path from url
func EffectiveDir ¶
EffectiveDir is checking argument path and returning closest folder.
func EncodeFileURL ¶
EncodeFileURL encode file path into proper url
func FileExists ¶
FileExists check for file existence in a simple way
func FileWithoutExtension ¶
FileWithoutExtension returns file without extension
func GetRealPath ¶
func HasAudioExt ¶
HasAudioExt searches different audio extensions in file name
func HasSubtitlesExt ¶
HasSubtitlesExt searches different subtitles extensions in file name
func IsAudioExt ¶
IsAudioExt checks if extension belong to Audio type
func IsNetworkPath ¶
func IsSpecialPath ¶
func IsSubtitlesExt ¶
IsSubtitlesExt checks if extension belong to Subtitles type
func IsValidPath ¶
func Move ¶
Move a file from src to dst
Simply tries os.Rename first in case the file is getting moved on the same disk, and uses Copy() otherwise.
Does not follow symlinks when copying.
func RandomString ¶
func StringSliceContains ¶
StringSliceContains ...
func TrailerURL ¶
TrailerURL returns trailer url, constructed for Kodi
Types ¶
type CopyTreeOptions ¶
type CopyTreeOptions struct { Symlinks bool IgnoreDanglingSymlinks bool CopyFunction func(string, string, bool) (string, error) Ignore func(string, []fs.DirEntry) []string }
CopyTreeOptions ...
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
Locker wraps a map of mutexes. Each key locks separately.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
A RateLimiter limits the rate at which an action can be performed. It applies neither smoothing (like one could achieve in a token bucket system) nor does it offer any conception of warmup, wherein the rate of actions granted are steadily increased until a steady throughput equilibrium is reached.
func NewRateLimiter ¶
func NewRateLimiter(limit int, interval time.Duration, parallelCount int) *RateLimiter
NewRateLimiter creates a new rate limiter for the limit and interval.
func (*RateLimiter) CoolDown ¶
func (r *RateLimiter) CoolDown(headers http.Header)
CoolDown is checking HTTP headers if we need to wait
func (*RateLimiter) Enter ¶
func (r *RateLimiter) Enter()
Enter blocks parallen channel for simultaneous connections limitation
func (*RateLimiter) ForceWait ¶
func (r *RateLimiter) ForceWait()
ForceWait is forcing rate limit if we have an external cause (like Response from API).
func (*RateLimiter) Try ¶
func (r *RateLimiter) Try() (ok bool, remaining time.Duration)
Try returns true if under the rate limit, or false if over and the remaining time before the rate limit expires.
func (*RateLimiter) Wait ¶
func (r *RateLimiter) Wait()
Wait blocks if the rate limit has been reached. Wait offers no guarantees of fairness for multiple actors if the allowed rate has been temporarily exhausted.
type SameFileError ¶
SameFileError ...
type SpecialFileError ¶
SpecialFileError ...