Files
jellyfin-plugin-floatplane/doc/research/reference-sources/fpdl_subscriptionFetching.ts
claude 9e33a343ab
Some checks failed
release / build-release (push) Has been cancelled
Floatplane channel plugin for Jellyfin 10.10.x: browse, HLS proxy, cookie session, CI release
- IChannel: creators -> sub-channels -> video posts (public listing API, search mapped)
- IRequiresMediaInfoCallback -> signed proxy URLs; stream controller rewrites HLS so the
  AES-128 key is fetched server-side with the session cookie, segments stay on the CDN
- delivery/info cached per token lifetime and throttled (~2/min)
- config page: paste sails.sid + validate, extra creators, quality, search test
- scripts/package.sh -> plugin folder + zip + md5 + manifest.json; Gitea release workflow
- research docs, HAR analysis (HAR itself gitignored), install-pi5.sh

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-25 09:42:27 +01:00

59 lines
2.4 KiB
TypeScript

import type { CreatorChannel } from "floatplane/creator";
import { defaultSubChannels } from "./lib/defaults";
import { fApi, settings } from "./lib/helpers/index";
import Subscription from "./lib/Subscription";
import chalk from "chalk-template";
export async function* fetchSubscriptions() {
const seenChannels = new Set<string>();
console.log("Fetching user subscriptions...");
for (const userSubscription of await fApi.user.subscriptions()) {
// Add the subscription to settings if it doesnt exist
settings.subscriptions[userSubscription.creator] ??= {
creatorId: userSubscription.creator,
plan: userSubscription.plan.title,
skip: false,
channels: defaultSubChannels[userSubscription.creator] ?? [],
};
const settingSubscription = settings.subscriptions[userSubscription.creator];
// Make sure that new subchannels from defaults are added to settings
if (defaultSubChannels[userSubscription.creator] !== undefined) {
const channelsToAdd = defaultSubChannels[userSubscription.creator].filter(
(channel) => settingSubscription.channels.findIndex((chan) => chan.title === channel.title) === -1
);
if (channelsToAdd.length > 0) settingSubscription.channels = [...settingSubscription.channels, ...channelsToAdd];
}
console.log(chalk`Fetching {yellow ${userSubscription.plan.title}'s} channels...`);
const subChannels = await fApi.creator.channels([userSubscription.creator]);
for (const channel of subChannels) {
if (seenChannels.has(channel.id)) return;
seenChannels.add(channel.id);
const subChannel = settingSubscription.channels.find((chan) => chan.title === channel.title);
const channelDefaults = subChannelDefaults(channel);
if (subChannel === undefined) {
settingSubscription.channels.push(channelDefaults);
} else if (subChannel.isChannel === undefined) {
// @ts-expect-error Identifiers have been replaced by isChannel
delete subChannel.identifiers;
subChannel.isChannel = channelDefaults.isChannel;
}
}
if (settingSubscription.skip === true) continue;
yield new Subscription(settings.subscriptions[userSubscription.creator]);
}
}
export const subChannelDefaults = (channel: CreatorChannel) => ({
title: channel.title,
skip: false,
isChannel:
channel.id === "6413623f5b12cca228a28e78"
? `(post, video) => isChannel(post, '${channel.id}') && !video?.title?.toLowerCase().startsWith('caption')`
: `(post) => isChannel(post, '${channel.id}')`,
});