utils

package
v0.0.0-...-87db3fa Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResizeParamForPicUrl

func AddResizeParamForPicUrl(picurl string, size int64) string

func BinToID

func BinToID(bin []byte) uint64

BinToID convert []byte to autoincrement ID

func CacheMusic

func CacheMusic(song structs.Song, url string, musicType string, quality service.SongQualityLevel)

func CheckUpdate

func CheckUpdate() (bool, string)

CheckUpdate 检查更新

func ClearDir

func ClearDir(dir string) error

func ClearMusicCache

func ClearMusicCache() error

func CompareVersion

func CompareVersion(v1, v2 string, equal bool) bool

func CopyCachedSong

func CopyCachedSong(song structs.Song) error

func CopyClose

func CopyClose(ctx context.Context, dst io.Writer, src io.ReadCloser) (int64, error)

CopyClose 可中断的流复制

func CopyDirFromEmbed

func CopyDirFromEmbed(src, dst string) error

func CopyFileFromEmbed

func CopyFileFromEmbed(src, dst string) error

func DownloadFile

func DownloadFile(url, filename, dirname string) error

func DownloadMusic

func DownloadMusic(song structs.Song)

DownloadMusic 下载音乐

func FileOrDirExists

func FileOrDirExists(filename string) bool

func FileUrl

func FileUrl(filepath string) string

func GenQRCode

func GenQRCode(filename, content string) (string, error)

func GetAlbumsOfSearchResult

func GetAlbumsOfSearchResult(data []byte) (list []structs.Album)

GetAlbumsOfSearchResult 获取搜索结果的专辑

func GetArtistHotAlbums

func GetArtistHotAlbums(data []byte) (albums []structs.Album)

GetArtistHotAlbums 获取歌手热门专辑列表

func GetArtistsOfSearchResult

func GetArtistsOfSearchResult(data []byte) (list []structs.Artist)

GetArtistsOfSearchResult 获取搜索结果的歌手

func GetArtistsOfTopArtists

func GetArtistsOfTopArtists(data []byte) (list []structs.Artist)

GetArtistsOfTopArtists 获取热门歌手

func GetCacheDir

func GetCacheDir() string

func GetCacheUrl

func GetCacheUrl(songId int64) (url, musicType string, ok bool)

func GetDailyPlaylists

func GetDailyPlaylists(data []byte) (list []structs.Playlist)

GetDailyPlaylists 获取每日推荐歌单

func GetDailySongs

func GetDailySongs(data []byte) (list []structs.Song)

GetDailySongs 获取每日歌曲列表

func GetDjCategory

func GetDjCategory(data []byte) (list []structs.DjCategory)

GetDjCategory 获取电台分类

func GetDjRadios

func GetDjRadios(data []byte) (list []structs.DjRadio)

GetDjRadios 获取电台列表

func GetDjRadiosOfSearchResult

func GetDjRadiosOfSearchResult(data []byte) (list []structs.DjRadio)

GetDjRadiosOfSearchResult 从搜索结果中获取电台列表

func GetDjRadiosOfToday

func GetDjRadiosOfToday(data []byte) (list []structs.DjRadio)

GetDjRadiosOfToday 获取今日优选电台列表

func GetDjRadiosOfTopDj

func GetDjRadiosOfTopDj(data []byte) (list []structs.DjRadio)

GetDjRadiosOfTopDj 获取热门电台列表

func GetDownloadDir

func GetDownloadDir() string

func GetFmSongs

func GetFmSongs(data []byte) (list []structs.Song)

GetFmSongs 获取每日歌曲列表

func GetIntelligenceSongs

func GetIntelligenceSongs(data []byte) (list []structs.Song)

GetIntelligenceSongs 获取心动模式歌曲列表

func GetLocalDataDir

func GetLocalDataDir() string

GetLocalDataDir 获取本地数据存储目录

func GetNewAlbums

func GetNewAlbums(data []byte) (albums []structs.Album)

GetNewAlbums 获取最新专辑列表

func GetPlaylists

