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