1declare namespace IPlugin { 2 export interface IMediaSourceResult { 3 headers?: Record<string, string>; 4 /** 兜底播放 */ 5 url?: string; 6 /** UA */ 7 userAgent?: string; 8 /** 音质 */ 9 quality?: IMusic.IQualityKey; 10 } 11 12 export interface ISearchResult<T extends ICommon.SupportMediaType> { 13 isEnd?: boolean; 14 data: ICommon.SupportMediaItemBase[T][]; 15 } 16 17 export type ISearchResultType = ICommon.SupportMediaType; 18 19 type ISearchFunc = <T extends ICommon.SupportMediaType>( 20 query: string, 21 page: number, 22 type: T, 23 ) => Promise<ISearchResult<T>>; 24 25 type IGetArtistWorksFunc = <T extends IArtist.ArtistMediaType>( 26 artistItem: IArtist.IArtistItem, 27 page: number, 28 type: T, 29 ) => Promise<ISearchResult<T>>; 30 31 interface IUserVariable { 32 /** 键 */ 33 key: string; 34 /** 名称 */ 35 name?: string; 36 } 37 38 interface IAlbumInfoResult { 39 isEnd?: boolean; 40 albumItem?: IAlbum.IAlbumItemBase; 41 musicList?: IMusic.IMusicItem[]; 42 } 43 44 interface ISheetInfoResult { 45 isEnd?: boolean; 46 sheetItem?: IMusic.IMusicSheetItemBase; 47 musicList?: IMusic.IMusicItem[]; 48 } 49 50 interface IGetRecommendSheetTagsResult { 51 // 固定的tag 52 pinned?: IMusic.IMusicSheetItemBase[]; 53 data?: IMusic.IMusicSheetGroupItem[]; 54 } 55 56 interface IPluginDefine { 57 /** 来源名 */ 58 platform: string; 59 /** 匹配的版本号 */ 60 appVersion?: string; 61 /** 插件版本 */ 62 version?: string; 63 /** 远程更新的url */ 64 srcUrl?: string; 65 /** 主键,会被存储到mediameta中 */ 66 primaryKey?: string[]; 67 /** 默认搜索类型 */ 68 defaultSearchType?: ICommon.SupportMediaType; 69 /** 有效搜索类型 */ 70 supportedSearchType?: ICommon.SupportMediaType[]; 71 /** 插件缓存控制 */ 72 cacheControl?: 'cache' | 'no-cache' | 'no-store'; 73 /** 用户自定义输入 */ 74 userVariables?: IUserVariable[]; 75 /** 提示文本 */ 76 hints?: Record<string, string[]>; 77 /** 搜索 */ 78 search?: ISearchFunc; 79 /** 获取根据音乐信息获取url */ 80 getMediaSource?: ( 81 musicItem: IMusic.IMusicItemBase, 82 quality: IMusic.IQualityKey, 83 ) => Promise<IMediaSourceResult | null>; 84 /** 根据主键去查询歌曲信息 */ 85 getMusicInfo?: ( 86 musicBase: ICommon.IMediaBase, 87 ) => Promise<Partial<IMusic.IMusicItem> | null>; 88 /** 获取歌词 */ 89 getLyric?: ( 90 musicItem: IMusic.IMusicItemBase, 91 ) => Promise<ILyric.ILyricSource | null>; 92 /** 获取专辑信息,里面的歌曲分页 */ 93 getAlbumInfo?: ( 94 albumItem: IAlbum.IAlbumItemBase, 95 page: number, 96 ) => Promise<IAlbumInfoResult | null>; 97 /** 获取歌单信息,有分页 */ 98 getMusicSheetInfo?: ( 99 sheetItem: IMusic.IMusicSheetItem, 100 page: number, 101 ) => Promise<ISheetInfoResult | null>; 102 /** 获取作品,有分页 */ 103 getArtistWorks?: IGetArtistWorksFunc; 104 /** 导入歌单 */ 105 // todo: 数据结构应该是IMusicSheetItem 106 importMusicSheet?: ( 107 urlLike: string, 108 ) => Promise<IMusic.IMusicItem[] | null>; 109 /** 导入单曲 */ 110 importMusicItem?: ( 111 urlLike: string, 112 ) => Promise<IMusic.IMusicItem | null>; 113 /** 获取榜单 */ 114 getTopLists?: () => Promise<IMusic.IMusicSheetGroupItem[]>; 115 // todo:分页 116 /** 获取榜单详情 */ 117 getTopListDetail?: ( 118 topListItem: IMusic.IMusicSheetItemBase, 119 ) => Promise<ICommon.WithMusicList<IMusic.IMusicSheetItemBase>>; 120 /** 获取热门歌单tag */ 121 getRecommendSheetTags?: () => Promise<IGetRecommendSheetTagsResult>; 122 /** 歌单列表 */ 123 getRecommendSheetsByTag?: ( 124 tag: ICommon.IUnique, 125 page?: number, 126 ) => Promise<ICommon.PaginationResponse<IMusic.IMusicSheetItemBase>>; 127 } 128 129 export interface IPluginInstance extends IPluginDefine { 130 /** 内部属性 */ 131 /** 插件路径 */ 132 _path: string; 133 } 134 135 type R = Required<IPluginInstance>; 136 export type IPluginInstanceMethods = { 137 [K in keyof R as R[K] extends (...args: any) => any ? K : never]: R[K]; 138 }; 139 140 /** 插件其他属性 */ 141 export type IPluginMeta = { 142 order: number; 143 userVariables: Record<string, string>; 144 enabled?: boolean; 145 }; 146} 147