krillplayer-plugin 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +5 -0
  2. package/dist/cli.js +949 -636
  3. package/package.json +3 -2
  4. package/skill/krillplayer-plugin/SKILL.md +2 -1
  5. package/skill/krillplayer-plugin/assets/samples/file-share/plugin.ts +1 -20
  6. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-connect.json +23 -0
  7. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-decode.json +19 -0
  8. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-content-rejected.json +31 -0
  9. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-login-expired.json +31 -0
  10. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-muted.json +31 -0
  11. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-not-logged-in.json +14 -0
  12. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-other.json +31 -0
  13. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-rate-limited.json +31 -0
  14. package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-sent.json +28 -0
  15. package/skill/krillplayer-plugin/assets/samples/live-video-platform/manifest.ts +2 -1
  16. package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +40 -1
  17. package/skill/krillplayer-plugin/assets/samples/media-server/plugin.ts +1 -35
  18. package/skill/krillplayer-plugin/assets/samples/network-share/plugin.ts +1 -20
  19. package/skill/krillplayer-plugin/references/choosing-a-kind.md +2 -2
  20. package/skill/krillplayer-plugin/references/contract.d.ts +80 -112
  21. package/skill/krillplayer-plugin/references/errors-and-fixes.md +1 -1
  22. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-empty-folder.json +0 -11
  23. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-gone-not-found.json +0 -12
  24. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-lists-subfolders-and-media.json +0 -28
  25. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-second-page.json +0 -22
  26. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-skips-subtitles.json +0 -21
  27. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-root-first-page.json +0 -25
  28. package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-root-second-page.json +0 -22
  29. package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-everything-first-page.json +0 -74
  30. package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-everything-last-page.json +0 -86
  31. package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-nothing-new.json +0 -12
  32. package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-since-a-token-with-a-removal.json +0 -88
  33. package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-ids-first-page.json +0 -15
  34. package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-ids-last-page.json +0 -14
  35. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-empty-folder.json +0 -60
  36. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-gives-size-and-modified-time.json +0 -78
  37. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-gone-not-found.json +0 -60
  38. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-second-page.json +0 -71
  39. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-a-range.json +0 -62
  40. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-an-info-file.json +0 -62
  41. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-file-gone-not-found.json +0 -62
  42. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-root.json +0 -84
  43. package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-source-offline-retryable.json +0 -61
