跳转至

Song

歌曲相关Api

Class qqmusic::BaseMediaFileType

ClassList > qqmusic > BaseMediaFileType

媒体文件类型基类

  • #include <song.h>

Inherited by the following classes: qqmusic::EncryptedSongFileType, qqmusic::SongFileType

Public Functions

Type Name
virtual bool encrypted () = 0
是否加密
virtual std::string_view expandation () = 0
获取扩展名
virtual std::string_view prefix () = 0
获取基类ID
virtual ~BaseMediaFileType () = default

Public Functions Documentation

function encrypted

是否加密

virtual bool qqmusic::BaseMediaFileType::encrypted () = 0


function expandation

获取扩展名

virtual std::string_view qqmusic::BaseMediaFileType::expandation () = 0


function prefix

获取基类ID

virtual std::string_view qqmusic::BaseMediaFileType::prefix () = 0


function ~BaseMediaFileType

virtual qqmusic::BaseMediaFileType::~BaseMediaFileType () = default


The documentation for this class was generated from the following file include/qqmusic/song.h

Class qqmusic::SongFileType

ClassList > qqmusic > SongFileType

未加密的歌曲文件类枚举 More...

  • #include <song.h>

Inherits the following classes: qqmusic::BaseMediaFileType

Public Types

Type Name
enum Type
未加密歌曲类型枚举

Public Functions

Type Name
SongFileType (Type type)
通过类型枚举初始化
SongFileType ()
默认初始化函数, 默认格式: MP3_128格式
virtual bool encrypted () override
该格式是否加密
virtual std::string_view expandation () override
获取歌曲类ID扩展
virtual std::string_view prefix () override
获取歌曲类ID前缀
~SongFileType () override

Public Functions inherited from qqmusic::BaseMediaFileType

See qqmusic::BaseMediaFileType

Type Name
virtual bool encrypted () = 0
是否加密
virtual std::string_view expandation () = 0
获取扩展名
virtual std::string_view prefix () = 0
获取基类ID
virtual ~BaseMediaFileType () = default

Detailed Description

See also: BaseMediaFileType

Public Types Documentation

enum Type

未加密歌曲类型枚举

enum qqmusic::SongFileType::Type {
    MASTER,
    ATMOS_2,
    ATMOS_51,
    FLAC,
    OGG_640,
    OGG_320,
    OGG_192,
    OGG_96,
    MP3_320,
    MP3_128,
    ACC_192,
    ACC_96,
    ACC_48
};


Public Functions Documentation

function SongFileType [1/2]

通过类型枚举初始化

inline qqmusic::SongFileType::SongFileType (
    Type type
) 

Parameters:

  • type 类型枚举

See also: SongFileType::Type

Exception:

  • 若提供的枚举不合法

function SongFileType [2/2]

默认初始化函数, 默认格式: MP3_128格式

inline qqmusic::SongFileType::SongFileType () 

See also: SongFileType::Type


function encrypted

该格式是否加密

inline virtual bool qqmusic::SongFileType::encrypted () override

Returns:

总是返回false

Implements qqmusic::BaseMediaFileType::encrypted


function expandation

获取歌曲类ID扩展

inline virtual std::string_view qqmusic::SongFileType::expandation () override

Returns:

返回std::string格式的类型扩展名

Implements qqmusic::BaseMediaFileType::expandation


function prefix

获取歌曲类ID前缀

inline virtual std::string_view qqmusic::SongFileType::prefix () override

Returns:

返回std::string格式的类型前缀

Implements qqmusic::BaseMediaFileType::prefix


function ~SongFileType

qqmusic::SongFileType::~SongFileType () override


The documentation for this class was generated from the following file include/qqmusic/song.h

Class qqmusic::EncryptedSongFileType

ClassList > qqmusic > EncryptedSongFileType

加密歌曲文件类型 More...

  • #include <song.h>

Inherits the following classes: qqmusic::BaseMediaFileType

Public Types

Type Name
enum Type
加密歌曲类型枚举

Public Functions

Type Name
EncryptedSongFileType (Type type)
通过类型枚举初始化
EncryptedSongFileType ()
默认初始化函数, 默认格式: FLAC格式
virtual bool encrypted () override
该格式是否加密
virtual std::string_view expandation () override
获取歌曲类ID扩展
virtual std::string_view prefix () override
获取歌曲类ID前缀
~EncryptedSongFileType () override

Public Functions inherited from qqmusic::BaseMediaFileType

See qqmusic::BaseMediaFileType

Type Name
virtual bool encrypted () = 0
是否加密
virtual std::string_view expandation () = 0
获取扩展名
virtual std::string_view prefix () = 0
获取基类ID
virtual ~BaseMediaFileType () = default

Detailed Description

See also: BaseMediaFileType

Public Types Documentation

enum Type

加密歌曲类型枚举

enum qqmusic::EncryptedSongFileType::Type {
    MASTER,
    ATMOS_2,
    ATMOS_51,
    FLAC,
    OGG_640,
    OGG_320,
    OGG_192,
    OGG_96
};


Public Functions Documentation

function EncryptedSongFileType [1/2]

通过类型枚举初始化

inline qqmusic::EncryptedSongFileType::EncryptedSongFileType (
    Type type
) 

Parameters:

  • type 类型枚举

See also: EncryptedSongFileType::Type

Exception:

  • 若提供的枚举不合法

function EncryptedSongFileType [2/2]

默认初始化函数, 默认格式: FLAC格式

inline qqmusic::EncryptedSongFileType::EncryptedSongFileType () 

