Documentation
¶
Overview ¶
Package model 的专辑实体映射与专辑详情解码。
Package model 的歌手实体映射与歌手详情解码。
Package model 的登录认证解码。
Package model 的主播电台(djradio)域解码。
第一阶段(issue #33)只做 endpoint 声明 + CLI 直连验证,响应是纯 Go 模型、 尚未 proto 建模(第二阶段替换);json tag 与上游字段同名,直接反序列化。 响应形状取自真实上游(见 endpoint/djradio/testdata 夹具,已裁剪)。
Package model 的 MV 解码。
上游现状(2026-10 实测):独立的 /mv/url 接口已下线(weapi / eapi 均业务 404), 多清晰度播放地址由 /mv/detail 的 brs 字段返回;MV 排行的现行接口是 /mv/toplist (老 /top/mv 已业务 404),其条目顶层 duration 恒为 0、发行日期在嵌套 mv 子对象上。
Package model 的歌单实体映射。
Package model 的每日推荐解码。
Package model 是网易云领域映射层。
每个领域实体定义「网易云原始 JSON 的 struct 镜像 + map 到 proto 的函数」, 写一次后全局复用。例如 MapSong 被歌曲详情、每日推荐、歌单曲目、专辑曲目、 搜索(单曲)等几十个接口复用。
这是「该复用的复用」的落点,把看似 357 次的映射塌缩为约 30 次领域映射 + 接口级组装。
Package model 的官方榜单解码。
Package model 的用户实体映射。
Package model 的用户详情解码。
Index ¶
- func DecodeAlbumDetail(raw json.RawMessage) (*mmpb.Album, []*mmpb.Song, error)
- func DecodeAlbumList(raw json.RawMessage) ([]*mmpb.Album, error)
- func DecodeAlbumListWithMore(raw json.RawMessage) ([]*mmpb.Album, bool, error)
- func DecodeAlbumListWithTotal(raw json.RawMessage) ([]*mmpb.Album, int32, error)
- func DecodeArtistInfo(raw json.RawMessage) (*mmpb.Artist, []*mmpb.Song, error)
- func DecodeDailyRecommend(raw json.RawMessage) ([]*mmpb.Song, error)
- func DecodeLoginResponse(raw json.RawMessage) (*mmpb.Session, error)
- func DecodeMvDetail(raw json.RawMessage) (*mmpb.Mv, error)
- func DecodeMvSummaries(raw json.RawMessage, listKey string) ([]*mmpb.Mv, bool, error)
- func DecodePersonalFM(raw json.RawMessage) ([]*mmpb.Song, error)
- func DecodeQrcodeKey(raw json.RawMessage) (string, error)
- func DecodeQrcodeStatus(raw json.RawMessage) (mmpb.QrcodeCode, string, error)
- func DecodeRecommendNewSongs(raw json.RawMessage) ([]*mmpb.Song, error)
- func DecodeRecommendPlaylists(raw json.RawMessage) ([]*mmpb.Playlist, error)
- func DecodeSongDetail(raw json.RawMessage) ([]*mmpb.Song, error)
- func DecodeTopMvs(raw json.RawMessage) ([]*mmpb.Mv, bool, int64, error)
- func DecodeToplists(raw json.RawMessage) ([]*mmpb.Toplist, error)
- func DecodeUserDetail(raw json.RawMessage) (*mmpb.UserDetail, error)
- func DecodeUserSubCount(raw json.RawMessage) (*mmpb.UserSubCount, error)
- func DecodeWordLyric(blob string) (*mmpb.WordLyric, error)
- func MapAlbum(a rawAlbum) *mmpb.Album
- func MapAlbums(in []rawAlbum) []*mmpb.Album
- func MapArtist(a rawArtist) *mmpb.Artist
- func MapArtists(in []rawArtist) []*mmpb.Artist
- func MapPlaylist(raw json.RawMessage) (*mmpb.Playlist, error)
- func MapSong(s rawSong) *mmpb.Song
- func MapSongs(in []rawSong) []*mmpb.Song
- func MapUser(u rawUser) *mmpb.User
- type DjAnchor
- type DjCategory
- type DjCategoryList
- type DjProgram
- type DjProgramPage
- type DjRadio
- type DjSubscribedPage
- type PlaylistTrackIDs
- type UserPlaylistPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeAlbumDetail ¶
DecodeAlbumDetail 解析专辑详情响应的原始 JSON。
func DecodeAlbumList ¶
func DecodeAlbumList(raw json.RawMessage) ([]*mmpb.Album, error)
DecodeAlbumList 解析专辑列表响应,只取专辑数组(最新专辑等不带分页的接口用)。
func DecodeAlbumListWithMore ¶
DecodeAlbumListWithMore 解析带 more 标记的专辑列表响应(新碟上架用)。
func DecodeAlbumListWithTotal ¶
DecodeAlbumListWithTotal 解析带 total 的专辑列表响应(全部新碟/收藏列表用)。
func DecodeArtistInfo ¶
DecodeArtistInfo 解析歌手详情响应的原始 JSON。
func DecodeDailyRecommend ¶
func DecodeDailyRecommend(raw json.RawMessage) ([]*mmpb.Song, error)
DecodeDailyRecommend 解析每日推荐响应的原始 JSON。
func DecodeLoginResponse ¶
func DecodeLoginResponse(raw json.RawMessage) (*mmpb.Session, error)
DecodeLoginResponse 解析登录响应,提取用户信息(不含 cookie,cookie 由 service 层从 Set-Cookie 取)。
func DecodeMvDetail ¶ added in v0.6.0
func DecodeMvDetail(raw json.RawMessage) (*mmpb.Mv, error)
DecodeMvDetail 解析 MV 详情响应(/mv/detail),含多清晰度播放地址(brs)。
func DecodeMvSummaries ¶ added in v0.6.0
DecodeMvSummaries 解析 MV 摘要列表响应(listKey 为列表字段名: /simi/mv 是 "mvs",/mv/sublist 是 "data"),并回传 hasMore。
func DecodePersonalFM ¶
func DecodePersonalFM(raw json.RawMessage) ([]*mmpb.Song, error)
DecodePersonalFM 解析私人 FM 响应的原始 JSON。
func DecodeQrcodeKey ¶
func DecodeQrcodeKey(raw json.RawMessage) (string, error)
DecodeQrcodeKey 解析二维码 key 获取响应。
func DecodeQrcodeStatus ¶
func DecodeQrcodeStatus(raw json.RawMessage) (mmpb.QrcodeCode, string, error)
DecodeQrcodeStatus 解析二维码轮询响应。
func DecodeRecommendNewSongs ¶
func DecodeRecommendNewSongs(raw json.RawMessage) ([]*mmpb.Song, error)
DecodeRecommendNewSongs 解析推荐新音乐响应(歌曲嵌在 result[i].song 下,字段用全名)。
func DecodeRecommendPlaylists ¶
func DecodeRecommendPlaylists(raw json.RawMessage) ([]*mmpb.Playlist, error)
DecodeRecommendPlaylists 解析推荐歌单列表响应(兼容 recommend/result 两种字段名)。
func DecodeSongDetail ¶
func DecodeSongDetail(raw json.RawMessage) ([]*mmpb.Song, error)
DecodeSongDetail 解析歌曲详情响应的原始 JSON。
func DecodeTopMvs ¶ added in v0.6.0
DecodeTopMvs 解析 MV 排行榜响应(/mv/toplist)。
func DecodeToplists ¶ added in v0.6.0
func DecodeToplists(raw json.RawMessage) ([]*mmpb.Toplist, error)
DecodeToplists 解析榜单列表响应(/toplist 与 /toplist/detail 共用)。
func DecodeUserDetail ¶
func DecodeUserDetail(raw json.RawMessage) (*mmpb.UserDetail, error)
DecodeUserDetail 解析用户详情响应。
func DecodeUserSubCount ¶
func DecodeUserSubCount(raw json.RawMessage) (*mmpb.UserSubCount, error)
DecodeUserSubCount 解析用户数量统计响应。
func DecodeWordLyric ¶
DecodeWordLyric 把网易云逐字歌词文本(yrc)解析成结构化 WordLyric。
yrc 格式:每行 `[lineStartMs,lineDurMs](wordStartMs,wordDurMs,0)字(...)...` - 行头方括号标注行级时间戳 - 每字圆括号三元组 (startMs,durMs,0),第三字段为固定标记 - 字内间隙/标点可能 dur=0 blob 为空时返回空 WordLyric(无逐字歌词),不报错。
func MapArtists ¶
MapArtists 把网易云原始歌手数组转成 proto Artist 列表。
func MapPlaylist ¶
func MapPlaylist(raw json.RawMessage) (*mmpb.Playlist, error)
MapPlaylist 把网易云原始歌单结构转成 proto Playlist。
Types ¶
type DjAnchor ¶ added in v0.6.0
type DjAnchor struct {
UserID int64 `json:"userId"` // 用户ID
Nickname string `json:"nickname"` // 昵称
AvatarURL string `json:"avatarUrl"` // 头像URL
}
DjAnchor 主播的公开身份摘要(节目与电台共用的 dj 字段)。
type DjCategory ¶ added in v0.6.0
type DjCategory struct {
ID int64 `json:"id"` // 分类ID
Name string `json:"name"` // 分类名(如「情感」「有声书」)
}
DjCategory 电台分类。
type DjCategoryList ¶ added in v0.6.0
type DjCategoryList struct {
Categories []*DjCategory `json:"categories"` // 分类列表(真实上游是数组,非旧文档的带 sub 对象)
}
DjCategoryList 电台分类列表响应。
func DecodeDjCategories ¶ added in v0.6.0
func DecodeDjCategories(raw json.RawMessage) (*DjCategoryList, error)
DecodeDjCategories 解析电台分类列表(/weapi/djradio/category/get)。
type DjProgram ¶ added in v0.6.0
type DjProgram struct {
ID int64 `json:"id"` // 节目ID
Name string `json:"name"` // 节目名
CoverURL string `json:"coverUrl"` // 封面URL
Description string `json:"description"` // 节目描述
DurationMs int64 `json:"duration"` // 时长(毫秒)
SerialNum int64 `json:"serialNum"` // 期数
CreateTimeMs int64 `json:"createTime"` // 上架时间(毫秒时间戳)
ListenerCount int64 `json:"listenerCount"` // 播放数
LikedCount int64 `json:"likedCount"` // 点赞数
CommentCount int64 `json:"commentCount"` // 评论数
MainTrackID int64 `json:"mainTrackId"` // 关联歌曲ID(取播放链接用)
Radio *DjRadio `json:"radio"` // 所属电台
Anchor *DjAnchor `json:"dj"` // 主播
}
DjProgram 电台节目。
func DecodeDjProgramDetail ¶ added in v0.6.0
func DecodeDjProgramDetail(raw json.RawMessage) (*DjProgram, error)
DecodeDjProgramDetail 解析节目详情(/weapi/dj/program/detail,顶层 program)。
type DjProgramPage ¶ added in v0.6.0
type DjProgramPage struct {
Programs []*DjProgram `json:"programs"` // 本页节目
Count int64 `json:"count"` // 上游总数
More bool `json:"more"` // 是否还有下一页
}
DjProgramPage 电台节目列表的一页。
func DecodeDjPrograms ¶ added in v0.6.0
func DecodeDjPrograms(raw json.RawMessage) (*DjProgramPage, error)
DecodeDjPrograms 解析电台节目列表的一页(/weapi/dj/program/byradio)。
type DjRadio ¶ added in v0.6.0
type DjRadio struct {
ID int64 `json:"id"` // 电台ID
Name string `json:"name"` // 电台名
PicURL string `json:"picUrl"` // 封面URL
Desc string `json:"desc"` // 简介
Category string `json:"category"` // 一级分类名
SecondCategory string `json:"secondCategory"` // 二级分类名
SubCount int64 `json:"subCount"` // 订阅数
ProgramCount int64 `json:"programCount"` // 节目数
PlayCount int64 `json:"playCount"` // 播放数
Subed bool `json:"subed"` // 当前用户是否已订阅
Anchor *DjAnchor `json:"dj"` // 主播
}
DjRadio 电台摘要(订阅列表的条目、节目内嵌的 radio 同一形状)。
type DjSubscribedPage ¶ added in v0.6.0
type DjSubscribedPage struct {
DjRadios []*DjRadio `json:"djRadios"` // 本页电台
Count int64 `json:"count"` // 上游总数(匿名调用时上游不给该字段)
More bool `json:"more"` // 是否还有下一页
}
DjSubscribedPage 订阅电台列表的一页(需登录态)。
func DecodeDjSubscribed ¶ added in v0.6.0
func DecodeDjSubscribed(raw json.RawMessage) (*DjSubscribedPage, error)
DecodeDjSubscribed 解析订阅电台列表的一页(/weapi/djradio/get/subed,需登录态)。
type PlaylistTrackIDs ¶ added in v0.4.2
type PlaylistTrackIDs struct {
IDs []int64
}
PlaylistTrackIDs 是歌单的完整曲目 ID 列表(歌单原顺序)。
func DecodePlaylistTrackIDs ¶ added in v0.4.2
func DecodePlaylistTrackIDs(raw json.RawMessage) (*PlaylistTrackIDs, error)
DecodePlaylistTrackIDs 取歌单详情里完整的 trackIds。
详情内嵌的 tracks 会被上游截断(实测匿名请求时 71 首的歌单只返回 10 首、3672 首的只返回 6 首), 只有 trackIds 是完整的;按页取歌曲要用它切片,而不是对 tracks 切片。
type UserPlaylistPage ¶ added in v0.4.2
type UserPlaylistPage struct {
// Playlists 按上游顺序。第一页会在 limit 之外额外带上「喜欢的音乐」。
Playlists []*mmpb.Playlist
// More 表示上游还有下一页。上游不返回总数。
More bool
}
UserPlaylistPage 是上游用户歌单接口的一页原始结果(未筛选)。
func DecodeUserPlaylistPage ¶ added in v0.4.2
func DecodeUserPlaylistPage(raw json.RawMessage) (*UserPlaylistPage, error)
DecodeUserPlaylistPage 解析用户歌单接口的一页。筛选与分页在 compose.UserPlaylists 里做: 上游的分页既不返回总数、第一页又多一条,只有拿到全量后才能给出准确的 total。