@@ -23,7 +23,7 @@ export interface Paged<T> {
23
23
  export type Ids = Record<string, string>;
24
24
 
25
25
  // 能力由打包器按导出的函数生成(SLOT_RULES),插件不手写。
26
- export type Capability = "browse" | "music" | "play" | "resolve" | "library" | "resources" | "subtitles" | "subtitleSearch" | "danmaku" | "danmakuMatch" | "status" | "login" | "playbackReport" | "views" | "libraryChanges";
26
+ export type Capability = "browse" | "music" | "play" | "resolve" | "resources" | "subtitles" | "subtitleSearch" | "danmaku" | "danmakuMatch" | "status" | "login" | "playbackReport" | "views" | "danmakuSend" | "browseLists";
27
27
 
28
28
  // 内容对象。通用域三样结构:频道、合集、条目,每个种类一个类型,只带属于它的字段。
29
29
  // 种类的取值是内核定死的词表,插件不能自造。比插件旧的 App 遇到不认识的种类时跳过数组里的那一项、把可选字段当作没给;
@@ -124,11 +124,11 @@ export interface PodcastEpisode {
124
124
  summary?: string; // App 尚未使用
125
125
  media: Media;
126
126
  podcast: ChannelRef;
127
- season?: number; // 整数;App 尚未使用
128
- index?: number; // 整数;App 尚未使用
127
+ season?: number; // 整数
128
+ index?: number; // 整数
129
129
  episodeType?: PodcastEpisodeType; // App 尚未使用
130
130
  duration?: number;
131
- published?: number; // App 尚未使用
131
+ published?: number;
132
132
  }
133
133
 
134
134
  export type PodcastEpisodeType = "full" | "trailer" | "bonus";
@@ -178,7 +178,7 @@ export interface Upcoming {
178
178
  end?: number; // App 尚未使用
179
179
  }
180
180
 
181
- // filename 是原始文件名,给识别与字幕匹配用。
181
+ // filename 是原始文件名,给字幕匹配用。
182
182
  export interface File {
183
183
  kind: "file";
184
184
  id: string;
@@ -255,7 +255,7 @@ export interface Season {
255
255
  ancestors?: CollectionRef[]; // App 尚未使用
256
256
  index: number; // 整数
257
257
  series: CollectionRef;
258
- ids?: Ids;
258
+ ids?: Ids; // App 尚未使用
259
259
  }
260
260
 
261
261
  export interface BoxSet {
@@ -266,7 +266,7 @@ export interface BoxSet {
266
266
  summary?: string;
267
267
  count?: number; // 整数
268
268
  ancestors?: CollectionRef[]; // App 尚未使用
269
- ids?: Ids;
269
+ ids?: Ids; // App 尚未使用
270
270
  }
271
271
 
272
272
  export interface Playlist {
@@ -299,6 +299,16 @@ export type Entry =
299
299
  | { type: "collection"; collection: Collection }
300
300
  ;
301
301
 
302
+ // 具名列表:插件交出的一份数据,id 稳定,App 按 kind(内容大类)给它取默认的样式,怎么画全由 App 定。
303
+ // video 影视与点播,live 直播与电视台,audio 电台与播客,file 文件与文件夹。
304
+ export type BrowseListKind = "video" | "live" | "audio" | "file";
305
+
306
+ export interface BrowseList {
307
+ id: string;
308
+ title: string;
309
+ kind: BrowseListKind;
310
+ }
311
+
302
312
  // 音乐曲库:歌手、专辑、歌单、歌曲四样,不是频道、合集、条目的种类。
303
313
  // 歌曲的歌手与它所在专辑的歌手分开给:合辑的专辑歌手可以为空,compilation 为真。歌曲不记续播位置,进播放队列。
304
314
  export interface ArtistRef {
@@ -415,54 +425,6 @@ export interface LyricsLine {
415
425
  translation?: string;
416
426
  }
417
427
 
418
- // 资料库:文件类来源的 list 列出一个目录下的一层,内核据此扫描进索引库。path 相对来源实例的根,根是 "",
419
- // 分隔符是 /,开头不带 /。path 只用于识别与手动改正,起播只认 itemId(与 browse 给的同一个 File 的 id 一致)。
420
- // 媒体服务器实现 changes 与 ids,交回已经识别过的条目(identified),内核直接用它给的 id,不再按文件名搜索。
421
- export interface LibraryDirectory {
422
- type: "directory";
423
- path: string;
424
- name: string;
425
- modified?: number;
426
- tag?: string;
427
- }
428
-
429
- export interface LibraryFile {
430
- type: "file";
431
- path: string;
432
- name: string;
433
- itemId: string;
434
- media: Media;
435
- size?: number; // 整数
436
- modified?: number;
437
- tag?: string;
438
- }
439
-
440
- // 媒体服务器已经识别过的一部电影(movie)或一集(episode),别的种类内核跳过。item.id 是起播用的 id,
441
- // 也是增量与对账认这一项的键;电影的 versions 各是一个文件,起播用版本自己的 id。ids 是作品的外部 id(集的看 series.ids),
442
- // 内核拿它与别的来源里的同一部聚合。series 是集所在的剧的完整资料(海报、年份),给了内核用它显示这部剧,没给时只有 item.series 里的片名与 ids。
443
- export interface LibraryIdentified {
444
- type: "identified";
445
- item: Item;
446
- series?: Series;
447
- }
448
-
449
- export type LibraryEntry = LibraryDirectory | LibraryFile | LibraryIdentified;
450
-
451
- // changes 的一页:entries 是 since 之后新增或改过的条目(都是 identified),removed 是来源知道的删除(条目 id)。
452
- // next 有值时内核原样带回取下一页;since 是全部取完之后下次增量用的 since,内核只认最后一页(没有 next 的那页)给的。
453
- export interface LibraryChanges {
454
- entries: LibraryEntry[];
455
- removed?: string[];
456
- next?: string;
457
- since: string;
458
- }
459
-
460
- // ids 的一页:来源里现在全部条目的 id(与 identified 的 item.id 一致),内核拿它做只取 id 的全量对账,认出删除。
461
- export interface LibraryIds {
462
- ids: string[];
463
- next?: string;
464
- }
465
-
466
428
  // krillplayer.files:内核替插件读用户填的那台服务器或选的那个文件夹,插件拿不到套接字,也走不出来源实例的根。
467
429
  // 清单的 files 声明要哪种协议;path 相对来源实例的根,根是 "",分隔符是 /,开头不带 /,不接受 . 与 ..。
468
430
  // modified 是 Unix 秒;目录不带 size。
@@ -518,6 +480,7 @@ export interface ResolvedBrowse {
518
480
  // multiChoice 是一个 JSON 数组的文本。secret 的值按凭证存放,不进任何 id,也不进日志。不认识的种类当作 text。
519
481
  // dynamicOptions:选项要向插件的 options(krillplayer, name, values) 要;dependsOn 里的参数变了重新要。
520
482
  // visibleWhen 全部满足才显示;当前不显示的参数不传给插件。constant 不显示给用户,值固定为 defaultValue。
483
+ // perSource 只在清单的 settings 里有意义:这一项每个来源各存一份,在来源的编辑页里改;不写是插件级,所有来源共用一份。
521
484
  export interface Parameter {
522
485
  name: string;
523
486
  title: string;
@@ -530,6 +493,7 @@ export interface Parameter {
530
493
  dynamicOptions?: boolean;
531
494
  dependsOn?: string[];
532
495
  visibleWhen?: ParameterCondition[];
496
+ perSource?: boolean;
533
497
  }
534
498
 
535
499
  // App 不认识的取值当作 "text"。
@@ -574,8 +538,11 @@ export interface PlatformCapabilities {
574
538
  tvOS?: Capability[];
575
539
  }
576
540
 
577
- // parameters 是实例参数:声明了它的插件,用户每填一组就建一个来源实例;url 参数里的主机在声明了 userProvidedURLs 时放行。
578
- // settings 是设置项,值由插件用 krillplayer.settings.get() 读。
541
+ // 插件是来源类型,来源是它的实例:能浏览或有曲库的插件,用户在来源页「+」每添加一次就建一个来源实例,没有实例参数的也一样。
542
+ // parameters 是实例参数,添加时填;url 参数里的主机在声明了 userProvidedURLs 时放行。
543
+ // settings 是设置项,值由插件用 krillplayer.settings.get() 读;默认插件级,带 perSource 的那一项每个来源各一份。
544
+ // loginRequired:导出了 login 的插件声明添加来源时必须登录;不写是可以登录、也可以不登录。没导出 login 的插件没有登录,不能写它。
545
+ // singleSource:这个插件只能有一个来源实例;不写可以有多个(多个账号就是多个来源)。
579
546
  export interface PluginManifest {
580
547
  id: string;
581
548
  sourceId: string;
@@ -588,6 +555,8 @@ export interface PluginManifest {
588
555
  hosts: string[];
589
556
  userProvidedURLs?: boolean;
590
557
  readsCredentials?: boolean;
558
+ loginRequired?: boolean;
559
+ singleSource?: boolean;
591
560
  imageCacheIgnoredParameters?: string[];
592
561
  files?: FilesProtocol;
593
562
  appKeys?: string[];
@@ -599,8 +568,10 @@ export interface PluginManifest {
599
568
  capabilities: Capability[];
600
569
  }
601
570
 
571
+ // muted、rateLimited、contentRejected 是发弹幕(danmaku.send)被来源拒绝的三种原因:被禁言、发得太快、内容不让发。
572
+ // 不认识的种类按 other(旧内核遇到这三种也是 other)。
602
573
  // App 不认识的取值当作 "other"。
603
- export type PluginErrorKind = "regionRestricted" | "loginRequired" | "verificationRequired" | "ended" | "notStarted" | "refused" | "retryable" | "notFound" | "other";
574
+ export type PluginErrorKind = "regionRestricted" | "loginRequired" | "verificationRequired" | "ended" | "notStarted" | "refused" | "retryable" | "notFound" | "muted" | "rateLimited" | "contentRejected" | "other";
604
575
 
605
576
  export interface PluginError {
606
577
  kind: PluginErrorKind;
@@ -675,16 +646,8 @@ export type PlayableSegmentKind = "intro" | "outro" | "chapter";
675
646
 
676
647
  export type PlayableDecryptionMethod = "cencAesCtr";
677
648
 
678
- // 指向插件的一个页面:内核用 page 与 values 调 views.page;title 是推入页面时的标题。
679
- export interface PageLink {
680
- page: string;
681
- title?: string;
682
- values?: Record<string, string>;
683
- }
684
-
685
649
  // 卡片按 kind 各取所需的字段,缺了必需字段的卡片按坏元素跳过:
686
- // entry 必须有 entry:点频道与合集进内核的原生页面,点条目起播或进详情;link 必须有 open,点开推入插件的页面;
687
- // banner 必须有 image,给 entry 或 open 之一;comment 必须有 text,title 是作者、image 是头像、time 是 Unix 秒。
650
+ // entry 必须有 entry:点频道与合集进内核的原生页面,点条目起播或进详情;comment 必须有 text,title 是作者、image 是头像、time 是 Unix 秒。
688
651
  // 卡片自己没有 image 时用 entry 里对象的图。徽标与续播进度由内核按 entry 画,插件不给;颜色、尺寸与动画都由内核决定。
689
652
  export interface Card {
690
653
  kind: CardKind;
@@ -695,22 +658,20 @@ export interface Card {
695
658
  text?: string;
696
659
  time?: number;
697
660
  entry?: Entry;
698
- open?: PageLink;
699
661
  }
700
662
 
701
- export type CardKind = "entry" | "link" | "banner" | "comment";
663
+ export type CardKind = "entry" | "comment";
702
664
 
703
- // row 横向列表,grid 网格,list 竖排的紧凑行(评论、面板里的推荐),banners 横幅轮播。more 是分区标题旁的「更多」。
665
+ // row 横向列表,grid 网格,list 竖排的紧凑行(评论、面板里的推荐)。
704
666
  export interface Section {
705
667
  layout: SectionLayout;
706
668
  title?: string;
707
669
  cards: Card[];
708
- more?: PageLink;
709
670
  }
710
671
 
711
- export type SectionLayout = "row" | "grid" | "list" | "banners";
672
+ export type SectionLayout = "row" | "grid" | "list";
712
673
 
713
- // 插件用组件拼出的页面。filters 里的选项参数渲染成分段筛选,选中的值按参数名放进下一次请求的 values;
674
+ // 播放器面板的内容(views.panel):插件用组件拼出的一页。filters 里的选项参数渲染成分段筛选,选中的值按参数名放进下一次请求的 values;
714
675
  // next 有值时内核滚到底再要下一页,把它原样放进下一次请求的 cursor:下一页的第一个分区与上一页最后一个分区布局与标题相同时接在后面。
715
676
  // empty 是没有分区时空状态里的说明。Swift 里叫 PageContent:内核校验后的页面类型叫 ComponentPage。
716
677
  export interface ComponentPage {
@@ -722,9 +683,8 @@ export interface ComponentPage {
722
683
  empty?: string;
723
684
  }
724
685
 
725
- // 卡片操作的结果:open 推入插件的页面,message 是给用户看的一句话。
686
+ // 卡片操作的结果:message 是给用户看的一句话。
726
687
  export interface ActionResult {
727
- open?: PageLink;
728
688
  message?: string;
729
689
  }
730
690
 
@@ -736,14 +696,14 @@ export interface ActionResult {
736
696
  // latest 是频道最新的点播条目(来源内 id、发布时间 Unix 秒、标题),内核据此判定「有新集」;与 live 无关,查不出时不给。
737
697
  // liveId 在 live 为 online 时给:此刻在播的那个条目的 id,内核用它起播;没给时内核退回去调 browse.channel 取。
738
698
  export interface ChannelStatus {
739
- id: string; // App 尚未使用
740
- live: ChannelLive; // App 尚未使用
741
- offlineReason?: OfflineReason; // App 尚未使用
742
- unknownReason?: UnknownReason; // App 尚未使用
743
- retryAfter?: number; // App 尚未使用
744
- title?: string; // App 尚未使用
745
- session?: string; // App 尚未使用
746
- liveId?: string; // App 尚未使用
699
+ id: string;
700
+ live: ChannelLive;
701
+ offlineReason?: OfflineReason;
702
+ unknownReason?: UnknownReason;
703
+ retryAfter?: number;
704
+ title?: string;
705
+ session?: string;
706
+ liveId?: string;
747
707
  latest?: LatestItemSignal; // App 尚未使用
748
708
  }
749
709
 
@@ -764,8 +724,8 @@ export interface LatestItemSignal {
764
724
 
765
725
  // 状态槽位 images 的一项:频道 id 与它的头像,地址规则同卡片的 image。
766
726
  export interface ChannelImage {
767
- id: string; // App 尚未使用
768
- image: string; // App 尚未使用
727
+ id: string;
728
+ image: string;
769
729
  }
770
730
 
771
731
  // 弹幕槽位的直播弹幕。一帧是文本或字节,二者只给一个;两个都给时按字节。
@@ -1017,15 +977,19 @@ export interface RSSFeed {
1017
977
 
1018
978
  // krillplayer.metadata:目录插件经它查影视资料,请求由内核发出,插件看不到背后是哪家服务,也不用在 hosts 里声明。
1019
979
  // 名字是自己定的,不跟哪一家的接口名与类型编号走。榜单:trending 是本周的热门,popular 是一直以来的热门,topRated 是评分高的,
1020
- // upcoming 只有电影,onAir 只有剧集。筛选(genre、country、year)只有 popular 与 topRated 能用,三者可以一起用。
980
+ // upcoming 与 nowPlaying(正在院线上映)只有电影,onAir 只有剧集。筛选(genre、country、year、network)只有 popular 与 topRated 能用,
981
+ // 可以一起用;network 是剧集首播的平台,只有剧集能用。
1021
982
  // 剧集没有 horror、history、music、romance、thriller,电影没有 kids、news、reality、soap、talk;剧集的 action 与 adventure、
1022
983
  // scienceFiction 与 fantasy 各是同一组。组合不成立、名字写错,调用直接失败并说明原因。
1023
984
  export type WorkKind = "movie" | "series";
1024
985
 
1025
- export type ListName = "trending" | "popular" | "topRated" | "upcoming" | "onAir";
986
+ export type ListName = "trending" | "popular" | "topRated" | "upcoming" | "nowPlaying" | "onAir";
1026
987
 
1027
988
  export type Genre = "action" | "adventure" | "animation" | "comedy" | "crime" | "documentary" | "drama" | "family" | "fantasy" | "history" | "horror" | "kids" | "music" | "mystery" | "news" | "reality" | "romance" | "scienceFiction" | "soap" | "talk" | "thriller" | "war" | "western";
1028
989
 
990
+ // 剧集首播的平台,名字是自己定的一组。
991
+ export type Network = "netflix" | "hbo" | "disneyPlus" | "appleTv" | "primeVideo" | "hulu" | "peacock" | "paramountPlus" | "iqiyi" | "tencentVideo" | "youku" | "bilibili" | "mangoTv";
992
+
1029
993
  // search 与 list 返回的 ids 只有 tmdb;get 返回这家知道的全部判定 id,调用方带来的别家 id 原样留着。image 是海报,经代理转发,不用声明域名。
1030
994
  export interface Work {
1031
995
  kind: WorkKind;
@@ -1043,9 +1007,10 @@ export interface MetadataSearchOptions {
1043
1007
  cursor?: string;
1044
1008
  }
1045
1009
 
1046
- // 筛选只有 popular 与 topRated 能用;country 是 ISO 3166-1 两位大写代码,year 是上映或首播年。
1010
+ // 筛选只有 popular 与 topRated 能用;country 是 ISO 3166-1 两位大写代码,year 是上映或首播年,network 只有剧集能用。
1047
1011
  export interface MetadataListOptions {
1048
1012
  genre?: Genre;
1013
+ network?: Network;
1049
1014
  country?: string;
1050
1015
  year?: number; // 整数
1051
1016
  cursor?: string;
@@ -1343,11 +1308,27 @@ export interface KrillPlayer {
1343
1308
  // 槽位的调用约定:导出名就是槽位名,每个函数的第一个参数是 krillplayer。槽位接口不生成,内核按名字调用。
1344
1309
  // 翻页一律用游标:函数收 cursor,返回 Paged<T>,next 有值就是还有下一页;第一页不传 cursor。翻页只往后翻。
1345
1310
 
1346
- // 浏览:通用域的来源实现这一组。values 是浏览参数的取值,按参数名传入,都是字符串。
1311
+ // 浏览:通用域的来源实现这一组。插件只交数据,不交版式,来源页与首页怎么画由 App 定。
1312
+ // 有几份列表的插件导出 lists,交出几份具名列表(形状同 music 的 sections),写成 BrowseListsSlot:list、parameters、options
1313
+ // 都多收一个列表的 id。只有一份列表的插件不导出 lists,写成 BrowseSlot:list、parameters、options 不收列表的 id。
1314
+ // values 是这份列表参数的取值,按参数名传入,都是字符串。
1347
1315
  // channel 与 collection 返回对象本身加它下面的一页;条目必须已经按播放顺序排好,内核不重排。
1348
1316
  // schedule 一次查多个频道的节目单,返回按频道 id 分的排期。
1349
1317
  // search 是跨来源搜索里本来源的那一份:内核同时问每个导出了 search 的来源要第一页,结果按来源分组标明来源。
1318
+ export interface BrowseListsSlot {
1319
+ lists(krillplayer: KrillPlayer): BrowseList[] | Promise<BrowseList[]>;
1320
+ parameters?(krillplayer: KrillPlayer, list: string): Parameter[] | Promise<Parameter[]>;
1321
+ options?(krillplayer: KrillPlayer, list: string, name: string, values: Record<string, string>): Promise<Option[]>;
1322
+ list(krillplayer: KrillPlayer, list: string, values: Record<string, string>, cursor?: string): Promise<Paged<Entry>>;
1323
+ search?(krillplayer: KrillPlayer, query: string, cursor?: string): Promise<Paged<Entry>>;
1324
+ channel?(krillplayer: KrillPlayer, channelId: string, at?: At): Promise<ChannelPage>;
1325
+ collection?(krillplayer: KrillPlayer, collectionId: string, at?: At): Promise<CollectionPage>;
1326
+ schedule?(krillplayer: KrillPlayer, channelIds: string[], range: { start: number; end: number }): Promise<Record<string, ScheduleEntry[]>>;
1327
+ }
1328
+
1329
+ // 只有一份列表的特例:App 把它当作一份具名列表,标题用来源的名字。
1350
1330
  export interface BrowseSlot {
1331
+ lists?: never;
1351
1332
  parameters?(krillplayer: KrillPlayer): Parameter[] | Promise<Parameter[]>;
1352
1333
  options?(krillplayer: KrillPlayer, name: string, values: Record<string, string>): Promise<Option[]>;
1353
1334
  list(krillplayer: KrillPlayer, values: Record<string, string>, cursor?: string): Promise<Paged<Entry>>;
@@ -1373,23 +1354,8 @@ export interface MusicSlot {
1373
1354
  lyrics?(krillplayer: KrillPlayer, songId: string): Promise<Lyrics | null>;
1374
1355
  }
1375
1356
 
1376
- // 资料库:能列举全部内容的来源实现它,内核据此扫描进索引库。
1377
- // list 给 dir 下的一层(不递归,子目录由内核再列),翻页用游标;dir 相对来源实例的根,根是 ""。
1378
- // 目录不存在时抛 krillplayer.error("notFound"),内核据此删掉它在索引里的内容;连不上抛 retryable、没有权限抛 loginRequired,
1379
- // 内核什么都不删,把来源标为离线。read 读一个文件的一段(内核读 NFO 用,每个文件最多 64 KiB)。
1380
- // 媒体服务器不实现 list,实现 changes 与 ids(两个一起):changes 交回 since 之后新增或改过的条目,都是来源已经识别过的
1381
- // { type: "identified", item },since 为 null 时交回全部;ids 交回现在全部条目的 id,内核每天第一次增量与用户手动时拿它对账、认出删除。
1382
- // 两者都按游标翻页。连不上抛 retryable、没有权限抛 loginRequired,内核什么都不删,条目照样留在海报墙上、标明不可播。
1383
- export interface LibrarySlot {
1384
- list?(krillplayer: KrillPlayer, dir: string, cursor?: string): Promise<Paged<LibraryEntry>>;
1385
- read?(krillplayer: KrillPlayer, path: string, offset: number, length: number): Promise<Uint8Array>;
1386
- changes?(krillplayer: KrillPlayer, since: string | null, cursor?: string): Promise<LibraryChanges>;
1387
- ids?(krillplayer: KrillPlayer, cursor?: string): Promise<LibraryIds>;
1388
- }
1389
-
1390
1357
  // 资源插件:用户要看某部作品时内核同时问每个资源插件,返回的每一项是一个版本,之后用它的 id 调 play.start;
1391
1358
  // 不用造出季和剧集。没有就返回空数组,不抛错。内核给 find 的时限比别的调用短,超时当作没有。
1392
- // 实现了 library 的来源不实现 find,否则同一份内容会出现两次。
1393
1359
  export interface ResourcesSlot {
1394
1360
  find(krillplayer: KrillPlayer, work: WorkQuery): Promise<ResourceVersion[]>;
1395
1361
  }
@@ -1411,8 +1377,8 @@ export interface ParametersExport {
1411
1377
  // images 可选:一批频道的头像,查不到的频道不列。内核只为订阅里还没有头像的频道调它,与 check 分开、单独计时,
1412
1378
  // 这一批 check 有频道被限流时不调,后台刷新不调。头像能从 check 已有的应答里顺带拿到的来源也走这里。
1413
1379
  export interface StatusSlot {
1414
- check(krillplayer: KrillPlayer, channelIds: string[]): Promise<ChannelStatus[]>; // App 尚未使用
1415
- images?(krillplayer: KrillPlayer, channelIds: string[]): Promise<ChannelImage[]>; // App 尚未使用
1380
+ check(krillplayer: KrillPlayer, channelIds: string[]): Promise<ChannelStatus[]>;
1381
+ images?(krillplayer: KrillPlayer, channelIds: string[]): Promise<ChannelImage[]>;
1416
1382
  }
1417
1383
 
1418
1384
  // 登录槽位。凭证一律经 krillplayer.credentials.set 写入,过期时间随写入一起报;
@@ -1430,12 +1396,17 @@ export interface LoginSlot {
1430
1396
  // segment 是点播弹幕:给出覆盖条目里 position 秒的那一段;内核按播放位置决定何时要哪一段、何时上屏。
1431
1397
  // match 与 comments 是弹幕插件,对任何来源的视频:match 按 media 给候选(没有时给空数组),内核取第一个、用户可以改选;
1432
1398
  // comments 按候选的 id 给覆盖 position 秒的那一段,规则同 segment。match 与 comments 要一起导出。
1399
+ // send 在直播间 itemId 里用本来源的登录凭证发一条弹幕 text,发出去了就正常返回,没有返回值;自己发的那条内核已经上屏,
1400
+ // 之后连接里推回来的同一条由内核去掉。被拒绝时抛 krillplayer.error:没登录或登录失效 loginRequired、被禁言 muted、
1401
+ // 发得太快 rateLimited、内容不让发 contentRejected,别的原因 other,message 是来源给的说明(内核原样显示)。
1402
+ // 内核不自动重发,同一条内容不连发,两次发送之间留几秒;插件也不要替用户重发。
1433
1403
  export interface DanmakuSlot {
1434
1404
  connect?(krillplayer: KrillPlayer, itemId: string, resume: string | null): Promise<LiveDanmakuConnection>;
1435
1405
  decode?(krillplayer: KrillPlayer, frame: DanmakuFrame): DanmakuBatch | Promise<DanmakuBatch>;
1436
1406
  segment?(krillplayer: KrillPlayer, itemId: string, position: number): Promise<DanmakuSegment>;
1437
1407
  match?(krillplayer: KrillPlayer, media: MediaQuery): Promise<DanmakuMatch[]>;
1438
1408
  comments?(krillplayer: KrillPlayer, matchId: string, position: number): Promise<DanmakuSegment>;
1409
+ send?(krillplayer: KrillPlayer, itemId: string, text: string): Promise<void>;
1439
1410
  }
1440
1411
 
1441
1412
  // 播放回报槽位(可选):插件把这次播放报给来源。失败不影响播放,内核不重试。
@@ -1453,16 +1424,13 @@ export interface SubtitlesSlot {
1453
1424
  fetch(krillplayer: KrillPlayer, trackId: string, itemId?: string): Promise<Subtitle>;
1454
1425
  }
1455
1426
 
1456
- // views 槽位。values 里的值都是字符串;cursor 是上一页给的 next,第一页不给;
1457
- // components 是内核的组件库版本(COMPONENT_LIBRARY.version)。
1458
- // page 的 "home" 是来源首页,其余页面 id 由插件自己定、经 PageLink 引用。panel 与 action 的 id 来自清单的贡献点声明,
1459
- // item 与 channel 是来源内 id。
1460
- export interface PageRequest { page: string; values: Record<string, string>; cursor?: string; components: number }
1427
+ // views 槽位:播放器面板与卡片操作。values 里的值都是字符串;cursor 是上一页给的 next,第一页不给;
1428
+ // components 是内核的组件库版本(COMPONENT_LIBRARY.version)。panel 与 action 的 id 来自清单的贡献点声明,
1429
+ // item 与 channel 是来源内 id。插件拼整页的 page 去掉了,来源页由 App 按具名列表画。
1461
1430
  export interface PanelRequest { panel: string; item: string; values: Record<string, string>; cursor?: string; components: number }
1462
1431
  export interface ActionRequest { action: string; item?: string; channel?: string }
1463
1432
 
1464
1433
  export interface ViewsSlot {
1465
- page(krillplayer: KrillPlayer, request: PageRequest): Promise<ComponentPage>;
1466
1434
  panel?(krillplayer: KrillPlayer, request: PanelRequest): Promise<ComponentPage>;
1467
1435
  action?(krillplayer: KrillPlayer, request: ActionRequest): Promise<ActionResult>;
1468
1436
  }
@@ -8,7 +8,7 @@
8
8
 
9
9
  | 报错里有 | 意思 | 怎么改 |
10
10
  |---|---|---|
11
- | `plugins export only` | plugin.ts 导出了契约里没有的名字 | 只导出槽位对象(browse、play、library、status、login、danmaku、subtitles、playbackReport、views、parameters)与顶层函数 resolve;辅助函数不要 export |
11
+ | `plugins export only` | plugin.ts 导出了契约里没有的名字 | 只导出槽位对象(browse、play、status、login、danmaku、subtitles、playbackReport、views、parameters)与顶层函数 resolve;辅助函数不要 export |
12
12
  | `is not in the contract` | 槽位对象里有契约没列的函数 | 把辅助函数移到槽位对象外面;函数名照 contract.d.ts 里的槽位接口拼 |
13
13
  | `needs one of` | 槽位导出了却一项能力都生成不了 | 补上这一项列出的函数中的一个 |
14
14
  | `is inherited; slot functions must be the object's own properties` | 槽位函数放在类的方法或原型上 | 写成对象字面量:export const browse = { async list(krillplayer, values, cursor) {…} } satisfies BrowseSlot |
@@ -1,11 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- "Home Videos/2025"
6
- ],
7
- "exchanges": [],
8
- "output": {
9
- "entries": []
10
- }
11
- }
@@ -1,12 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- "不存在"
6
- ],
7
- "exchanges": [],
8
- "error": {
9
- "kind": "notFound",
10
- "message": "这个文件夹已不在了"
11
- }
12
- }
@@ -1,28 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- "Home Videos"
6
- ],
7
- "exchanges": [],
8
- "output": {
9
- "entries": [
10
- {
11
- "type": "directory",
12
- "path": "Home Videos/2025",
13
- "name": "2025",
14
- "modified": 1795748400
15
- },
16
- {
17
- "type": "file",
18
- "path": "Home Videos/beach.MOV",
19
- "name": "beach.MOV",
20
- "itemId": "Home Videos/beach.MOV",
21
- "media": "video",
22
- "size": 1073741824,
23
- "modified": 1795748400
24
- }
25
- ],
26
- "next": "2"
27
- }
28
- }
@@ -1,22 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- "Home Videos",
6
- "2"
7
- ],
8
- "exchanges": [],
9
- "output": {
10
- "entries": [
11
- {
12
- "type": "file",
13
- "path": "Home Videos/interview.m4a",
14
- "name": "interview.m4a",
15
- "itemId": "Home Videos/interview.m4a",
16
- "media": "audio",
17
- "size": 8388608,
18
- "modified": 1795748400
19
- }
20
- ]
21
- }
22
- }
@@ -1,21 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- "电影"
6
- ],
7
- "exchanges": [],
8
- "output": {
9
- "entries": [
10
- {
11
- "type": "file",
12
- "path": "电影/Big Buck Bunny (2008).mkv",
13
- "name": "Big Buck Bunny (2008).mkv",
14
- "itemId": "电影/Big Buck Bunny (2008).mkv",
15
- "media": "video",
16
- "size": 734003200,
17
- "modified": 1795748400
18
- }
19
- ]
20
- }
21
- }
@@ -1,25 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- ""
6
- ],
7
- "exchanges": [],
8
- "output": {
9
- "entries": [
10
- {
11
- "type": "directory",
12
- "path": "Home Videos",
13
- "name": "Home Videos",
14
- "modified": 1795748400
15
- },
16
- {
17
- "type": "directory",
18
- "path": "电影",
19
- "name": "电影",
20
- "modified": 1795748400
21
- }
22
- ],
23
- "next": "2"
24
- }
25
- }
@@ -1,22 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "list",
4
- "args": [
5
- "",
6
- "2"
7
- ],
8
- "exchanges": [],
9
- "output": {
10
- "entries": [
11
- {
12
- "type": "file",
13
- "path": "trailer.mp4",
14
- "name": "trailer.mp4",
15
- "itemId": "trailer.mp4",
16
- "media": "video",
17
- "size": 52428800,
18
- "modified": 1795748400
19
- }
20
- ]
21
- }
22
- }
@@ -1,74 +0,0 @@
1
- {
2
- "slot": "library",
3
- "call": "changes",
4
- "args": [
5
- null
6
- ],
7
- "exchanges": [],
8
- "output": {
9
- "entries": [
10
- {
11
- "type": "identified",
12
- "item": {
13
- "kind": "movie",
14
- "id": "m1",
15
- "title": "磷虾:起源",
16
- "year": 2024,
17
- "duration": 6120,
18
- "ids": {
19
- "tmdb": "200001",
20
- "imdb": "tt0000001"
21
- },
22
- "image": "https://media.example/posters/m1.jpg",
23
- "versions": [
24
- {
25
- "id": "m1-4k",
26
- "title": "4K HDR",
27
- "filename": "Krill.Origins.2024.2160p.mkv",
28
- "version": {
29
- "width": 3840,
30
- "height": 2160,
31
- "hdr": "dolbyVision",
32
- "videoCodec": "hevc",
33
- "audioCodec": "eac3",
34
- "audioChannels": 6,
35
- "size": 42000000000
36
- }
37
- },
38
- {
39
- "id": "m1-1080",
40
- "title": "1080p",
41
- "filename": "Krill.Origins.2024.1080p.mkv",
42
- "version": {
43
- "width": 1920,
44
- "height": 1080,
45
- "hdr": "sdr",
46
- "videoCodec": "h264",
47
- "audioCodec": "aac",
48
- "audioChannels": 2,
49
- "size": 8000000000
50
- }
51
- }
52
- ]
53
- }
54
- },
55
- {
56
- "type": "identified",
57
- "item": {
58
- "kind": "movie",
59
- "id": "m2",
60
- "title": "磷虾:归途",
61
- "year": 2026,
62
- "duration": 6840,
63
- "version": {
64
- "width": 1920,
65
- "height": 1080,
66
- "videoCodec": "hevc"
67
- }
68
- }
69
- }
70
- ],
71
- "next": "2",
72
- "since": "5"
73
- }
74
- }