miaosic

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 8 Imported by: 0

README

Miaosic

Music Provider Repository, provide a universal interface for different music service.

Command line Tool

please check miaosic cmd tool

How to Use

please figure it out by yourself.

Available Providers

Provider Search Info Url Lyric Playlist loginable
netease ✓ * ✓ * ✓ * ✓ * ✓ *
kuwo
kugou ✓ *
bilibili-video
qq ✓* ✓* ✓* ✓* ✓*

* means require login

Known Problem

  1. Current implementation of source registration is not threading-safe, please implement thread-safe version by yourself in your project require multi-thread access (for example, web).

Disclaimer

All APIs used in this project are publicly available on the internet and not obtained through illegal means such as reverse engineering.

The use of this project may involve access to copyrighted content. This project does not own or claim any rights to such content. To avoid potential infringement, all users are required to delete any copyrighted data obtained through this project within 24 hours.

Any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses) that arise from the use or inability to use this project are solely the responsibility of the user.

This project is completely free and open-source, published on GitHub for global users for technical learning and research purposes only. This project does not guarantee compliance with local laws or regulations in all jurisdictions.

Using this project in violation of local laws is strictly prohibited. Any legal consequences arising from intentional or unintentional violations are the user's responsibility. The project maintainers accept no liability for such outcomes.

Documentation

Index

Constants

View Source
const VERSION = "0.2.6"

Variables

View Source
var (
	ErrorExternalApi          = errors.New("miaosic: external api error")
	ErrorNoSuchProvider       = errors.New("miaosic: no such provider")
	ErrorProviderNotLoginable = errors.New("miaosic: provider not loginable")
	ErrorDifferentProvider    = errors.New("miaosic: different provider")
	ErrorInvalidPageSetting   = errors.New("miaosic: invalid page setting")
	ErrorInvalidMediaMeta     = errors.New("miaosic: invalid media meta")
)
View Source
var ErrNotImplemented = errors.New("miaosic: not implemented")

Functions

func IsLoginByProvider added in v0.2.6

func IsLoginByProvider(provider string) (bool, error)

func ListAvailableProviders

func ListAvailableProviders() []string

func LoginByProvider added in v0.2.6

func LoginByProvider(provider, username, password string) error

func LogoutByProvider added in v0.2.6

func LogoutByProvider(provider string) error

func RefreshLoginByProvider added in v0.2.6

func RefreshLoginByProvider(provider string) error

func RegisterProvider

func RegisterProvider(provider MediaProvider)

func RestoreSessionByProvider added in v0.2.6

func RestoreSessionByProvider(provider, session string) error

func SaveSessionByProvider added in v0.2.6

func SaveSessionByProvider(provider string) (string, error)

func UnregisterAllProvider added in v0.2.5

func UnregisterAllProvider()

func UnregisterProvider added in v0.2.5

func UnregisterProvider(name string)

Types

type Loginable

type Loginable interface {
	Login(username string, password string) error
	Logout() error
	IsLogin() bool
	RefreshLogin() error
	QrLogin() (*QrLoginSession, error)
	QrLoginVerify(qrlogin *QrLoginSession) (*QrLoginResult, error)
	RestoreSession(session string) error
	SaveSession() string
}

type LyricContext added in v0.1.6

type LyricContext struct {
	Now   LyricLine   `json:"now"`
	Index int         `json:"index"`
	Total int         `json:"total"`
	Prev  []LyricLine `json:"prev"`
	Next  []LyricLine `json:"next"`
}

type LyricLine

type LyricLine struct {
	Time  float64 `json:"time"` // in seconds
	Lyric string  `json:"lyric"`
}

func (LyricLine) String

func (lr LyricLine) String() string

type Lyrics

type Lyrics struct {
	// Lang will is ISO 639-3 string
	Lang    string      `json:"lang"`
	Content []LyricLine `json:"content"`
}

func GetMediaLyric added in v0.1.6

func GetMediaLyric(meta MetaData) ([]Lyrics, error)

func ParseLyrics

func ParseLyrics(lang string, lyrics string) Lyrics

func (*Lyrics) Find

func (l *Lyrics) Find(time float64) LyricLine

func (*Lyrics) FindContext added in v0.1.6

func (l *Lyrics) FindContext(time float64, prev int, next int) *LyricContext

func (*Lyrics) FindIndex

