utils

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigENV = "ENV_MEDIA_GET"
View Source
const ConfigFile = ".media-get.json"
View Source
const HttpRetryCnt = 3
View Source
const TcpConnectTimeout = 1500 * time.Millisecond
View Source
const TimeOut = 3 * time.Second

Variables

This section is empty.

Functions

func ConvertString2Int

func ConvertString2Int(numberStr string, fallback int) int

func DownloadBinaryWithTCP added in v0.2.6

func DownloadBinaryWithTCP(inputUrl string, downloadTo string, headers map[string]string) error

func DurationStr2Second

func DurationStr2Second(durationStr string) int

func ExecCmd added in v0.2.13

func ExecCmd(program string, arg ...string) (string, error)

func FilterUnexpectedChar added in v0.2.5

func FilterUnexpectedChar(path string) string

func GenReqID added in v0.1.3

func GenReqID() string

func GetCookie added in v0.2.0

func GetCookie(source, url string, headers map[string]string, isHead bool) (string, error)

func GetCurrentDir

func GetCurrentDir() (string, error)

func GetExtFromUrl

func GetExtFromUrl(url string) string

func GetLocation

func GetLocation(source, url string, headers map[string]string) (string, error)

func HttpGet

func HttpGet(source, url string, headers map[string]string) (string, error)

func HttpHead added in v0.2.11

func HttpHead(source, url string, headers map[string]string) error

func InArray added in v0.2.0

func InArray(array []string, value string) bool

func InitConfig added in v0.2.9

func InitConfig()

func Md5

func Md5(str string) string

func ModifyFileExt

func ModifyFileExt(filename, newExt string) string

func PostForm

func PostForm(source, url string, data, headers map[string]string) (string, error)

func RegexSingleMatch

func RegexSingleMatch(input string, expression string) (string, error)

func RegexSingleMatchIgnoreError

func RegexSingleMatchIgnoreError(input string, expression string, fallback string) string

func RegexSingleMatchIntIgnoreError

func RegexSingleMatchIntIgnoreError(input string, expression string, fallback int) int

func RemoveBracketsFromString added in v0.2.0

func RemoveBracketsFromString(str string) string

func RemoveTagFromString added in v0.2.0

func RemoveTagFromString(str string) string

func SimilarText added in v0.2.0

func SimilarText(str1, str2 string) float64

func Unzip

func Unzip(zipFile, outputPath string) bool

func WgetBinary added in v0.1.3

func WgetBinary(url string, downloadTo string, headers map[string]string) error

Types

type MediaGetConfig added in v0.2.9

type MediaGetConfig struct {
	Proxy map[string]string `json:"proxy"`
}

func GetConfig added in v0.2.9

func GetConfig() *MediaGetConfig

type TCPProgressReader added in v0.2.8

type TCPProgressReader struct {
	net.Conn
	Init    bool
	Current int64
	Total   int64
}

func (*TCPProgressReader) Read added in v0.2.8

func (r *TCPProgressReader) Read(p []byte) (n int, err error)

type WgetBinaryProgressReader added in v0.2.8

type WgetBinaryProgressReader struct {
	io.Reader
	Total   int64
	Current int64
}

func (*WgetBinaryProgressReader) Read added in v0.2.8

func (r *WgetBinaryProgressReader) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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