Added support for import Invidious subs to Materialious account

This commit is contained in:
WardPearce
2026-02-16 21:02:00 +13:00
parent cfdc32ed8b
commit 19c8ea57b7
3 changed files with 23 additions and 6 deletions
+9 -3
View File
@@ -85,16 +85,22 @@ export async function deleteUnsubscribeBackend(authorId: string) {
});
}
export async function postSubscribeBackend(authorId: string) {
export async function postSubscribeBackend(
authorId: string,
authorName: string | undefined = undefined
) {
const rawKey = await getRawKey();
if (!rawKey) return;
const internalAuthorId = await getInternalAuthorId(authorId, rawKey);
const channel = await getChannelYTjs(authorId);
if (!authorName) {
const channel = await getChannelYTjs(authorId);
authorName = channel.author;
}
const channelId = await encryptWithMasterKey(authorId);
const channelName = await encryptWithMasterKey(channel.author);
const channelName = await encryptWithMasterKey(authorName);
const resp = await fetch(`/api/user/subscriptions/${internalAuthorId}`, {
method: 'POST',
@@ -60,7 +60,7 @@ export async function deleteUnsubscribeYTjs(authorId: string) {
export async function parseChannelRSS(channelId: string): Promise<void> {
const feedUrl = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`;
const response = await fetch(feedUrl);
const response = await fetch(feedUrl, { priority: 'low' });
if (!response.ok) return;
const text = await response.text();
@@ -7,13 +7,16 @@
engineFallbacksStore,
engineMaxConcurrentChannelsStore,
invidiousInstanceStore,
backendInUseStore
backendInUseStore,
rawMasterKeyStore
} from '$lib/store';
import { useEngineFallback, type EngineFallback } from '$lib/api/misc';
import { get } from 'svelte/store';
import { getSubscriptions, postSubscribe } from '$lib/api';
import { postSubscribeYTjs } from '$lib/api/youtubejs/subscriptions';
import { addToast } from '../Toast.svelte';
import { isOwnBackend } from '$lib/shared';
import { postSubscribeBackend } from '$lib/api/backend';
const engineFallbacks: EngineFallback[] = [
'Channel',
@@ -53,9 +56,17 @@
}
});
let subscribeFunction: (id: string, name: string) => Promise<void>;
if (isOwnBackend()?.internalAuth && $rawMasterKeyStore) {
subscribeFunction = postSubscribeBackend;
} else {
subscribeFunction = postSubscribeYTjs;
}
const subPromises: Promise<void>[] = [];
importedSubs.forEach((sub) => {
subPromises.push(postSubscribeYTjs(sub.authorId, sub.author));
subPromises.push(subscribeFunction(sub.authorId, sub.author));
});
await Promise.all(subPromises);