utils

package
v0.0.0-...-c3a6988 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BaseProviders are the main anime providers
	BaseProviders = []string{
		baseV1Host,
		baseV2Host,
		baseV3Host,
		baseV4Host,
	}

	// FallbackStreams are fallback stream providers
	FallbackStreams = []string{
		fallback1Host,
		fallback2Host,
	}
)

Functions

func BadRequest

func BadRequest(c *fiber.Ctx, message string) error

BadRequest sends a 400 Bad Request response

func CleanHTML

func CleanHTML(raw string) string

CleanHTML takes the raw JSON-escaped HTML from the AJAX response and returns clean, proper HTML that goquery can parse.

func Contains

func Contains(slice []string, item string) bool

Contains checks if a string slice contains a string

func Created

func Created(c *fiber.Ctx, message string, data interface{}) error

Created sends a 201 Created response

func ErrorResponse

func ErrorResponse(c *fiber.Ctx, statusCode int, message string) error

ErrorResponse sends an error response

func ExtractDataID

func ExtractDataID(id string) string

ExtractDataID get the numeric id from the dataid

func Forbidden

func Forbidden(c *fiber.Ctx, message string) error

Forbidden sends a 403 Forbidden response

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration to a human-readable string

func FormatTime

func FormatTime(t time.Time) string

FormatTime formats a time to RFC3339 format

func FormatTimeString

func FormatTimeString(t time.Time) string

FormatTimeString formats a time string to RFC3339 format

func FormatTitle

func FormatTitle(title string, dataID string) string

func GenerateID

func GenerateID() string

GenerateID generates a random ID

func GenerateSlug

func GenerateSlug(s string) string

GenerateSlug generates a URL-friendly slug from a string

func GetAppStartTime

func GetAppStartTime() time.Time

func GetBaseProviders

func GetBaseProviders() []string

GetBaseProviders returns base providers

func GetFallback1Host

func GetFallback1Host() string

GetFallback1Host returns the primary fallback host

func GetFallback1URL

func GetFallback1URL() string

GetFallback1URL returns the primary fallback URL with https scheme

func GetFallback2Host

func GetFallback2Host() string

GetFallback2Host returns the secondary fallback host

func GetFallback2URL

func GetFallback2URL() string

GetFallback2URL returns the secondary fallback URL with https scheme

func GetFallbackStreams

func GetFallbackStreams() []string

GetFallbackStreams returns fallback stream providers

func GetStreamProvider

func GetStreamProvider() string

GetStreamProvider returns the main stream provider with https scheme

func GetStreamProviderHost

func GetStreamProviderHost() string

GetStreamProviderHost returns the raw stream provider host

func GetUptime

func GetUptime() time.Duration

func GetUptimeString

func GetUptimeString() string

func GetV1BaseHost

func GetV1BaseHost() string

GetV1BaseHost returns the v1 provider host

func GetV1BaseURL

func GetV1BaseURL() string

GetV1BaseURL returns the v1 provider URL with https scheme

func GetV2BaseHost

func GetV2BaseHost() string

GetV2BaseHost returns the v2 provider host

func GetV2BaseURL

func GetV2BaseURL() string

GetV2BaseURL returns the v2 provider URL with https scheme

func GetV3BaseHost

func GetV3BaseHost() string

GetV3BaseHost returns the v3 provider host

func GetV3BaseURL

func GetV3BaseURL() string

GetV3BaseURL returns the v3 provider URL with https scheme

func GetV4BaseHost

func GetV4BaseHost() string

GetV4BaseHost returns the v4 provider host

func GetV4BaseURL

func GetV4BaseURL() string

GetV4BaseURL returns the v4 provider URL with https scheme

func InternalServerError

func InternalServerError(c *fiber.Ctx, message string) error

InternalServerError sends a 500 Internal Server Error response

func IsValidFallbackStream

func IsValidFallbackStream(stream string) bool

IsValidFallbackStream checks if a fallback stream is valid

func IsValidProvider

func IsValidProvider(provider string) bool

IsValidProvider checks if a provider is valid

func NewCollector

func NewCollector() *colly.Collector

NewCollector returns a preconfigured colly Collector with sane defaults

func NotFound

func NotFound(c *fiber.Ctx, message string) error

NotFound sends a 404 Not Found response

func Now

func Now() time.Time

Now returns the current UTC time

func OK

func OK(c *fiber.Ctx, message string, data interface{}) error

OK sends a 200 OK response

func PaginatedResponse

func PaginatedResponse(c *fiber.Ctx, statusCode int, message string, data interface{}, meta interface{}) error

PaginatedResponse sends a paginated response

func ParseTime

func ParseTime(s string) (time.Time, error)

ParseTime parses a time string in RFC3339 format

func PointerToString

func PointerToString(s *string) string

PointerToString converts a string pointer to a string

func SetAppStartTime

func SetAppStartTime(t time.Time)

func StringToPointer

func StringToPointer(s string) *string

StringToPointer converts a string to a string pointer

func SuccessResponse

func SuccessResponse(c *fiber.Ctx, statusCode int, message string, data interface{}) error

SuccessResponse sends a success response

func TruncateString

func TruncateString(s string, maxLen int) string

TruncateString truncates a string to a maximum length

func Unauthorized

func Unauthorized(c *fiber.Ctx, message string) error

Unauthorized sends a 401 Unauthorized response

func Unique

func Unique(slice []string) []string

Unique removes duplicates from a string slice

func UnprocessableEntity

func UnprocessableEntity(c *fiber.Ctx, message string) error

UnprocessableEntity sends a 422 Unprocessable Entity response

Types

type Providers

type Providers struct {
	BaseProviders   []string
	FallbackStreams []string
	StreamProvider  string
	BaseV1          string
	BaseV2          string
	BaseV3          string
	BaseV4          string
	Fallback1       string
	Fallback2       string
}

Providers holds all provider information

func GetProviders

func GetProviders() Providers

GetProviders returns all provider information

type Response

type Response struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Meta    interface{} `json:"meta,omitempty"`
}

Response represents a standard API response

Jump to

Keyboard shortcuts

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