utils

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BasePath string = "./downloads" // Base path for downloads

set the default path to where the video or audio will be downloaded

View Source
var ErrUnsupportedFileFormat = errors.New("unsupported file format")
View Source
var OutputName string = "youtube" // Default output name

Functions

func ConvertFileToMP3

func ConvertFileToMP3(inputFilePath string) (string, error)

ConvertFileToMP3 converts the given input filepath to MP3 format.

func ConvertReaderToMP3

func ConvertReaderToMP3(reader io.Reader, outputDir string) (string, error)

ConvertReaderToMP3 reads a video from an io.Reader and converts it to MP3.

func CreateUniqueFolder

func CreateUniqueFolder(basePath string) (string, error)

CreateUniqueFolder creates a new folder with a unique name within the specified base path

func DeleteFolder

func DeleteFolder(path string) error

DeleteFolder removes the specified folder and all its contents

func DownloadFileURL

func DownloadFileURL(url, dest string) (string, error)

DownloadFileURL downloads a file from the given URL and saves it to the specified path.

func HandleFileUpload

func HandleFileUpload(ctx context.Context, file interface{}, cloudinaryURL string) (string, error)

HandleFileUpload is a function that handles file uploads to Cloudinary. It uploads the file to Cloudinary and returns the Direct URL of the uploaded file.

If any error occurs during the process, the function returns an empty string and the error.

func HandleReadiness

func HandleReadiness() http.HandlerFunc

func LoadEnv

func LoadEnv(path string) (string, string, string, string, string, string, error)

this function loads the environment variables from the path

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to the given value.

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, errmessage string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

func SetBoolValue

func SetBoolValue(value string, param **bool)

SetBoolValue sets the value of the bool pointer if the given string is a valid boolean.

func SetFloatValue

func SetFloatValue(value string, param **float64)

SetFloatValue sets the value of the float64 pointer if the given string is a valid float.

func SetIntValue

func SetIntValue(value string, param **int)

SetIntValue sets the value of the int pointer if the given string is a valid integer.

func SetStringValue

func SetStringValue(value string, param **string)

SetStringValue sets the value of the string pointer if the given string is not empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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