func (l *Lyrics) FindIndex(time float64) int

func (*Lyrics) String

func (l *Lyrics) String() string

type MediaInfo

type MediaInfo struct {
	Title  string   `json:"title"`
	Artist string   `json:"artist"`
	Cover  Picture  `json:"cover"`
	Album  string   `json:"album"`
	Meta   MetaData `json:"meta"`
}

func GetMediaInfo added in v0.1.6

func GetMediaInfo(meta MetaData) (MediaInfo, error)

func SearchByProvider added in v0.1.6

func SearchByProvider(provider string, keyword string, page, size int) ([]MediaInfo, error)

type MediaProvider

type MediaProvider interface {
	// GetName returns the name of the provider.
	GetName() string
	Qualities() []Quality

	// Search returns a list of MetaData.
	Search(keyword string, page, size int) ([]MediaInfo, error)

	// MatchMedia returns a MetaData if the uri is matched, otherwise nil.
	MatchMedia(uri string) (MetaData, bool)
	GetMediaInfo(meta MetaData) (MediaInfo, error)
	GetMediaUrl(meta MetaData, quality Quality) ([]MediaUrl, error)
	GetMediaLyric(meta MetaData) ([]Lyrics, error)

	// MatchPlaylist returns a MetaData if the uri is matched, otherwise nil.
	MatchPlaylist(uri string) (MetaData, bool)
	// GetPlaylist returns a Playlist, it fetches all data, so it might be slow.
	GetPlaylist(meta MetaData) (*Playlist, error)
}

func GetProvider

func GetProvider(name string) (MediaProvider, bool)

type MediaUrl

type MediaUrl struct {
	Url     string            `json:"url"`
	Quality Quality           `json:"quality"`
	Header  map[string]string `json:"header"`
}

func GetMediaUrl added in v0.1.6

func GetMediaUrl(meta MetaData, quality Quality) ([]MediaUrl, error)

func NewMediaUrl

func NewMediaUrl(url string, quality Quality) MediaUrl

type MetaData added in v0.1.5

type MetaData struct {
	Provider   string `json:"provider"`
	Identifier string `json:"identifier"`
}

func MatchMedia added in v0.1.7

func MatchMedia(keyword string) (MetaData, bool)

func MatchMediaByProvider added in v0.1.7

func MatchMediaByProvider(provider string, uri string) (MetaData, bool)

func MatchPlaylistByProvider added in v0.1.6

func MatchPlaylistByProvider(provider string, uri string) (MetaData, bool)

func NewMetaData added in v0.1.5

func NewMetaData(provider, identifier string) MetaData

func (MetaData) ID added in v0.1.5

func (m MetaData) ID() string

type Picture

type Picture struct {
	Url  string `json:"url"`
	Data []byte `json:"data"`
}

func (Picture) Exists

func (p Picture) Exists() bool

type Playlist added in v0.1.5

type Playlist struct {
	Title  string      `json:"title"`
	Medias []MediaInfo `json:"medias"`
	Meta   MetaData    `json:"meta"`
}

func GetPlaylist added in v0.1.6

func GetPlaylist(meta MetaData) (*Playlist, error)

func (*Playlist) Copy added in v0.1.6

func (p *Playlist) Copy() Playlist

func (*Playlist) DisplayName added in v0.1.6

func (p *Playlist) DisplayName() string

type QrLoginResult added in v0.1.5

type QrLoginResult struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

func QrLoginVerifyByProvider added in v0.2.6

func QrLoginVerifyByProvider(provider string, qrlogin *QrLoginSession) (*QrLoginResult, error)

type QrLoginSession added in v0.1.5

type QrLoginSession struct {
	Url string `json:"url"`
	Key string `json:"key"`
}

func QrLoginByProvider added in v0.2.6

func QrLoginByProvider(provider string) (*QrLoginSession, error)

type Quality

type Quality string
const (
	QualityAny  Quality = ""
	QualityUnk  Quality = "unknown"
	Quality128k Quality = "128k"
	Quality192k Quality = "192k"
	Quality256k Quality = "256k"
	Quality320k Quality = "320k"
	QualityHQ   Quality = "hq"
	QualitySQ   Quality = "sq"
)

Directories

Path Synopsis
cmd
miaosic command
qq

Jump to

Keyboard shortcuts

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