See also: SongFileType::Type


function encrypted

该格式是否加密

inline virtual bool qqmusic::EncryptedSongFileType::encrypted () override

Returns:

总是返回true

Implements qqmusic::BaseMediaFileType::encrypted


function expandation

获取歌曲类ID扩展

inline virtual std::string_view qqmusic::EncryptedSongFileType::expandation () override

Returns:

返回std::string格式的类型扩展名

Implements qqmusic::BaseMediaFileType::expandation


function prefix

获取歌曲类ID前缀

inline virtual std::string_view qqmusic::EncryptedSongFileType::prefix () override

Returns:

返回std::string格式的类型前缀

Implements qqmusic::BaseMediaFileType::prefix


function ~EncryptedSongFileType

qqmusic::EncryptedSongFileType::~EncryptedSongFileType () override


The documentation for this class was generated from the following file include/qqmusic/song.h

function query_song

批量查询歌曲信息

Task< Result < nlohmann::json > > qqmusic::query_song (
    std::span< std::string > mids
) 

Parameters:

  • mids 待查询歌曲mid列表

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


/**
 * @struct SongInfo
 *
 * @var SongInfo::mid 歌曲mid
 * @var SongInfo url 歌曲文件地址, 如果没有则是`std::nullopt`
 * @var SongInfo ekey 歌曲密钥, 如果没有则是`std::nullopt`
 * */
struct SongInfo {
    std::string mid;
    std::optional<std::string> url = std::nullopt;
    std::optional<std::string> ekey = std::nullopt;
};

function get_song_urls

批量获取歌曲播放链接

Task< Result < std::vector< SongInfo > > > qqmusic::get_song_urls (
    std::span< std::string > mids,
    std::unique_ptr< BaseMediaFileType > file_type=std::make_unique< SongFileType >(),
    std::optional< utils::Credential > credential=std::nullopt
) 

@params mids 歌曲mid列表 @params file_type 歌曲文件类型, 默认MP3_128类型 @params credential 凭证信息

调用示例:

std::vector<std::string> mids{"002n5zzy3VVGau"};

// 未加密类型
auto res = co_await get_song_urls(mids,
    std::make_unique<SongFileType>(SongFileType::ACC_192));

// 加密文件类型 
auto res = co_await get_song_urls(mids,
    std::make_unique<EncryptedSongFileType>(EncryptedSongFileType::MASTER));

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

See also: BaseMediaFileType, SongFileType, EncryptedSongFileType

Note:

异步函数, 返回Task


function get_try_url

获取试听链接

Task< Result < std::string > > qqmusic::get_try_url (
    std::string_view mid,
    std::string_view vs
) 

Parameters:

  • area 区域信息筛选, 默认AreaType::ALL.
  • gender 性别信息筛选, 默认GenderType::ALL.
  • genre 风格信息筛选, 默认GenreType::ALL.

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

See also: AreaType, GenderType, GenreType

Note:

异步函数, 返回Task


function get_song_detail

获取歌曲详细信息

Task< Result < nlohmann::json > > qqmusic::get_song_detail (
    std::string_view mid
) 

Parameters:

  • mid 歌曲mid

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_song_detail

获取歌曲详细信息

Task< Result < nlohmann::json > > qqmusic::get_song_detail (
    uint64_t id
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_similar_songs

获取相似歌曲列表

Task< Result < nlohmann::json > > qqmusic::get_similar_songs (
    uint64_t songid
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_labels

获取歌曲标签信息

Task< Result < nlohmann::json > > qqmusic::get_labels (
    uint64_t songid
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


获取相关歌单列表

Task< Result < nlohmann::json > > qqmusic::get_related_songlist (
    uint64_t songid
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


获取相关MV

Task< Result < nlohmann::json > > qqmusic::get_related_mv (
    uint64_t songid,
    std::optional< std::string > last_mvid=std::nullopt
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_other_version

获取同名歌曲的其他版本

Task< Result < nlohmann::json > > qqmusic::get_other_version (
    std::string_view mid
) 

Parameters:

  • mid 歌曲mid

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_other_version

获取同名歌曲的其他版本

Task< Result < nlohmann::json > > qqmusic::get_other_version (
    uint64_t id
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_producer_info

获取歌曲制作者信息

Task< Result < nlohmann::json > > qqmusic::get_producer_info (
    std::string_view mid
) 

Parameters:

  • mid 歌曲mid

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

可能返回JSON的null, 即没有制作者信息

Note:

异步函数, 返回Task


function get_producer_info

获取歌曲制作者信息

Task< Result < nlohmann::json > > qqmusic::get_producer_info (
    uint64_t id
) 

Parameters:

  • id 歌曲id

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

可能返回JSON的null, 即没有制作者信息

Note:

异步函数, 返回Task


function get_sheet

获取曲谱信息

Task< Result < nlohmann::json > > qqmusic::get_sheet (
    std::string_view mid
) 

Parameters:

  • mid 歌曲mid

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task


function get_fav_num

获取歌曲的收藏量

Task< Result < nlohmann::json > > qqmusic::get_fav_num (
    std::span< uint64_t > id_list,
    bool readable=true
) 

Parameters:

  • id_list 歌曲id列表
  • readable 是否人类可读

示例:

readable == false 返回: {'438910555': 1000001}
readable == true 返回:  {'438910555': '550w+'}

Returns:

包含正确JSON格式结果的Task< Result <nlohmann::json>>. 如果产生错误, 返回值包含错误结果和错误类型枚举

Note:

异步函数, 返回Task