pub struct NcmApi { /* private fields */ }
Expand description
API wrapper.
Implementations
sourceimpl NcmApi
impl NcmApi
apis
sourcepub async fn search(
&self,
key: &str,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn search(
&self,
key: &str,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入搜索关键词可以搜索该音乐 / 专辑 / 歌手 / 歌单 / 用户 , 关键词可以多个 , 以空格隔开 , 如 “ 周杰伦 搁浅 “( 不需要登录 ), 搜索获取的 mp3url 不能直接用 , 可通过 /song/url 接口传入歌曲 id 获取具体的播放链接
required 必选参数 : key: 关键词
optional 可选参数 : limit : 返回数量 , 默认为 30 offset : 偏移数量,用于分页 , 如 : 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0 type: 搜索类型;默认为 1 即单曲 , 取值意义 : 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频, 1018:综合
sourcepub async fn album_sub(&self, id: usize, op: u8) -> Result<ApiResponse, ApiErr>
pub async fn album_sub(&self, id: usize, op: u8) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可收藏/取消收藏专辑 required id : 专辑 id t : 1 为收藏,其他为取消收藏
sourcepub async fn album_sublist(
&self,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn album_sublist(
&self,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 可获得已收藏专辑列表 optional limit: 取出数量 , 默认为 25 offset: 偏移数量 , 用于分页 , 如 :( 页数 -1)*25, 其中 25 为 limit 的值 , 默认 为 0
sourcepub async fn album(&self, id: usize) -> Result<ApiResponse, ApiErr>
pub async fn album(&self, id: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入专辑 id, 可获得专辑内容 required 必选参数 : id: 专辑 id
sourcepub async fn artist_songs(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn artist_songs(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可获取歌手全部歌曲 必选参数 : required id : 歌手 id optional: order : hot ,time 按照热门或者时间排序 limit: 取出歌单数量 , 默认为 50 offset: 偏移数量 , 用于分页 , 如 :( 评论页数 -1)*50, 其中 50 为 limit 的值
sourcepub async fn artist_sub(&self, id: usize, sub: u8) -> Result<ApiResponse, ApiErr>
pub async fn artist_sub(&self, id: usize, sub: u8) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可收藏歌手 required id : 歌手 id t:操作,1 为收藏,其他为取消收藏
sourcepub async fn artist_sublist(
&self,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn artist_sublist(
&self,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可获取收藏的歌手列表
sourcepub async fn artist_top_song(&self, id: usize) -> Result<ApiResponse, ApiErr>
pub async fn artist_top_song(&self, id: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可获取歌手热门50首歌曲 required id : 歌手 id
sourcepub async fn check_music(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn check_music(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明: 调用此接口,传入歌曲 id, 可获取音乐是否可用,返回 { success: true, message: ‘ok’ } 或者 { success: false, message: ‘亲爱的,暂无版权’ } requried 必选参数 : id : 歌曲 id optional 可选参数 : br: 码率,默认设置了 999000 即最大码率,如果要 320k 则可设置为 320000,其他类推
sourcepub async fn comment_hot(
&self,
id: usize,
resouce_type: ResourceType,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn comment_hot(
&self,
id: usize,
resouce_type: ResourceType,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入 type, 资源 id 可获得对应资源热门评论 ( 不需要登录 ) required id : 资源 id type: 数字 , 资源类型
optional 可选参数 : limit: 取出评论数量 , 默认为 20 offset: 偏移数量 , 用于分页 , 如 :( 评论页数 -1)*20, 其中 20 为 limit 的值 before: 分页参数,取上一页最后一项的 time 获取下一页数据(获取超过5000条评论的时候需要用到)
sourcepub async fn comment(
&self,
id: usize,
resource_type: ResourceType,
page_size: usize,
page_no: usize,
sort_type: usize,
cursor: usize,
show_inner: bool
) -> Result<ApiResponse, ApiErr>
pub async fn comment(
&self,
id: usize,
resource_type: ResourceType,
page_size: usize,
page_no: usize,
sort_type: usize,
cursor: usize,
show_inner: bool
) -> Result<ApiResponse, ApiErr>
新版评论接口 说明 : 调用此接口 , 传入资源类型和资源id,以及排序方式,可获取对应资源的评论
required id : 资源 id, 如歌曲 id,mv id type: 数字 , 资源类型 , 对应歌曲 , mv, 专辑 , 歌单 , 电台, 视频对应以下类型
optional pageNo:分页参数,第N页,默认为1 pageSize:分页参数,每页多少条数据,默认20 sortType: 排序方式,1:按推荐排序,2:按热度排序,3:按时间排序 cursor: 当sortType为3时且页数不是第一页时需传入,值为上一条数据的time
sourcepub async fn comment_create(
&self,
rid: usize,
rt: ResourceType,
cmt: &str
) -> Result<ApiResponse, ApiErr>
pub async fn comment_create(
&self,
rid: usize,
rt: ResourceType,
cmt: &str
) -> Result<ApiResponse, ApiErr>
required rid: resource id rt: resource type cmt: comment body
sourcepub async fn comment_re(
&self,
rid: usize,
rt: ResourceType,
re_id: usize,
cmt: &str
) -> Result<ApiResponse, ApiErr>
pub async fn comment_re(
&self,
rid: usize,
rt: ResourceType,
re_id: usize,
cmt: &str
) -> Result<ApiResponse, ApiErr>
required rid: resource id rt: resource type reid: the comment id of reply to cmt: comment body
sourcepub async fn comment_del(
&self,
rid: usize,
rt: ResourceType,
cmt_id: usize
) -> Result<ApiResponse, ApiErr>
pub async fn comment_del(
&self,
rid: usize,
rt: ResourceType,
cmt_id: usize
) -> Result<ApiResponse, ApiErr>
required rid: resource id rt: resource type cmtid: comment id
sourcepub async fn daily_signin(
&self,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn daily_signin(
&self,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入签到类型 ( 可不传 , 默认安卓端签到 ), 可签到 ( 需要登录 ), 其中安卓端签到可获得 3 点经验 , web/PC 端签到可获得 2 点经验
optional 可选参数 : type: 签到类型 , 默认 0, 其中 0 为安卓端签到 ,1 为 web/PC 签到
sourcepub async fn fm_trash(&self, id: usize) -> Result<ApiResponse, ApiErr>
pub async fn fm_trash(&self, id: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入音乐 id, 可把该音乐从私人 FM 中移除至垃圾桶
required id: 歌曲 id
sourcepub async fn like(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn like(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入音乐 id, 可喜欢该音乐
required 必选参数 : id: 歌曲 id
optional 可选参数 : like: 布尔值 , 默认为 true 即喜欢 , 若传 false, 则取消喜欢
sourcepub async fn likelist(&self, uid: usize) -> Result<ApiResponse, ApiErr>
pub async fn likelist(&self, uid: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入用户 id, 可获取已喜欢音乐id列表(id数组)
required 必选参数 : uid: 用户 id
sourcepub async fn login_phone(
&self,
phone: &str,
password: &str
) -> Result<ApiResponse, ApiErr>
pub async fn login_phone(
&self,
phone: &str,
password: &str
) -> Result<ApiResponse, ApiErr>
必选参数 : phone: 手机号码 password: 密码
可选参数 : countrycode: 国家码,用于国外手机号登录,例如美国传入:1 md5_password: md5加密后的密码,传入后 password 将失效
sourcepub async fn login_refresh(&self) -> Result<ApiResponse, ApiErr>
pub async fn login_refresh(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 可刷新登录状态
sourcepub async fn login_status(&self) -> Result<ApiResponse, ApiErr>
pub async fn login_status(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可获取登录状态
sourcepub async fn lyric(&self, id: usize) -> Result<ApiResponse, ApiErr>
pub async fn lyric(&self, id: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入音乐 id 可获得对应音乐的歌词 ( 不需要登录 )
required 必选参数 : id: 音乐 id
sourcepub async fn personal_fm(&self) -> Result<ApiResponse, ApiErr>
pub async fn personal_fm(&self) -> Result<ApiResponse, ApiErr>
说明 : 私人 FM( 需要登录 )
sourcepub async fn playlist_detail(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn playlist_detail(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 歌单能看到歌单名字, 但看不到具体歌单内容 , 调用此接口 , 传入歌单 id, 可以获取对应歌单内的所有的音乐(未登录状态只能获取不完整的歌单,登录后是完整的), 但是返回的trackIds是完整的,tracks 则是不完整的, 可拿全部 trackIds 请求一次 song/detail 接口获取所有歌曲的详情
required 必选参数 : id : 歌单 id
optional 可选参数 : s : 歌单最近的 s 个收藏者,默认为8
sourcepub async fn playlist_tracks(
&self,
pid: usize,
op: u8,
tracks: Vec<usize>
) -> Result<ApiResponse, ApiErr>
pub async fn playlist_tracks(
&self,
pid: usize,
op: u8,
tracks: Vec<usize>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 可以添加歌曲到歌单或者从歌单删除某首歌曲 ( 需要登录 )
required op: 从歌单增加单曲为 add, 删除为 del pid: 歌单 id tracks: 歌曲 id,可多个,用逗号隔开
sourcepub async fn playlist_update(
&self,
pid: usize,
name: &str,
desc: &str,
tags: Vec<&str>
) -> Result<ApiResponse, ApiErr>
pub async fn playlist_update(
&self,
pid: usize,
name: &str,
desc: &str,
tags: Vec<&str>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口,可以更新用户歌单
required
id:歌单id
name:歌单名字
desc:歌单描述
tags:歌单tag ,多个用 ;
隔开,只能用官方规定标签
sourcepub async fn recommend_resource(&self) -> Result<ApiResponse, ApiErr>
pub async fn recommend_resource(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 可获得每日推荐歌单 ( 需要登录 )
sourcepub async fn recommend_songs(&self) -> Result<ApiResponse, ApiErr>
pub async fn recommend_songs(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 可获得每日推荐歌曲 ( 需要登录 )
sourcepub async fn scrobble(
&self,
id: usize,
source_id: usize
) -> Result<ApiResponse, ApiErr>
pub async fn scrobble(
&self,
id: usize,
source_id: usize
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入音乐 id, 来源 id,歌曲时间 time,更新听歌排行数据
requried 必选参数 : id: 歌曲 id sourceid: 歌单或专辑 id
optional 可选参数 : time: 歌曲播放时间,单位为秒
sourcepub async fn search_default(&self) -> Result<ApiResponse, ApiErr>
pub async fn search_default(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 可获取默认搜索关键词
sourcepub async fn search_hot_detail(&self) -> Result<ApiResponse, ApiErr>
pub async fn search_hot_detail(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可获取热门搜索列表
sourcepub async fn search_hot(&self) -> Result<ApiResponse, ApiErr>
pub async fn search_hot(&self) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口,可获取热门搜索列表(简略)
sourcepub async fn search_suggest(
&self,
keyword: &str,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn search_suggest(
&self,
keyword: &str,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入搜索关键词可获得搜索建议 , 搜索结果同时包含单曲 , 歌手 , 歌单 ,mv 信息
required 必选参数 : keywords : 关键词
optional 可选参数 : type : 如果传 ‘mobile’ 则返回移动端数据
sourcepub async fn simi_artist(&self, artist_id: usize) -> Result<ApiResponse, ApiErr>
pub async fn simi_artist(&self, artist_id: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入歌手 id, 可获得相似歌手
requried 必选参数 : id: 歌手 id
sourcepub async fn simi_playlist(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn simi_playlist(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入歌曲 id, 可获得相似歌单
required 必选参数 : id: 歌曲 id
sourcepub async fn simi_song(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn simi_song(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入歌曲 id, 可获得相似歌曲
required 必选参数 : id: 歌曲 id
sourcepub async fn song_detail(&self, ids: &[usize]) -> Result<ApiResponse, ApiErr>
pub async fn song_detail(&self, ids: &[usize]) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口 , 传入音乐 id(支持多个 id, 用 , 隔开), 可获得歌曲详情
requried 必选参数 : ids: 音乐 id, 如 ids=347230
sourcepub async fn song_url(&self, ids: &Vec<usize>) -> Result<ApiResponse, ApiErr>
pub async fn song_url(&self, ids: &Vec<usize>) -> Result<ApiResponse, ApiErr>
说明 : 使用歌单详情接口后 , 能得到的音乐的 id, 但不能得到的音乐 url, 调用此接口, 传入的音乐 id( 可多个 , 用逗号隔开 ), 可以获取对应的音乐的 url,未登录状态或者非会员返回试听片段(返回字段包含被截取的正常歌曲的开始时间和结束时间)
required 必选参数 : id : 音乐 id
optional 可选参数 : br: 码率,默认设置了 999000 即最大码率,如果要 320k 则可设置为 320000,其他类推
sourcepub async fn user_account(&self) -> Result<ApiResponse, ApiErr>
pub async fn user_account(&self) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 ,可获取用户账号信息
sourcepub async fn user_cloud_detail(
&self,
ids: &Vec<usize>
) -> Result<ApiResponse, ApiErr>
pub async fn user_cloud_detail(
&self,
ids: &Vec<usize>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入云盘歌曲 id,可获取云盘数据详情
requried 必选参数 : id: 歌曲id,可多个,用逗号隔开
sourcepub async fn user_cloud(&self, opt: Option<Value>) -> Result<ApiResponse, ApiErr>
pub async fn user_cloud(&self, opt: Option<Value>) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 可获取云盘数据 , 获取的数据没有对应 url, 需要再调用一 次 /song/url 获取 url
optional 可选参数 : limit : 返回数量 , 默认为 200 offset : 偏移数量,用于分页 , 如 :( 页数 -1)*200, 其中 200 为 limit 的值 , 默认为 0
sourcepub async fn user_comment_history(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn user_comment_history(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入用户 id, 可以获取用户历史评论
requried 必选参数 : uid : 用户 id
optional 可选参数 : limit : 返回数量 , 默认为 10 time: 上一条数据的time,第一页不需要传,默认为0
sourcepub async fn user_detail(&self, uid: usize) -> Result<ApiResponse, ApiErr>
pub async fn user_detail(&self, uid: usize) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入用户 id, 可以获取用户详情
required 必选参数 : uid : 用户 id
sourcepub async fn user_dj(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn user_dj(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入用户 id, 可以获取用户电台
required 必选参数 : uid : 用户 id
sourcepub async fn user_podcast(&self, uid: usize) -> Result<ApiResponse, ApiErr>
pub async fn user_podcast(&self, uid: usize) -> Result<ApiResponse, ApiErr>
说明 : 调用此接口, 传入用户id可获取用户创建的电台
required 必选参数 : uid : 用户 id
sourcepub async fn podcast_audio(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn podcast_audio(
&self,
id: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入rid, 可查看对应电台的电台节目以及对应的 id, 需要 注意的是这个接口返回的 mp3Url 已经无效 , 都为 null, 但是通过调用 /song/url 这 个接口 , 传入节目 id 仍然能获取到节目音频 , 如 /song/url?id=478446370 获取代 码时间的一个节目的音频 必选参数 : rid: 电台 的 id 可选参数 : limit : 返回数量 , 默认为 30 offset : 偏移数量,用于分页 , 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0 asc : 排序方式,默认为 false (新 => 老 ) 设置 true 可改为 老 => 新
sourcepub async fn user_level(&self) -> Result<ApiResponse, ApiErr>
pub async fn user_level(&self) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 可以获取用户等级信息,包含当前登录天数,听歌次数,下一等级需要的登录天数和听歌次数,当前等级进度
sourcepub async fn user_playlist(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn user_playlist(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入用户 id, 可以获取用户歌单
required 必选参数 : uid : 用户 id
optional 可选参数 : limit : 返回数量 , 默认为 30 offset : 偏移数量,用于分页 , 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0
sourcepub async fn user_record(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
pub async fn user_record(
&self,
uid: usize,
opt: Option<Value>
) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 传入用户 id, 可获取用户播放记录
requred 必选参数 : uid : 用户 id
optional 可选参数 : type : type=1 时只返回 weekData, type=0 时返回 allData
sourcepub async fn user_subcount(&self) -> Result<ApiResponse, ApiErr>
pub async fn user_subcount(&self) -> Result<ApiResponse, ApiErr>
说明 : 登录后调用此接口 , 可以获取用户信息 获取用户信息 , 歌单,收藏,mv, dj 数量
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for NcmApi
impl !Send for NcmApi
impl !Sync for NcmApi
impl Unpin for NcmApi
impl !UnwindSafe for NcmApi
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more