func GetPlaylists(data []byte) (list []structs.Playlist)

GetPlaylists 获取播放列表

func GetPlaylistsFromHighQuality

func GetPlaylistsFromHighQuality(data []byte) (list []structs.Playlist)

GetPlaylistsFromHighQuality 获取精品歌单

func GetPlaylistsOfSearchResult

func GetPlaylistsOfSearchResult(data []byte) (list []structs.Playlist)

GetPlaylistsOfSearchResult 获取搜索结果的歌单

func GetRanks

func GetRanks(data []byte) (list []structs.Rank)

GetRanks 获取排行榜

func GetRecentSongs

func GetRecentSongs(data []byte) (list []structs.Song)

GetRecentSongs 获取每日歌曲列表

func GetSongUrl

func GetSongUrl(song structs.Song) (url, musicType string, err error)

func GetSongsOfAlbum

func GetSongsOfAlbum(data []byte) (list []structs.Song)

GetSongsOfAlbum 获取专辑的歌曲

func GetSongsOfArtist

func GetSongsOfArtist(data []byte) (list []structs.Song)

GetSongsOfArtist 获取歌手的歌曲

func GetSongsOfCloud

func GetSongsOfCloud(data []byte) (list []structs.Song)

GetSongsOfCloud 获取云盘的歌曲

func GetSongsOfDjHoursRank

func GetSongsOfDjHoursRank(data []byte) (list []structs.Song)

GetSongsOfDjHoursRank 获取电台节目24小时排行榜列表的歌曲

func GetSongsOfDjRadio

func GetSongsOfDjRadio(data []byte) (list []structs.Song)

GetSongsOfDjRadio 获取电台节目列表的歌曲

func GetSongsOfDjRank

func GetSongsOfDjRank(data []byte) (list []structs.Song)

GetSongsOfDjRank 获取电台节目排行榜列表的歌曲

func GetSongsOfPlaylist

func GetSongsOfPlaylist(data []byte) (list []structs.Song)

GetSongsOfPlaylist 获取播放列表的歌曲

func GetSongsOfSearchResult

func GetSongsOfSearchResult(data []byte) (list []structs.Song)

GetSongsOfSearchResult 获取搜索结果的歌曲

func GetTopAlbums

func GetTopAlbums(data []byte) (albums []structs.Album)

GetTopAlbums 获取专辑列表

func GetUsersOfSearchResult

func GetUsersOfSearchResult(data []byte) (list []structs.User)

GetUsersOfSearchResult 从搜索结果中获取用户列表

func GetViewFromAlbums

func GetViewFromAlbums(albums []ds.Album) []model.MenuItem

GetViewFromAlbums 从歌曲列表获取View

func GetViewFromArtists

func GetViewFromArtists(artists []ds.Artist) []model.MenuItem

GetViewFromArtists 从歌手列表获取View

func GetViewFromDjCate

func GetViewFromDjCate(categories []ds.DjCategory) []model.MenuItem

GetViewFromDjCate 分类列表获取View

func GetViewFromDjRadios

func GetViewFromDjRadios(radios []ds.DjRadio) []model.MenuItem

GetViewFromDjRadios DjRadio列表获取View

func GetViewFromPlaylists

func GetViewFromPlaylists(playlists []ds.Playlist) []model.MenuItem

GetViewFromPlaylists 从歌单列表获取View

func GetViewFromSongs

func GetViewFromSongs(songs []ds.Song) []model.MenuItem

GetViewFromSongs 从歌曲列表获取View

func GetViewFromUsers

func GetViewFromUsers(users []ds.User) []model.MenuItem

GetViewFromUsers 用户列表获取View

func IDToBin

func IDToBin(ID uint64) []byte

IDToBin convert autoincrement ID to []byte

func IsSameDate

func IsSameDate(t1, t2 time.Time) bool

func LoadIniConfig

func LoadIniConfig()

LoadIniConfig 加载ini配置信息

func LogWriter

func LogWriter() io.Writer

func Logger

func Logger() *log.Logger

func Max

