krillplayer-plugin 0.0.0-stage → 0.1.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.
- package/LICENSE +24 -0
- package/README.md +85 -2
- package/bin/krillplayer-plugin.js +13 -0
- package/dist/cli.js +5309 -0
- package/dist/engine/engine.c +140 -0
- package/kernel/Sources/CQuickJS/include/kernel_qjs.h +47 -0
- package/kernel/Sources/CQuickJS/kernel_qjs.c +407 -0
- package/kernel/Sources/CQuickJS/quickjs_vendor.c +8 -0
- package/kernel/Sources/CQuickJS/vendor/LICENSE +24 -0
- package/kernel/Sources/CQuickJS/vendor/builtin-array-fromasync.h +121 -0
- package/kernel/Sources/CQuickJS/vendor/builtin-iterator-zip-keyed.h +313 -0
- package/kernel/Sources/CQuickJS/vendor/builtin-iterator-zip.h +321 -0
- package/kernel/Sources/CQuickJS/vendor/cutils.h +2374 -0
- package/kernel/Sources/CQuickJS/vendor/dtoa.c +1619 -0
- package/kernel/Sources/CQuickJS/vendor/dtoa.h +87 -0
- package/kernel/Sources/CQuickJS/vendor/libregexp-opcode.h +73 -0
- package/kernel/Sources/CQuickJS/vendor/libregexp.c +3530 -0
- package/kernel/Sources/CQuickJS/vendor/libregexp.h +106 -0
- package/kernel/Sources/CQuickJS/vendor/libunicode-table.h +5160 -0
- package/kernel/Sources/CQuickJS/vendor/libunicode.c +2074 -0
- package/kernel/Sources/CQuickJS/vendor/libunicode.h +172 -0
- package/kernel/Sources/CQuickJS/vendor/list.h +107 -0
- package/kernel/Sources/CQuickJS/vendor/quickjs-atom.h +279 -0
- package/kernel/Sources/CQuickJS/vendor/quickjs-c-atomics.h +54 -0
- package/kernel/Sources/CQuickJS/vendor/quickjs-opcode.h +377 -0
- package/kernel/Sources/CQuickJS/vendor/quickjs.c +65536 -0
- package/kernel/Sources/CQuickJS/vendor/quickjs.h +1529 -0
- package/kernel/Sources/Kernel/PluginPrelude.js +312 -0
- package/package.json +35 -4
- package/skill/krillplayer-plugin/SKILL.md +100 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-next-page-passes-the-cursor-back.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-popular-movies.json +48 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-service-unavailable-fails.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-top-rated-series.json +68 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-trending-movies-by-default.json +71 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-unknown-values-fall-back.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/parameters.json +42 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/search-blank.json +11 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/search-movies-first.json +50 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/search-series-after-the-movies.json +50 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/cases/search-series-next-page.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/catalog/plugin.ts +57 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/comments-first-segment.json +77 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/comments-last-segment-stops-at-the-end.json +77 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/comments-past-the-end-empty.json +14 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/comments-segment-covering-the-position.json +77 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/comments-unknown-match-not-found.json +13 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-by-filename-with-spaces.json +34 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-by-filename-without-a-work.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-episode-by-absolute-number.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-episode-by-season-and-number.json +32 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-episode-not-in-the-catalog-empty.json +20 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-movie-by-tmdb-gives-both-cuts.json +34 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-nothing-to-go-on-empty.json +13 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/cases/match-unknown-work-empty.json +18 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/danmaku-tool/plugin.ts +72 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/folder-gone-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/folder-second-page-by-cursor.json +39 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/folder-skips-files-that-are-not-media.json +36 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/folder-with-subfolder-first-page.json +52 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-empty-folder.json +11 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-gone-not-found.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-lists-subfolders-and-media.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-second-page.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-skips-subtitles.json +21 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-root-first-page.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-root-second-page.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/list-cursor-not-a-number-starts-over.json +30 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/list-root-first-page.json +29 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/list-root-second-page.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/nested-folder-carries-ancestors.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/play-file-at-the-root.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/play-file-encodes-each-path-segment.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/play-file-gone-not-found.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/file-share/plugin.ts +192 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-first-page.json +247 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-missing-docs.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-not-json.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-refused.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-second-page.json +248 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-server-error.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/list-skips-incomplete-items.json +225 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/play-about-bananas.json +45 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/play-http-404.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/play-no-video-files.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/play-unknown-id.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/search-bad-request.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/search-bananas.json +247 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/search-blank-query.json +11 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/cases/search-rate-limited.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/manifest.ts +14 -0
- package/skill/krillplayer-plugin/assets/samples/internet-archive/plugin.ts +85 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/channel-creator-next-page.json +99 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/channel-creator-off-air-has-no-live.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/channel-creator-on-air.json +92 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/channel-creator-replays-tab.json +69 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/channel-unknown-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/collection-playlist-around-a-video.json +56 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/collection-playlist.json +78 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/list-live.json +33 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/list-videos-first-page.json +59 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/list-videos-next-page.json +64 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/parameters.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-off-air-not-started.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-replay.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-upcoming-not-started.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-video.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/resolve-channel-link.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/resolve-live-link.json +29 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/resolve-other-site-unclaimed.json +8 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/resolve-playlist-link.json +27 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/resolve-removed-video-unclaimed.json +8 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/resolve-video-link.json +34 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/search-creator-live-playlist-and-videos.json +115 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/search-off-air-room.json +47 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/status-live-id-comes-from-the-plugin.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +123 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-box-set.json +80 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-empty-subfolder.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-folder-has-a-subfolder-and-files.json +53 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-season-around-a-removed-episode-ended.json +15 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-season-around-an-episode.json +67 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-season-episodes.json +89 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-series-lists-seasons.json +79 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-series-next-page.json +54 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/collection-unknown-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-everything-first-page.json +74 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-everything-last-page.json +86 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-nothing-new.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-since-a-token-with-a-removal.json +88 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-ids-first-page.json +15 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-ids-last-page.json +14 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/list-files.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/list-movies-first-page.json +69 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/list-movies-next-page.json +30 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/list-shows.json +27 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/parameters.json +27 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/play-episode.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/play-file-without-duration.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/play-movie-version.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/play-movie.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/play-unknown-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/search-across-kinds.json +81 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/search-blank.json +11 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/media-server/plugin.ts +167 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/album-compilation-has-no-album-artist.json +63 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/album-songs-in-disc-order.json +117 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/artist-lists-albums-and-top-songs.json +103 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/artist-unknown-not-found.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/list-artists.json +32 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/list-newest-albums-first-page.json +51 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/list-past-the-end.json +13 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/list-playlists.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/list-stations-are-channels.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/list-unknown-section-not-found.json +13 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/play-song.json +24 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/play-station.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/play-unknown-not-found.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/playlist-first-page.json +67 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/playlist-next-page.json +48 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/cases/sections-lists-every-kind.json +28 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/music-library/plugin.ts +120 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/folder-gone-not-found.json +60 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/folder-nested-carries-ancestors.json +74 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/folder-second-page-by-cursor.json +88 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/folder-skips-subtitles-and-system-files.json +101 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/folder-without-access-asks-to-log-in.json +60 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-empty-folder.json +60 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-gives-size-and-modified-time.json +78 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-gone-not-found.json +60 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-second-page.json +71 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-a-range.json +62 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-an-info-file.json +62 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-file-gone-not-found.json +62 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-root.json +84 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-source-offline-retryable.json +61 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/list-root-first-page.json +71 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/list-root-next-page-by-the-kernel-cursor.json +83 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/list-root-page-of-only-other-files-still-has-next.json +63 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/list-root.json +96 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/list-source-offline-retryable.json +61 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/list-wrong-account-asks-to-log-in.json +61 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-a-folder-not-found.json +61 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-audio-takes-no-subtitles.json +71 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-file-at-the-root.json +71 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-file-gone-not-found.json +60 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-finds-subtitles-across-pages.json +88 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-lists-subtitles-next-to-the-video.json +87 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-similar-name-takes-only-its-own-subtitles.json +80 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/play-without-access-asks-to-log-in.json +60 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/manifest.ts +13 -0
- package/skill/krillplayer-plugin/assets/samples/network-share/plugin.ts +122 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/channel-around-a-removed-episode-ended.json +15 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/channel-around-an-episode.json +62 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/channel-episodic-newest-first.json +57 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/channel-episodic-next-page.json +42 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/channel-serial-oldest-first.json +57 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/channel-unknown-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/list-first-page.json +32 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/list-past-the-end.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/play-episode.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/play-removed-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/search-next-page.json +47 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/cases/search-shows-and-episodes.json +41 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/podcast/plugin.ts +77 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-episode-by-absolute-number.json +24 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-episode-by-season-and-number.json +26 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-episode-it-does-not-have.json +17 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-movie-by-imdb-only.json +39 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-movie-by-tmdb.json +40 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-movie-ids-win-over-the-title.json +16 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-movie-title-in-another-year-has-none.json +14 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/find-movie-without-ids-by-title-and-year.json +25 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/play-episode-version.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/play-movie-version.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/cases/play-unknown-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/resource-finder/plugin.ts +70 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/fetch-after-login-gives-the-text.json +16 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/fetch-gives-the-text.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/fetch-login-required-without-credentials.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/fetch-unknown-track-not-found.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/login-methods-fields.json +24 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-by-filename-without-a-work.json +34 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-by-hash-gives-only-that-file.json +29 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-episode-by-season-and-number.json +32 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-episode-not-in-the-catalog-empty.json +22 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-hash-wins-over-a-misleading-filename.json +27 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-language-by-primary-subtag.json +24 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-movie-by-tmdb-in-language-order.json +51 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-nothing-to-go-on-empty.json +13 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-unknown-hash-falls-back-to-the-work.json +53 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-unknown-work-empty.json +20 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/cases/search-unwanted-language-empty.json +21 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/subtitle-tool/plugin.ts +104 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/channel-radio-is-audio.json +33 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/channel-station.json +33 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/channel-unknown-ended.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/list-all-stations.json +81 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/list-group.json +37 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/parameters.json +31 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/play-catch-up-is-on-demand.json +23 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/play-future-programme-has-no-catch-up.json +12 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/play-live-two-lines.json +31 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/play-radio.json +31 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/schedule-future-window-has-no-items.json +24 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/schedule-past-programmes-carry-catch-up.json +58 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/schedule-several-stations-in-one-call.json +127 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/schedule-window-without-programmes.json +15 -0
- package/skill/krillplayer-plugin/assets/samples/tv/cases/search-station.json +35 -0
- package/skill/krillplayer-plugin/assets/samples/tv/manifest.ts +12 -0
- package/skill/krillplayer-plugin/assets/samples/tv/plugin.ts +81 -0
- package/skill/krillplayer-plugin/references/cases.md +86 -0
- package/skill/krillplayer-plugin/references/choosing-a-kind.md +69 -0
- package/skill/krillplayer-plugin/references/contract.d.ts +1479 -0
- package/skill/krillplayer-plugin/references/errors-and-fixes.md +117 -0
- package/templates/apple-hls/cases/list-filtered.json +24 -0
- package/templates/apple-hls/cases/list-first-page.json +35 -0
- package/templates/apple-hls/cases/list-last-page.json +25 -0
- package/templates/apple-hls/cases/parameters.json +31 -0
- package/templates/apple-hls/cases/play-bipbop.json +23 -0
- package/templates/apple-hls/cases/play-unknown.json +12 -0
- package/templates/apple-hls/cases/search-blank-query.json +11 -0
- package/templates/apple-hls/cases/search-no-match.json +11 -0
- package/templates/apple-hls/cases/search-title-ignores-case.json +22 -0
- package/templates/apple-hls/manifest.ts +12 -0
- package/templates/apple-hls/plugin.ts +77 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
// 插件代码之前在每个上下文里执行的一段 JS,App 内核(PluginPrelude.swift)与试跑器(plugins/trial-runner/engine.ts)读的是这同一个文件。
|
|
2
|
+
// 它是一个函数表达式,引擎以 (native, utf8Encode, utf8Decode) 调用它(kernel_qjs.h 的 kq_install)。__GLOBALS__ 由两边换成
|
|
3
|
+
// plugins/host/globals.ts 的全局对象清单。它删掉清单外的全局,补上原生实现的 TextEncoder / TextDecoder(只支持 UTF-8),
|
|
4
|
+
// 建好交给插件的 krillplayer,并返回宿主调用插件用的分发函数。与宿主之间的值按 KrillPlayerWire 的线格式传。
|
|
5
|
+
// console.* 接到 krillplayer.log(ADR 0019):log 与 info 记为 info,trace 记为 debug;参数按空格连起来,
|
|
6
|
+
// 错误写成「名字: 说明」,别的不是字符串的先 JSON.stringify,转不了的用 String,再不行写 [unprintable]。
|
|
7
|
+
// 插件改坏这里捕获前的内建只会弄坏它自己:域名与凭证的检查都在宿主一侧。
|
|
8
|
+
(function (native, utf8Encode, utf8Decode) {
|
|
9
|
+
"use strict";
|
|
10
|
+
const allowed = new Set(__GLOBALS__);
|
|
11
|
+
const { stringify, parse } = JSON;
|
|
12
|
+
const { freeze, keys, fromEntries, defineProperty, getOwnPropertyNames, getOwnPropertyDescriptor } = Object;
|
|
13
|
+
const U8 = Uint8Array;
|
|
14
|
+
const Buffer = ArrayBuffer;
|
|
15
|
+
const isView = ArrayBuffer.isView;
|
|
16
|
+
const isArray = Array.isArray;
|
|
17
|
+
const Pending = Promise;
|
|
18
|
+
const Failure = Error;
|
|
19
|
+
const raised = new WeakMap();
|
|
20
|
+
const MARKER = "\u0000";
|
|
21
|
+
|
|
22
|
+
for (const name of getOwnPropertyNames(globalThis)) if (!allowed.has(name)) delete globalThis[name];
|
|
23
|
+
const remaining = getOwnPropertyNames(globalThis).filter((name) => !allowed.has(name));
|
|
24
|
+
if (remaining.length > 0) throw new Error("could not remove globals: " + remaining.join(", "));
|
|
25
|
+
|
|
26
|
+
const UTF8_LABELS = new Set(["unicode-1-1-utf-8", "unicode11utf8", "unicode20utf8", "utf-8", "utf8", "x-unicode20utf8"]);
|
|
27
|
+
|
|
28
|
+
function bytesOf(input) {
|
|
29
|
+
if (input === undefined) return new U8(0);
|
|
30
|
+
if (input instanceof Buffer) return new U8(input);
|
|
31
|
+
if (isView(input)) return new U8(input.buffer, input.byteOffset, input.byteLength);
|
|
32
|
+
throw new TypeError("TextDecoder.decode needs an ArrayBuffer or an ArrayBuffer view");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class TextEncoder {
|
|
36
|
+
get encoding() { return "utf-8"; }
|
|
37
|
+
encode(input = "") { return utf8Encode(String(input)); }
|
|
38
|
+
encodeInto(source, destination) {
|
|
39
|
+
let read = 0;
|
|
40
|
+
let written = 0;
|
|
41
|
+
for (const character of String(source)) {
|
|
42
|
+
const bytes = utf8Encode(character);
|
|
43
|
+
if (written + bytes.length > destination.length) break;
|
|
44
|
+
destination.set(bytes, written);
|
|
45
|
+
written += bytes.length;
|
|
46
|
+
read += character.length;
|
|
47
|
+
}
|
|
48
|
+
return { read, written };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class TextDecoder {
|
|
53
|
+
#fatal;
|
|
54
|
+
#ignoreBOM;
|
|
55
|
+
constructor(label = "utf-8", options = {}) {
|
|
56
|
+
if (!UTF8_LABELS.has(String(label).trim().toLowerCase())) {
|
|
57
|
+
throw new RangeError(`TextDecoder only supports utf-8, not ${label}`);
|
|
58
|
+
}
|
|
59
|
+
this.#fatal = Boolean(options?.fatal);
|
|
60
|
+
this.#ignoreBOM = Boolean(options?.ignoreBOM);
|
|
61
|
+
}
|
|
62
|
+
get encoding() { return "utf-8"; }
|
|
63
|
+
get fatal() { return this.#fatal; }
|
|
64
|
+
get ignoreBOM() { return this.#ignoreBOM; }
|
|
65
|
+
decode(input, options) {
|
|
66
|
+
if (options?.stream) throw new TypeError("TextDecoder does not support stream");
|
|
67
|
+
return utf8Decode(bytesOf(input), this.#fatal, this.#ignoreBOM);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (const [name, value] of [["TextEncoder", TextEncoder], ["TextDecoder", TextDecoder]]) {
|
|
72
|
+
defineProperty(globalThis, name, { value, writable: true, configurable: true });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function encode(message) {
|
|
76
|
+
const parts = [];
|
|
77
|
+
const json = stringify(message, (_key, value) => {
|
|
78
|
+
if (!(value instanceof U8)) return value;
|
|
79
|
+
parts.push(value);
|
|
80
|
+
return { [MARKER]: parts.length - 1 };
|
|
81
|
+
});
|
|
82
|
+
let size = 0;
|
|
83
|
+
for (const part of parts) size += part.length;
|
|
84
|
+
const blob = new U8(size);
|
|
85
|
+
let offset = 0;
|
|
86
|
+
for (const part of parts) {
|
|
87
|
+
blob.set(part, offset);
|
|
88
|
+
offset += part.length;
|
|
89
|
+
}
|
|
90
|
+
return [`[${json ?? "null"},${stringify(parts.map((part) => part.length))}]`, blob];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function revive(value, parts) {
|
|
94
|
+
if (value === null || typeof value !== "object") return value;
|
|
95
|
+
if (isArray(value)) return value.map((item) => revive(item, parts));
|
|
96
|
+
const names = keys(value);
|
|
97
|
+
if (names.length === 1 && names[0] === MARKER) return parts[value[MARKER]];
|
|
98
|
+
return fromEntries(names.map((name) => [name, revive(value[name], parts)]));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function decode(json, blob) {
|
|
102
|
+
const [message, sizes] = parse(json);
|
|
103
|
+
// 没有字节就没有要换回的标记,原样交出:revive 每层要好几帧,深的树(krillplayer.formats.xml 的 64 层)会把栈用完。
|
|
104
|
+
if (sizes.length === 0) return message;
|
|
105
|
+
const parts = [];
|
|
106
|
+
let offset = 0;
|
|
107
|
+
for (const size of sizes) {
|
|
108
|
+
parts.push(blob.slice(offset, offset + size));
|
|
109
|
+
offset += size;
|
|
110
|
+
}
|
|
111
|
+
return revive(message, parts);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function send(message) {
|
|
115
|
+
const [json, blob] = encode(message);
|
|
116
|
+
const reply = native(json, blob);
|
|
117
|
+
return decode(reply[0], reply[1]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const call = (name, args) => send({ op: "call", name, args });
|
|
121
|
+
|
|
122
|
+
// 交给 krillplayer.crypto.subtle 的参数:BufferSource 一律换成 Uint8Array,对象与数组逐层换,别的原样。
|
|
123
|
+
function cryptoBytes(value) {
|
|
124
|
+
if (value instanceof U8) return value;
|
|
125
|
+
if (value instanceof Buffer) return new U8(value);
|
|
126
|
+
if (isView(value)) return new U8(value.buffer, value.byteOffset, value.byteLength);
|
|
127
|
+
if (isArray(value)) return value.map(cryptoBytes);
|
|
128
|
+
if (value !== null && typeof value === "object") return fromEntries(keys(value).map((name) => [name, cryptoBytes(value[name])]));
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const waiting = new Map();
|
|
133
|
+
let nextOperation = 0;
|
|
134
|
+
function start(name, args) {
|
|
135
|
+
const id = nextOperation++;
|
|
136
|
+
const result = new Pending((resolve, reject) => waiting.set(id, { resolve, reject }));
|
|
137
|
+
send({ op: "start", id, name, args });
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const consoleLevels = { debug: "debug", trace: "debug", log: "info", info: "info", warn: "warn", error: "error" };
|
|
142
|
+
function consoleText(value) {
|
|
143
|
+
if (typeof value === "string") return value;
|
|
144
|
+
// 错误照 String 写(JSON.stringify 只得到「{}」);它的 toString 也可能抛,和别的值一样落到占位。
|
|
145
|
+
if (value instanceof Failure) { try { return String(value); } catch { return "[unprintable]"; } }
|
|
146
|
+
try { return stringify(value) ?? String(value); } catch {}
|
|
147
|
+
try { return String(value); } catch { return "[unprintable]"; }
|
|
148
|
+
}
|
|
149
|
+
const consoleMethod = (level) => (...args) => { call("log", [level, args.map(consoleText).join(" ")]); };
|
|
150
|
+
const consoleObject = freeze(fromEntries(keys(consoleLevels).map((name) => [name, consoleMethod(consoleLevels[name])])));
|
|
151
|
+
defineProperty(globalThis, "console", { value: consoleObject, writable: true, configurable: true });
|
|
152
|
+
|
|
153
|
+
const krillplayer = freeze({
|
|
154
|
+
http: freeze({ request: (request) => start("http.request", [request]) }),
|
|
155
|
+
decompress: async (format, data) => call("decompress", [format, data]),
|
|
156
|
+
crypto: freeze({
|
|
157
|
+
randomBytes: (length) => call("crypto.randomBytes", [length]),
|
|
158
|
+
digest: async (algorithm, data) => call("crypto.digest", [algorithm, data]),
|
|
159
|
+
// contract.md 6.3.1:检查与计算都在宿主一侧,这里只把 ArrayBuffer 与别的视图换成线格式认得的 Uint8Array。
|
|
160
|
+
subtle: freeze(fromEntries(["generateKey", "importKey", "exportKey", "sign", "verify", "encrypt", "decrypt", "digest",
|
|
161
|
+
"deriveBits", "deriveKey", "wrapKey", "unwrapKey"]
|
|
162
|
+
.map((name) => [name, async (...args) => call("crypto.subtle." + name, args.map(cryptoBytes))]))),
|
|
163
|
+
}),
|
|
164
|
+
formats: freeze({
|
|
165
|
+
m3u: async (data) => call("formats.m3u", [data]),
|
|
166
|
+
rss: (data) => call("formats.rss", [data]),
|
|
167
|
+
xml: (data) => call("formats.xml", [data]),
|
|
168
|
+
xmltv: freeze({
|
|
169
|
+
channels: async (source) => start("formats.xmltv.channels", [source]),
|
|
170
|
+
programmes: async (source, query) => start("formats.xmltv.programmes", [source, query]),
|
|
171
|
+
}),
|
|
172
|
+
}),
|
|
173
|
+
metadata: freeze({
|
|
174
|
+
search: async (kind, query, options) => start("metadata.search", [kind, query, options ?? null]),
|
|
175
|
+
get: async (kind, ids) => start("metadata.get", [kind, ids]),
|
|
176
|
+
list: async (name, kind, options) => start("metadata.list", [name, kind, options ?? null]),
|
|
177
|
+
}),
|
|
178
|
+
files: freeze({
|
|
179
|
+
list: async (path, cursor) => start("files.list", [path, cursor ?? null]),
|
|
180
|
+
stat: async (path) => start("files.stat", [path]),
|
|
181
|
+
read: async (path, offset, length) => start("files.read", [path, offset, length]),
|
|
182
|
+
playable: (path) => call("files.playable", [path]),
|
|
183
|
+
}),
|
|
184
|
+
log: (level, message) => {
|
|
185
|
+
call("log", [level, String(message)]);
|
|
186
|
+
},
|
|
187
|
+
cache: freeze({
|
|
188
|
+
get: (key) => {
|
|
189
|
+
const json = call("cache.get", [String(key)]);
|
|
190
|
+
return json === null ? null : parse(json);
|
|
191
|
+
},
|
|
192
|
+
set: (key, value, ttlSeconds) => {
|
|
193
|
+
const json = stringify(value);
|
|
194
|
+
if (json === undefined) throw new TypeError("krillplayer.cache only stores JSON values");
|
|
195
|
+
call("cache.set", [String(key), json, ttlSeconds]);
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
storage: freeze({
|
|
199
|
+
get: (key) => call("storage.get", [String(key)]),
|
|
200
|
+
set: (key, value) => {
|
|
201
|
+
if (typeof value !== "string") throw new TypeError("krillplayer.storage only stores strings");
|
|
202
|
+
call("storage.set", [String(key), value]);
|
|
203
|
+
},
|
|
204
|
+
delete: (key) => {
|
|
205
|
+
call("storage.delete", [String(key)]);
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
208
|
+
credentials: freeze({
|
|
209
|
+
get: () => call("credentials.get", []),
|
|
210
|
+
set: (values, options) => {
|
|
211
|
+
call("credentials.set", [values, options ?? null]);
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
parameters: freeze({ get: () => call("parameters.get", []) }),
|
|
215
|
+
// App 自己的密钥(#617):只有预装插件、只有清单 appKeys 写了的名字拿得到,别的都是 null。名字由宿主检查。
|
|
216
|
+
appKeys: freeze({ get: async (name) => start("appKeys.get", [name]) }),
|
|
217
|
+
// 词典与当前界面语言在宿主一侧(contract.md 第 5 节)。参数原样交过去,检查与报错由宿主做。
|
|
218
|
+
i18n: (text, values, context) => call("i18n", [text, values ?? null, context ?? null]),
|
|
219
|
+
get locale() { return call("locale", []); },
|
|
220
|
+
error: (kind, message) => {
|
|
221
|
+
const text = message === undefined ? undefined : String(message);
|
|
222
|
+
const error = new Failure(text ?? String(kind));
|
|
223
|
+
raised.set(error, { kind: String(kind), message: text });
|
|
224
|
+
return error;
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// 宿主的操作失败时带了契约的错误种类(krillplayer.files 的 notFound、loginRequired、retryable):插件不接住它,
|
|
229
|
+
// 这次调用就按这个种类失败,说明由内核按种类给,不带宿主的报错文本。
|
|
230
|
+
function hostFailure(kind, text) {
|
|
231
|
+
const error = new Failure(text);
|
|
232
|
+
raised.set(error, { kind: String(kind) });
|
|
233
|
+
return error;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function describe(error) {
|
|
237
|
+
try {
|
|
238
|
+
return error instanceof Error ? String(error.message) : String(error);
|
|
239
|
+
} catch {
|
|
240
|
+
return "the plugin threw a value that cannot be described";
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async function settle(id, run) {
|
|
245
|
+
let reply;
|
|
246
|
+
try {
|
|
247
|
+
reply = encode({ op: "settled", call: id, ok: true, value: await run() });
|
|
248
|
+
} catch (error) {
|
|
249
|
+
const structured = raised.get(error);
|
|
250
|
+
reply = encode({ op: "settled", call: id, ok: false, error: describe(error), kind: structured?.kind, message: structured?.message });
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
native(reply[0], reply[1]);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
// 宿主不收这个结果(嵌套过深,#442):这次调用按宿主的报错失败,不悬着。
|
|
256
|
+
const refused = encode({ op: "settled", call: id, ok: false, error: describe(error) });
|
|
257
|
+
native(refused[0], refused[1]);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// A slot function is an own data property of the slot object: no prototype chain, no getters,
|
|
262
|
+
// nothing a Proxy get trap makes up. Same rule as slotMember in plugins/contract/contract.ts, which the packer uses.
|
|
263
|
+
function slotFunction(slot, functionName) {
|
|
264
|
+
if ((typeof slot !== "object" && typeof slot !== "function") || slot === null) return undefined;
|
|
265
|
+
const descriptor = getOwnPropertyDescriptor(slot, functionName);
|
|
266
|
+
return descriptor !== undefined && "value" in descriptor && typeof descriptor.value === "function" ? descriptor.value : undefined;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function invoke(namespace, slotName, functionName, args) {
|
|
270
|
+
// An empty function name is a top-level export (resolve), which belongs to no slot.
|
|
271
|
+
const slot = namespace?.[slotName];
|
|
272
|
+
if (functionName === "") {
|
|
273
|
+
if (typeof slot !== "function") throw new TypeError(`plugin has no ${slotName}`);
|
|
274
|
+
return slot(krillplayer, ...args);
|
|
275
|
+
}
|
|
276
|
+
const method = slotFunction(slot, functionName);
|
|
277
|
+
if (method === undefined) throw new TypeError(`plugin has no ${slotName}.${functionName}`);
|
|
278
|
+
return method.call(slot, krillplayer, ...args);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function invokeKrillPlayer(path, args) {
|
|
282
|
+
const names = path.split(".");
|
|
283
|
+
let owner = krillplayer;
|
|
284
|
+
for (const name of names.slice(0, -1)) owner = owner?.[name];
|
|
285
|
+
const method = owner?.[names[names.length - 1]];
|
|
286
|
+
// 不是函数的成员(locale)按读取处理。
|
|
287
|
+
if (typeof method === "string" && args.length === 0) return method;
|
|
288
|
+
if (typeof method !== "function") throw new TypeError(`krillplayer.${path} does not exist`);
|
|
289
|
+
return method.apply(owner, args);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return function dispatch(json, blob, namespace) {
|
|
293
|
+
const message = decode(json, blob);
|
|
294
|
+
if (message.op === "invoke") {
|
|
295
|
+
settle(message.call, () => invoke(namespace, message.slot, message.function, message.args));
|
|
296
|
+
} else if (message.op === "exports") {
|
|
297
|
+
settle(message.call, () => message.function === "" ? typeof namespace?.[message.slot] === "function"
|
|
298
|
+
: slotFunction(namespace?.[message.slot], message.function) !== undefined);
|
|
299
|
+
} else if (message.op === "krillplayer") {
|
|
300
|
+
settle(message.call, async () => {
|
|
301
|
+
const value = await invokeKrillPlayer(message.path, message.args);
|
|
302
|
+
if (message.raise) throw value;
|
|
303
|
+
return value;
|
|
304
|
+
});
|
|
305
|
+
} else if (message.op === "resolve") {
|
|
306
|
+
const operation = waiting.get(message.id);
|
|
307
|
+
waiting.delete(message.id);
|
|
308
|
+
if (message.ok) operation?.resolve(message.value);
|
|
309
|
+
else operation?.reject(typeof message.kind === "string" ? hostFailure(message.kind, message.error) : new TypeError(message.error));
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "krillplayer-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Write, pack, record and test KrillPlayer source plugins on the App's own QuickJS-ng engine, with an AI skill.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://krillplayer.kami.asia",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.18.0"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"krillplayer-plugin": "bin/krillplayer-plugin.js"
|
|
13
|
+
},
|
|
14
|
+
"types": "skill/krillplayer-plugin/references/contract.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./skill/krillplayer-plugin/references/contract.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"dist",
|
|
24
|
+
"kernel",
|
|
25
|
+
"templates",
|
|
26
|
+
"skill",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"esbuild": "0.28.2",
|
|
32
|
+
"eslint": "9.39.5"
|
|
33
|
+
},
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"@krillplayer/plugin-engine-darwin-arm64": "0.1.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: krillplayer-plugin
|
|
3
|
+
description: 写、改或修 KrillPlayer 的来源插件:选内容的种类、照契约写 plugin.ts 与 manifest.ts、录用例、在 App 同一份引擎上试跑、跑 check 直到通过。用于从零写一个新来源、给插件加槽位、修平台接口变了导致的失效、读懂试跑器的报错。
|
|
4
|
+
license: 与 npm 包 krillplayer-plugin 相同,见它的 package.json
|
|
5
|
+
compatibility: 需要 Node 22.18 以上与 npm 包 krillplayer-plugin;Apple 芯片的 Mac 以外还要 C 编译器(cc)。录制要能访问来源的服务。
|
|
6
|
+
metadata:
|
|
7
|
+
contract-revision: "2"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 写 KrillPlayer 插件
|
|
11
|
+
|
|
12
|
+
插件是一个来源的适配器:App 按槽位调用它,它经 `krillplayer.*` 发请求,返回契约里的对象。这份 Skill 管的是一条循环:**定范围 → 写 → 录用例 → 试跑 → check**。每一步有完成判据,判据满足了才进下一步。
|
|
13
|
+
|
|
14
|
+
所有命令在插件目录里跑,命令是 `npx krillplayer-plugin <命令>`。`npx krillplayer-plugin --help` 列出全部命令,`npx krillplayer-plugin <命令> --help` 列出那个命令的参数。
|
|
15
|
+
|
|
16
|
+
| 要查的 | 在哪 |
|
|
17
|
+
|---|---|
|
|
18
|
+
| 槽位的函数签名、每个返回类型的字段、`krillplayer` 对象、清单字段、运行时上限 | [references/contract.d.ts](references/contract.d.ts)(契约的唯一出处,生成的) |
|
|
19
|
+
| 一样内容该写成哪个种类 | [references/choosing-a-kind.md](references/choosing-a-kind.md) |
|
|
20
|
+
| 某条报错什么意思、怎么改 | [references/errors-and-fixes.md](references/errors-and-fixes.md) |
|
|
21
|
+
| 用例文件怎么写、怎么录、失败情形怎么造 | [references/cases.md](references/cases.md) |
|
|
22
|
+
| 照着改的样例:媒体服务器、文件类来源(`file-share` 用 `krillplayer.formats.xml` 解 WebDAV 的目录,`network-share` 经 `krillplayer.files` 让 App 替它读 SMB 共享)、既直播又发视频的平台、电视、播客、弹幕工具(`danmaku.match` 与 `comments`)、字幕工具(`subtitles.search` 与 `fetch`)、资源插件(`resources.find`:按作品回答有没有可播的版本)、目录插件(只导出 `browse`,作品清单经 `krillplayer.metadata` 查),数据都写在插件里、不出网 | `assets/samples/<样例>/`:`plugin.ts`、`manifest.ts`、`cases/` |
|
|
23
|
+
| 出网的样例:`krillplayer.http.request`、解 JSON、HTTP 状态到错误种类、录下来的 `exchanges`、手工造的失败用例 | `assets/samples/internet-archive/` |
|
|
24
|
+
|
|
25
|
+
## 0. 起点
|
|
26
|
+
|
|
27
|
+
还没有插件目录时:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npx krillplayer-plugin new <目录> --id <反写域名,如 com.example.mysource> --name "<显示名>"
|
|
31
|
+
cd <目录> && npm install && npx krillplayer-plugin check
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`new` 照模板建好 `plugin.ts`、`manifest.ts`、`cases/`、`package.json`、`tsconfig.json`,它本身就能 check 通过。模板是 Apple 的公开 HLS 示例流,你要把它整个换成自己的来源;跑通一次 check 只是为了确认环境没问题。
|
|
35
|
+
|
|
36
|
+
完成判据:`check` 的最后一行是 `PASS check`。
|
|
37
|
+
|
|
38
|
+
## 1. 定范围
|
|
39
|
+
|
|
40
|
+
先弄清来源有什么,再动代码:
|
|
41
|
+
|
|
42
|
+
- **种类**:照 [choosing-a-kind.md](references/choosing-a-kind.md) 的问题按顺序问,给来源里的每样东西定一个种类(频道、合集、条目各自的哪一种)。哪个都不像时不要硬套。
|
|
43
|
+
- **槽位**:大多数来源导出 `browse`(`list` 必须有,`search`、`channel`、`collection`、`schedule` 按需)与 `play`(`start`);认分享链接导出顶层的 `resolve`;开播状态导出 `status`;要登录导出 `login`。列不出全部内容、只能按作品去问的来源导出 `resources`(`find`,返回版本,不是条目;列得出全部内容的导出 `library`,两样不能都导出)。只给作品清单(榜单)的目录插件只导出 `browse`,电影与剧集带上外部 `ids`,App 就把它们当作品,版本由别的来源给。函数名与参数只照 `contract.d.ts` 里的 `BrowseSlot`、`PlaySlot` 等接口写。
|
|
44
|
+
- **App 尚未使用**:`contract.d.ts` 里行尾注释标着「App 尚未使用」的函数与字段,契约里已经有了,这一版的 App 还没接上:导出了这类函数,打包与试跑照常通过,但会打一条 `WARN`,App 不会调它;这类字段给了也不会被读。先把标注之外的做好,标注的按来源有的给,别为了它们改种类或 id。
|
|
45
|
+
- **id**:每个频道、合集、条目的 id 由你定,要稳定(之后改 id 等于让用户的订阅、收藏、续播全部失效)。同一来源里能起播的 id 不重复;直播条目的 id 也由你给。
|
|
46
|
+
- **主机**:插件自己经 `krillplayer.http.request` 发的请求只能去清单 `hosts` 里的主机,按主机名精确匹配,不分大小写,不看端口,**不含子域名**(`api.example.com` 与 `example.com` 要分别写),重定向的每一跳都查。`hosts` 只管插件自己的请求:`play.start` 交给播放器的流地址、`image` 等图片地址不用写进去,播放器拉流时的重定向也不查。用户自己填的服务器地址:声明 `userProvidedURLs: true`,并在 `parameters` 里声明一个 `kind: "url"` 的实例参数。
|
|
47
|
+
- **图片地址**:公网的只取 https(给 http 时改成 https 取),局域网与本机的只在它就是用户填的那台主机时才取,按用户填的协议。App 按「来源实例、去掉尺寸参数后的地址、尺寸档」缓存图片;地址里每次都变的令牌或盐(例如 Subsonic 的 `t`、`s`,Emby 的 `api_key`)写进清单的 `imageCacheIgnoredParameters`,换了令牌仍命中同一份缓存。
|
|
48
|
+
- **失败**:每种失败应答(不存在、要登录、地区限制、还没开始、已结束、被拒、暂时失败)给哪个 `PluginErrorKind`。
|
|
49
|
+
|
|
50
|
+
完成判据:对每个要导出的函数,说得出它的入参、返回类型名、每种失败抛哪个 kind;id 的写法定下来;`hosts` 列全。
|
|
51
|
+
|
|
52
|
+
## 2. 写
|
|
53
|
+
|
|
54
|
+
- `plugin.ts` 只导出槽位对象与 `resolve`,每个槽位写成对象字面量并 `satisfies <槽位>Slot`,辅助函数不导出。类型从包里 import:`import type { BrowseSlot, Entry, PlaySlot } from "krillplayer-plugin";`。插件不能在运行时 import 任何东西,只有 `import type`。
|
|
55
|
+
- `manifest.ts` 只写元数据:`export default { … } satisfies Omit<PluginManifest, "capabilities">`。`interfaceLevel` 与 `contractRevision` 写成 `contract.d.ts` 里 `InterfaceLevel`、`ContractRevision` 的字面量。能力(`capabilities`)由打包器按导出生成,不手写。
|
|
56
|
+
- 插件里没有 `fetch`、`setTimeout`、`URL`、`URLSearchParams`、`atob`、`Buffer`、`Intl`:出网用 `krillplayer.http.request`,应答的 `body` 是字节,文本用 `new TextDecoder().decode(response.body)`,JSON 再 `JSON.parse`。地址用字符串拼,查询参数用 `encodeURIComponent`。
|
|
57
|
+
- 来源返回的东西一律当不可信输入:字段缺失、类型不对、列表为空都给出确定的结果(跳过这一项,或 `throw krillplayer.error(kind, message)`),不让读 `undefined` 属性的 `TypeError` 冒出去变成 `other`。
|
|
58
|
+
- 自己起名、给人看的字符串(清单的名字、参数标题与选项、运行时返回的标题)写原文,`manifest.ts` 写 `language`(原文的语言);译文放插件目录的 `locales/<语言标签>.json`,每个文件一张「原文 → 译文」的表。运行时返回的标题用 `krillplayer.i18n("共 {count} 集", { count })` 翻,同一句原文两处意思不同时给第三个参数 `context`、键写成 `原文|context`;不做复数变形。译文的占位符要与原文一致,全部词典合计不超过 256 KiB。来源给的内容(节目标题、简介)不翻。
|
|
59
|
+
- 翻页一律用游标:`list` 等函数收 `cursor`,返回 `{ entries, next? }`;`next` 的内容由你定(页码、偏移、来源给的令牌都行),还有下一页才给。条目已经按播放顺序排好,App 不重排。
|
|
60
|
+
- 只写契约里有的字段。每个种类只带属于它的字段,必填的都给;数字字段给数字不给字符串;时刻是 Unix 秒,时长是秒。
|
|
61
|
+
- 导出了 `status` 的插件:状态槽位只能用 `http`、`decompress`、`crypto`、`formats`、`log`、`cache`、`credentials.get`、`parameters`、`error`;整个包不出现 `eval` 与 `new Function`。一批频道里单个查不了时在那个频道的结果里报,整批都查不了才抛。
|
|
62
|
+
|
|
63
|
+
完成判据:`npx krillplayer-plugin bundle` 打出 `dist/<目录名>.zip`,没有报错。
|
|
64
|
+
|
|
65
|
+
## 3. 录用例
|
|
66
|
+
|
|
67
|
+
用例是这条循环的核心:试跑与 App 的内核测试跑的是 `cases/` 里同一批文件。一个文件一条,名字写成 `<调用>-<情形>.json`。格式与录法见 [references/cases.md](references/cases.md)。
|
|
68
|
+
|
|
69
|
+
- 正常情形从真实来源录:`npx krillplayer-plugin record --slot browse --call list --args '[{}]' --out cases/list-first-page.json`。录下的 `output` 是插件这次的回答,不是正确答案:拿来源的网页或官方客户端对照条目数、标题、id、在播与否、翻页标记,对不上就改插件、重新录。
|
|
70
|
+
- 来源能稳定触发的失败(不存在的 id、下架的条目)直接录:插件 `throw krillplayer.error(…)` 时 `record` 写出带 `error` 的用例。录不到的(限流、服务器出错、格式变了):复制一条录好的用例,改 `exchanges` 里的应答(HTTP 状态、错误码、空列表、缺字段),删掉 `output`,写上期望的 `error`。
|
|
71
|
+
- 来源不能出网访问时(没有账号、离线写样例),照 cases.md 手写 `exchanges`:请求的方法、地址、正文与插件发出的逐字节相同,应答写你从文档里知道的样子。
|
|
72
|
+
|
|
73
|
+
完成判据:每个导出的函数至少一条正常用例;代码里每一处 `throw krillplayer.error(…)` 都有一条用例走到它;每个用例目录里的文件都通过下一步。
|
|
74
|
+
|
|
75
|
+
## 4. 试跑
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npx krillplayer-plugin trial
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
它先打包,再用 `cases/` 在与 App 同一份 QuickJS-ng 引擎上跑产物:栈深、内存与 20 秒时限都与 App 相同。每条用例先按契约检查返回值,再与 `output` 比对。读 `FAIL` 行下面缩进的原因,在 [errors-and-fixes.md](references/errors-and-fixes.md) 里找对应的改法。`contract:` 开头的行写着出错的位置(例如 `output.entries[0].item.duration`)与 `fix:`,照它改。
|
|
82
|
+
|
|
83
|
+
改代码后每次都重新跑 `trial`,它总是先重新打包。
|
|
84
|
+
|
|
85
|
+
完成判据:最后一行是 `passed <n> skipped 0 failed 0`,`n` 等于用例数。
|
|
86
|
+
|
|
87
|
+
## 5. check
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npx krillplayer-plugin check
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
依次做类型检查(`tsc`)、打包、试跑全部用例、扫描用例里有没有留下凭证。最后一行是 `PASS check` 才算完。
|
|
94
|
+
|
|
95
|
+
试跑器不播放媒体。导出了 `play` 的插件,把它装进 App 起播一个真实存在的条目,画面或声音出来才算真的能用。
|
|
96
|
+
|
|
97
|
+
## 交出去之前
|
|
98
|
+
|
|
99
|
+
- 凭证不进仓库:录制时用 `--credentials <文件>`,文件放在插件目录外,录完删掉。工具把凭证换成 `REDACTED`,扫描还有发现就不写文件。
|
|
100
|
+
- 插件的发布、加密与 App 的立场写在 `node_modules/krillplayer-plugin/README.md` 的「发布」一节。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slot": "browse",
|
|
3
|
+
"call": "list",
|
|
4
|
+
"args": [
|
|
5
|
+
{
|
|
6
|
+
"list": "trending",
|
|
7
|
+
"kind": "movie"
|
|
8
|
+
},
|
|
9
|
+
"2"
|
|
10
|
+
],
|
|
11
|
+
"exchanges": [],
|
|
12
|
+
"metadata": [
|
|
13
|
+
{
|
|
14
|
+
"request": {
|
|
15
|
+
"call": "list",
|
|
16
|
+
"name": "trending",
|
|
17
|
+
"kind": "movie",
|
|
18
|
+
"cursor": "2"
|
|
19
|
+
},
|
|
20
|
+
"reply": {
|
|
21
|
+
"entries": []
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"output": {
|
|
26
|
+
"entries": []
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slot": "browse",
|
|
3
|
+
"call": "list",
|
|
4
|
+
"args": [
|
|
5
|
+
{
|
|
6
|
+
"list": "popular",
|
|
7
|
+
"kind": "movie"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"exchanges": [],
|
|
11
|
+
"metadata": [
|
|
12
|
+
{
|
|
13
|
+
"request": {
|
|
14
|
+
"call": "list",
|
|
15
|
+
"name": "popular",
|
|
16
|
+
"kind": "movie"
|
|
17
|
+
},
|
|
18
|
+
"reply": {
|
|
19
|
+
"entries": [
|
|
20
|
+
{
|
|
21
|
+
"kind": "movie",
|
|
22
|
+
"ids": {
|
|
23
|
+
"tmdb": "200003"
|
|
24
|
+
},
|
|
25
|
+
"title": "冰架之下",
|
|
26
|
+
"year": 2023
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"output": {
|
|
33
|
+
"entries": [
|
|
34
|
+
{
|
|
35
|
+
"type": "item",
|
|
36
|
+
"item": {
|
|
37
|
+
"kind": "movie",
|
|
38
|
+
"id": "movie-200003",
|
|
39
|
+
"title": "冰架之下",
|
|
40
|
+
"ids": {
|
|
41
|
+
"tmdb": "200003"
|
|
42
|
+
},
|
|
43
|
+
"year": 2023
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
package/skill/krillplayer-plugin/assets/samples/catalog/cases/list-service-unavailable-fails.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slot": "browse",
|
|
3
|
+
"call": "list",
|
|
4
|
+
"args": [
|
|
5
|
+
{}
|
|
6
|
+
],
|
|
7
|
+
"exchanges": [],
|
|
8
|
+
"metadata": [
|
|
9
|
+
{
|
|
10
|
+
"request": {
|
|
11
|
+
"call": "list",
|
|
12
|
+
"name": "trending",
|
|
13
|
+
"kind": "movie"
|
|
14
|
+
},
|
|
15
|
+
"error": "unavailable"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"error": {
|
|
19
|
+
"kind": "retryable",
|
|
20
|
+
"message": "影视资料暂时查不到:krillplayer.metadata is not available in this host"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"slot": "browse",
|
|
3
|
+
"call": "list",
|
|
4
|
+
"args": [
|
|
5
|
+
{
|
|
6
|
+
"list": "topRated",
|
|
7
|
+
"kind": "series"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"exchanges": [],
|
|
11
|
+
"metadata": [
|
|
12
|
+
{
|
|
13
|
+
"request": {
|
|
14
|
+
"call": "list",
|
|
15
|
+
"name": "topRated",
|
|
16
|
+
"kind": "series"
|
|
17
|
+
},
|
|
18
|
+
"reply": {
|
|
19
|
+
"entries": [
|
|
20
|
+
{
|
|
21
|
+
"kind": "series",
|
|
22
|
+
"ids": {
|
|
23
|
+
"tmdb": "100001"
|
|
24
|
+
},
|
|
25
|
+
"title": "深海来信",
|
|
26
|
+
"year": 2025,
|
|
27
|
+
"image": "https://images.example/p/letters.jpg"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"kind": "series",
|
|
31
|
+
"ids": {
|
|
32
|
+
"tmdb": "100004"
|
|
33
|
+
},
|
|
34
|
+
"title": "潮汐站"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"output": {
|
|
41
|
+
"entries": [
|
|
42
|
+
{
|
|
43
|
+
"type": "collection",
|
|
44
|
+
"collection": {
|
|
45
|
+
"kind": "series",
|
|
46
|
+
"id": "series-100001",
|
|
47
|
+
"title": "深海来信",
|
|
48
|
+
"ids": {
|
|
49
|
+
"tmdb": "100001"
|
|
50
|
+
},
|
|
51
|
+
"year": 2025,
|
|
52
|
+
"image": "https://images.example/p/letters.jpg"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"type": "collection",
|
|
57
|
+
"collection": {
|
|
58
|
+
"kind": "series",
|
|
59
|
+
"id": "series-100004",
|
|
60
|
+
"title": "潮汐站",
|
|
61
|
+
"ids": {
|
|
62
|
+
"tmdb": "100004"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
}
|