modules

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOutputDirs

func CreateOutputDirs(outputDir, cacheDir string)

创建输出目录和缓存目录

func FetchCommentsForSongs

func FetchCommentsForSongs(songIDs []string, userID int, maxPages int, queriesPerSecond int) error

函数接受歌曲ID数组、用户ID、最大页数、并发线程数,并开始抓取评论

func SaveCache

func SaveCache(songID string, cacheDir string, cache CacheData, userID int) error

保存缓存数据

func ScrapePlaylist

func ScrapePlaylist(playlistIDs []int64) (map[int64][]int64, error)

根据歌单,所有歌曲id

Types

type CacheData

type CacheData struct {
	TotalPages int `json:"totalPages"`
	FinalPage  int `json:"finalPage"`
}

func LoadCache

func LoadCache(songID string, cacheDir string, userID int) (CacheData, error)

加载缓存数据

type Comment

type Comment struct {
	Username  string `json:"username"`
	Comment   string `json:"comment"`
	SongID    string `json:"song_id"`
	Location  string `json:"location"`
	Timestamp string `json:"time"`
}

type Config

type Config struct {
	TargetUserIDs        []int64       `json:"userId"`
	SearchMethod         string        `json:"searchMethod"`
	SearchOptions        SearchOptions `json:"searchOptions"`
	MaxPages             int           `json:"maxPages"`
	ConcurrentThreads    int           `json:"queriesPerSecond"`
	IgnoreCompletedTasks bool          `json:"ignoreCompletedTasks"`
}

配置的结构体

func LoadConfig

func LoadConfig(filename string) (*Config, error)

函数读取配置文件并返回 Config 实例

func (*Config) GetSearchOptionByMethod

func (c *Config) GetSearchOptionByMethod() interface{}

方法返回与搜索方法对应的搜索选项

type SearchOptions

type SearchOptions struct {
	PlaylistIDs   []int64 `json:"playlists"`
	TrackIDs      []int64 `json:"singles"`
	ListeningRank struct {
		RecentWeekAllTime int `json:"week/all"`
	} `json:"listening"`
}

搜索选项的结构体

Jump to

Keyboard shortcuts

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