func Max[T ordinal](a, b T) T

func Min

func Min[T ordinal](a, b T) T

func Must

func Must(err error)

func Must1

func Must1[T any](a T, err error) T

func Must2

func Must2[T, S any](a T, b S, err error) (T, S)

func Notify

func Notify(content NotifyContent)

func PanicRecoverWrapper

func PanicRecoverWrapper(ignorePanic bool, f func())

func Recover

func Recover(ignore bool) (hasCaught bool)

func ReplaceSpecialStr

func ReplaceSpecialStr(str string) string

ReplaceSpecialStr 替换特殊字符

func ReportSongEnd

func ReportSongEnd(songID int64, sourceID int64, passedTime time.Duration)

播放结束上报网易云

func ResetError

func ResetError(i interface{})

func SetLogger

func SetLogger(l *log.Logger)

func SetSongTag

func SetSongTag(file *os.File, song structs.Song)

func WaitForNBytes

func WaitForNBytes(r io.ReadSeeker, N int, interval time.Duration, retryTime int) (err error)

WaitForNBytes 等待r中满足N个byte

func WebUrlOfAlbum

func WebUrlOfAlbum(artistId int64) string

func WebUrlOfArtist

func WebUrlOfArtist(artistId int64) string

func WebUrlOfPlaylist

func WebUrlOfPlaylist(playlistId int64) string

func WebUrlOfSong

func WebUrlOfSong(songId int64) string

Types

type FileExistsError

type FileExistsError struct {
	// contains filtered or unexported fields
}

func (FileExistsError) Error

func (e FileExistsError) Error() string

type Notificator

type Notificator struct {
	*notificator.Notificator
	// contains filtered or unexported fields
}

func NewNotificator

func NewNotificator(o notificator.Options) *Notificator

func (Notificator) Push

func (n Notificator) Push(urgency, title, text, iconPath, redirectUrl, groupId string) error

type NotifyContent

type NotifyContent struct {
	Title   string
	Text    string
	Url     string
	Icon    string
	GroupId string
}

type Options

type Options struct {
	Duration       time.Duration
	Passed         time.Duration
	TickerInternal time.Duration
	OnPaused       func()
	OnDone         func(stopped bool)
	OnTick         func()
	OnRun          func(started bool)
}

Options represents configuration for timer.

type QNode

type QNode struct {
	// contains filtered or unexported fields
}

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func (*Queue) Dequeue

func (q *Queue) Dequeue() interface{}

func (*Queue) Enqueue

func (q *Queue) Enqueue(value interface{})

func (*Queue) Len

func (q *Queue) Len() int

func (*Queue) Peek

func (q *Queue) Peek() interface{}

type ResCode

type ResCode uint8
const (
	Success ResCode = iota
	UnknownError
	NetworkError
	NeedLogin
	PasswordError
)

func CheckCode

func CheckCode(code float64) ResCode

CheckCode 验证响应码

func CheckUserInfo

func CheckUserInfo(user *structs.User) ResCode

CheckUserInfo 验证用户信息

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer represents timer with pause/resume features.

func NewTimer

func NewTimer(options Options) *Timer

NewTimer creates instance of timer.

func (*Timer) Passed

func (t *Timer) Passed() time.Duration

Passed returns how much done is already passed.

func (*Timer) Pause

func (t *Timer) Pause()

Pause temporarily pauses active timer.

func (*Timer) Remaining

func (t *Timer) Remaining() time.Duration

Remaining returns how much time is left to end.

func (*Timer) Run

func (t *Timer) Run()

Run starts just created timer and resumes paused.

func (*Timer) SetPassed

func (t *Timer) SetPassed(passed time.Duration)

SetPassed update passed.

func (*Timer) Stop

func (t *Timer) Stop()

Stop finishes the timer.

type XScrollBar

type XScrollBar struct {
	// contains filtered or unexported fields
}

func NewXScrollBar

func NewXScrollBar() *XScrollBar

func (*XScrollBar) Tick

func (b *XScrollBar) Tick(width int, content string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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