feedkeeper 0.46.1 → 0.47.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/package.json +1 -1
- package/server/dist/api/feeds.js +1 -0
- package/server/dist/api/v1/resources.js +1 -0
- package/server/dist/db/migrations/0050_feed_media_metadata.sql +5 -0
- package/server/dist/feeds/feedParser.js +69 -3
- package/server/dist/feeds/poller.js +61 -9
- package/server/dist/feeds/repository.js +9 -1
- package/server/dist/feeds/service.js +4 -1
- package/server/dist/sync/changeLog.js +5 -0
- package/server/package.json +1 -1
- package/web/dist/assets/index-CL74vLI6.js +113 -0
- package/web/dist/assets/index-DcSwZh8j.css +2 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-C-Cqi_Uh.js +0 -113
- package/web/dist/assets/index-CAofPYDH.css +0 -2
package/package.json
CHANGED
package/server/dist/api/feeds.js
CHANGED
|
@@ -138,6 +138,7 @@ const updateSchema = z.object({
|
|
|
138
138
|
folderId: z.number().int().positive().nullable().optional(),
|
|
139
139
|
pollIntervalMinutes: z.number().int().positive().max(10080).optional(),
|
|
140
140
|
fullTextMode: z.enum(["auto", "never"]).optional(),
|
|
141
|
+
kindOverride: z.enum(["article", "audio", "video"]).nullable().optional(),
|
|
141
142
|
notify: z.boolean().optional(),
|
|
142
143
|
badge: z.boolean().optional(),
|
|
143
144
|
});
|
|
@@ -117,6 +117,7 @@ const updateSchema = z.object({
|
|
|
117
117
|
folderId: z.number().int().positive().nullable().optional(),
|
|
118
118
|
pollIntervalMinutes: z.number().int().positive().max(10080).optional(),
|
|
119
119
|
fullTextMode: z.enum(["auto", "never"]).optional(),
|
|
120
|
+
kindOverride: z.enum(["article", "audio", "video"]).nullable().optional(),
|
|
120
121
|
notify: z.boolean().optional(),
|
|
121
122
|
badge: z.boolean().optional(),
|
|
122
123
|
});
|
|
@@ -5,13 +5,14 @@ import { unwrapRedirectLink } from "./redirectLinks.js";
|
|
|
5
5
|
import { decodeEntities, plainTitle } from "./text.js";
|
|
6
6
|
const xmlParser = new Parser({
|
|
7
7
|
customFields: {
|
|
8
|
-
feed: ["icon"],
|
|
8
|
+
feed: ["icon", "itunes:image"],
|
|
9
9
|
item: [
|
|
10
10
|
["media:content", "mediaContent", { keepArray: false }],
|
|
11
11
|
["media:thumbnail", "mediaThumbnail", { keepArray: false }],
|
|
12
12
|
["media:group", "mediaGroup", { keepArray: false }],
|
|
13
13
|
["content:encoded", "contentEncoded", { keepArray: false }],
|
|
14
14
|
["itunes:duration", "itunesDuration", { keepArray: false }],
|
|
15
|
+
["itunes:image", "itunesImage", { keepArray: false }],
|
|
15
16
|
["podcast:chapters", "podcastChapters", { keepArray: false }],
|
|
16
17
|
],
|
|
17
18
|
},
|
|
@@ -267,7 +268,17 @@ function extractXmlImageUrl(item) {
|
|
|
267
268
|
return grouped;
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
|
-
// 3.
|
|
271
|
+
// 3. itunes:image on episode level
|
|
272
|
+
const itunesImage = item.itunesImage ?? item["itunes:image"];
|
|
273
|
+
const itunesHref = isRecord(itunesImage)
|
|
274
|
+
? asNonEmptyString(isRecord(itunesImage.$) ? itunesImage.$.href : itunesImage.href)
|
|
275
|
+
: asNonEmptyString(itunesImage);
|
|
276
|
+
if (isValidImageUrl(itunesHref))
|
|
277
|
+
return cleanImageUrl(itunesHref);
|
|
278
|
+
if (isRecord(item.itunes) && isValidImageUrl(item.itunes.image)) {
|
|
279
|
+
return cleanImageUrl(item.itunes.image);
|
|
280
|
+
}
|
|
281
|
+
// 4. enclosure
|
|
271
282
|
if (item.enclosure?.url) {
|
|
272
283
|
const url = item.enclosure.url;
|
|
273
284
|
const type = item.enclosure.type ?? "";
|
|
@@ -392,9 +403,26 @@ function parseJsonFeed(body) {
|
|
|
392
403
|
link: asNonEmptyString(raw.home_page_url),
|
|
393
404
|
icons,
|
|
394
405
|
logos,
|
|
406
|
+
artworkUrl: logos[0] ?? icons[0],
|
|
395
407
|
items,
|
|
396
408
|
};
|
|
397
409
|
}
|
|
410
|
+
function extractXmlArtworkUrl(parsed) {
|
|
411
|
+
const itunesImage = parsed["itunes:image"] ?? parsed.itunesImage;
|
|
412
|
+
const href = isRecord(itunesImage)
|
|
413
|
+
? asNonEmptyString(isRecord(itunesImage.$) ? itunesImage.$.href : itunesImage.href)
|
|
414
|
+
: asNonEmptyString(itunesImage);
|
|
415
|
+
if (href && isValidImageUrl(href))
|
|
416
|
+
return href;
|
|
417
|
+
if (isRecord(parsed.itunes) && typeof parsed.itunes.image === "string" && isValidImageUrl(parsed.itunes.image)) {
|
|
418
|
+
return parsed.itunes.image.trim();
|
|
419
|
+
}
|
|
420
|
+
if (typeof parsed.image?.url === "string" && isValidImageUrl(parsed.image.url))
|
|
421
|
+
return parsed.image.url.trim();
|
|
422
|
+
if (typeof parsed.icon === "string" && isValidImageUrl(parsed.icon))
|
|
423
|
+
return parsed.icon.trim();
|
|
424
|
+
return undefined;
|
|
425
|
+
}
|
|
398
426
|
export async function parseFeedBody(body) {
|
|
399
427
|
if (body.trimStart().startsWith("{")) {
|
|
400
428
|
return parseJsonFeed(body);
|
|
@@ -406,13 +434,17 @@ export async function parseFeedBody(body) {
|
|
|
406
434
|
icons.push(parsed.icon.trim());
|
|
407
435
|
if (typeof parsed.image?.url === "string" && parsed.image.url.trim())
|
|
408
436
|
logos.push(parsed.image.url.trim());
|
|
437
|
+
const artworkUrl = extractXmlArtworkUrl(parsed);
|
|
438
|
+
if (artworkUrl && !logos.includes(artworkUrl))
|
|
439
|
+
logos.unshift(artworkUrl);
|
|
409
440
|
return {
|
|
410
441
|
mimeType: "application/rss+xml",
|
|
411
442
|
title: plainTitle(parsed.title),
|
|
412
|
-
description: asNonEmptyString(parsed.description),
|
|
443
|
+
description: decodeEntities(asNonEmptyString(parsed.description)) ?? undefined,
|
|
413
444
|
link: asNonEmptyString(parsed.link),
|
|
414
445
|
icons,
|
|
415
446
|
logos,
|
|
447
|
+
artworkUrl,
|
|
416
448
|
items: parsed.items.map((item) => ({
|
|
417
449
|
guid: itemGuid(item),
|
|
418
450
|
title: plainTitle(item.title),
|
|
@@ -426,6 +458,40 @@ export async function parseFeedBody(body) {
|
|
|
426
458
|
})),
|
|
427
459
|
};
|
|
428
460
|
}
|
|
461
|
+
function isYouTubeUrl(rawUrl) {
|
|
462
|
+
if (!rawUrl)
|
|
463
|
+
return false;
|
|
464
|
+
try {
|
|
465
|
+
const host = new URL(rawUrl).hostname.toLowerCase();
|
|
466
|
+
return host === "youtube.com" || host.endsWith(".youtube.com") || host === "youtu.be";
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/** Classifies a feed as `audio`, `video`, or `article` from its URL and recent items. */
|
|
473
|
+
export function detectFeedKind(feedUrl, items) {
|
|
474
|
+
if (isYouTubeUrl(feedUrl))
|
|
475
|
+
return "video";
|
|
476
|
+
const sample = items.slice(0, 20);
|
|
477
|
+
if (sample.length === 0)
|
|
478
|
+
return "article";
|
|
479
|
+
let audioCount = 0;
|
|
480
|
+
let videoCount = 0;
|
|
481
|
+
for (const item of sample) {
|
|
482
|
+
if (item.enclosureType?.toLowerCase().startsWith("video/") || isYouTubeUrl(item.link)) {
|
|
483
|
+
videoCount++;
|
|
484
|
+
}
|
|
485
|
+
else if (item.enclosureUrl) {
|
|
486
|
+
audioCount++;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (videoCount > 0 && videoCount >= audioCount && videoCount * 2 >= sample.length)
|
|
490
|
+
return "video";
|
|
491
|
+
if (audioCount > 0 && audioCount * 2 >= sample.length)
|
|
492
|
+
return "audio";
|
|
493
|
+
return "article";
|
|
494
|
+
}
|
|
429
495
|
export function formatFeedAuthor(authors, feedTitle, feedUrl) {
|
|
430
496
|
return authorLine(authors, { title: feedTitle, url: feedUrl });
|
|
431
497
|
}
|
|
@@ -10,25 +10,68 @@ import { db } from "../db/index.js";
|
|
|
10
10
|
import { configurePollHostCooldowns, PollQueue } from "./pollQueue.js";
|
|
11
11
|
import { feedRequests, PollDeferredError, sourceHost } from "./requestGate.js";
|
|
12
12
|
import { readPollSettings } from "./pollSettings.js";
|
|
13
|
-
import { formatFeedAuthor, itemGuid, itemLink, parseFeedBody, resolveFeedIconUrls } from "./feedParser.js";
|
|
13
|
+
import { detectFeedKind, formatFeedAuthor, itemGuid, itemLink, parseFeedBody, resolveFeedIconUrls } from "./feedParser.js";
|
|
14
|
+
import { decodeEntities } from "./text.js";
|
|
14
15
|
export { itemGuid, itemLink };
|
|
15
16
|
configurePollHostCooldowns();
|
|
17
|
+
function isYouTubeChannelUrl(rawUrl) {
|
|
18
|
+
if (!rawUrl)
|
|
19
|
+
return false;
|
|
20
|
+
try {
|
|
21
|
+
const host = new URL(rawUrl).hostname.toLowerCase();
|
|
22
|
+
return host === "youtube.com" || host.endsWith(".youtube.com");
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function extractHtmlMeta(html, nameOrProp) {
|
|
29
|
+
const metaTags = html.match(/<meta\b[^>]{1,600}>/gi) ?? [];
|
|
30
|
+
const target = nameOrProp.toLowerCase();
|
|
31
|
+
for (const tag of metaTags) {
|
|
32
|
+
const propMatch = /\b(?:property|name)\s*=\s*["']([^"']+)["']/i.exec(tag);
|
|
33
|
+
if (!propMatch || propMatch[1]?.toLowerCase() !== target)
|
|
34
|
+
continue;
|
|
35
|
+
const contentMatch = /\bcontent\s*=\s*["']([^"']*)["']/i.exec(tag);
|
|
36
|
+
if (contentMatch?.[1])
|
|
37
|
+
return decodeEntities(contentMatch[1]) ?? undefined;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
async function refreshYouTubeShowMetadata(feedId, siteUrl, signal) {
|
|
42
|
+
const fetched = await fetchFeed(siteUrl, { signal, priority: "background" });
|
|
43
|
+
if (fetched.notModified || !fetched.body)
|
|
44
|
+
return;
|
|
45
|
+
const artworkUrl = extractHtmlMeta(fetched.body, "og:image");
|
|
46
|
+
const description = extractHtmlMeta(fetched.body, "og:description") ?? extractHtmlMeta(fetched.body, "description");
|
|
47
|
+
if (!artworkUrl && !description)
|
|
48
|
+
return;
|
|
49
|
+
db.prepare("UPDATE feeds SET artwork_url = COALESCE(?, artwork_url), description = COALESCE(?, description) WHERE id = ?").run(artworkUrl ?? null, description ?? null, feedId);
|
|
50
|
+
}
|
|
16
51
|
/**
|
|
17
52
|
* Checks the feed's icon when it is due. The check starts right away but is not awaited, has its own deadline, and cannot retry or
|
|
18
53
|
* fail a committed feed; downloads join the shared request limit as background work.
|
|
19
54
|
*/
|
|
20
55
|
function scheduleIconMaintenance(feed, parsed) {
|
|
21
|
-
|
|
56
|
+
const siteUrl = parsed?.link || feed.site_url;
|
|
57
|
+
const needsYouTubeShowMeta = isYouTubeChannelUrl(siteUrl) && (!feed.artwork_url || !feed.description);
|
|
58
|
+
const iconDue = iconCheckDue(feed.icon_checked_at);
|
|
59
|
+
if (!iconDue && !needsYouTubeShowMeta)
|
|
22
60
|
return;
|
|
23
|
-
|
|
61
|
+
if (iconDue)
|
|
62
|
+
updateFeedIcon(feed.id, feed.icon_url);
|
|
24
63
|
const signal = AbortSignal.timeout(readPollSettings().attemptTimeoutMs);
|
|
25
64
|
const task = (async () => {
|
|
26
65
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
66
|
+
if (needsYouTubeShowMeta && siteUrl) {
|
|
67
|
+
await refreshYouTubeShowMetadata(feed.id, siteUrl, signal).catch(() => { });
|
|
68
|
+
}
|
|
69
|
+
if (iconDue) {
|
|
70
|
+
const htmlUrls = siteUrl ? await discoverIconUrls(siteUrl, signal) : [];
|
|
71
|
+
const feedUrls = parsed ? resolveFeedIconUrls(parsed, siteUrl || feed.url) : { icons: [], logos: [] };
|
|
72
|
+
signal.throwIfAborted();
|
|
73
|
+
await refreshFeedIcon(feed.id, siteUrl, [...htmlUrls, ...feedUrls.icons], signal, feedUrls.logos);
|
|
74
|
+
}
|
|
32
75
|
}
|
|
33
76
|
catch { /* Keep the successful poll; icon failures are best effort. */ }
|
|
34
77
|
})();
|
|
@@ -121,8 +164,17 @@ async function pollAttempt(feed, signal, interactive) {
|
|
|
121
164
|
}
|
|
122
165
|
}
|
|
123
166
|
const count = items ? upsertItems(feed.id, items) : 0;
|
|
167
|
+
const detectedKind = parsed ? detectFeedKind(effectiveFeed.url, parsed.items) : undefined;
|
|
124
168
|
updateFeedAfterPoll(feed.id, {
|
|
125
|
-
...(parsed ? {
|
|
169
|
+
...(parsed ? {
|
|
170
|
+
title: parsed.title,
|
|
171
|
+
siteUrl: parsed.link,
|
|
172
|
+
description: parsed.description,
|
|
173
|
+
artworkUrl: parsed.artworkUrl,
|
|
174
|
+
detectedKind,
|
|
175
|
+
etag: fetched.etag,
|
|
176
|
+
lastModified: fetched.lastModified,
|
|
177
|
+
} : {}),
|
|
126
178
|
error: null,
|
|
127
179
|
});
|
|
128
180
|
if (count > 0 && feed.last_success_at)
|
|
@@ -98,6 +98,7 @@ export function listSubscriptionsForUser(userId) {
|
|
|
98
98
|
s.full_text_mode AS full_text_mode,
|
|
99
99
|
s.notify AS notify,
|
|
100
100
|
s.badge AS badge,
|
|
101
|
+
s.kind_override AS kind_override,
|
|
101
102
|
COALESCE(s.poll_interval_minutes, f.poll_interval_minutes) AS poll_interval_minutes,
|
|
102
103
|
(
|
|
103
104
|
SELECT COUNT(*) FROM items i
|
|
@@ -145,13 +146,16 @@ export function updateFeedAfterPoll(feedId, data) {
|
|
|
145
146
|
db.prepare(`UPDATE feeds SET
|
|
146
147
|
title = COALESCE(?, title),
|
|
147
148
|
site_url = COALESCE(?, site_url),
|
|
149
|
+
description = COALESCE(?, description),
|
|
150
|
+
artwork_url = COALESCE(?, artwork_url),
|
|
151
|
+
detected_kind = COALESCE(?, detected_kind),
|
|
148
152
|
etag = COALESCE(?, etag),
|
|
149
153
|
last_modified = COALESCE(?, last_modified),
|
|
150
154
|
last_error = NULL,
|
|
151
155
|
consecutive_errors = 0,
|
|
152
156
|
last_success_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now'),
|
|
153
157
|
last_polled_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
154
|
-
WHERE id = ?`).run(data.title ?? null, data.siteUrl ?? null, data.etag ?? null, data.lastModified ?? null, feedId);
|
|
158
|
+
WHERE id = ?`).run(data.title ?? null, data.siteUrl ?? null, data.description ?? null, data.artworkUrl ?? null, data.detectedKind ?? null, data.etag ?? null, data.lastModified ?? null, feedId);
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
/** A tombstone records that its feed still lists the article; once a day is enough for its 90-day expiry. */
|
|
@@ -404,6 +408,7 @@ export function findSubscriptionForUser(userId, feedId) {
|
|
|
404
408
|
s.full_text_mode AS full_text_mode,
|
|
405
409
|
s.notify AS notify,
|
|
406
410
|
s.badge AS badge,
|
|
411
|
+
s.kind_override AS kind_override,
|
|
407
412
|
COALESCE(s.poll_interval_minutes, f.poll_interval_minutes) AS poll_interval_minutes,
|
|
408
413
|
(
|
|
409
414
|
SELECT COUNT(*) FROM items i
|
|
@@ -425,6 +430,9 @@ export function updateSubscriptionLabel(userId, feedId, label) {
|
|
|
425
430
|
export function updateSubscriptionFolder(userId, feedId, folderId) {
|
|
426
431
|
db.prepare("UPDATE subscriptions SET folder_id = ? WHERE user_id = ? AND feed_id = ?").run(folderId, userId, feedId);
|
|
427
432
|
}
|
|
433
|
+
export function updateSubscriptionKindOverride(userId, feedId, kindOverride) {
|
|
434
|
+
db.prepare("UPDATE subscriptions SET kind_override = ? WHERE user_id = ? AND feed_id = ?").run(kindOverride, userId, feedId);
|
|
435
|
+
}
|
|
428
436
|
export function listFoldersForUser(userId) {
|
|
429
437
|
return db
|
|
430
438
|
.prepare(`SELECT
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from "../config.js";
|
|
2
2
|
import { db } from "../db/index.js";
|
|
3
|
-
import { createFeed, findFeedByUrl, isUserSubscribed, subscribe, unsubscribe as unsubscribeRepo, findSubscriptionForUser, updateSubscriptionLabel, updateSubscriptionFolder, updateSubscriptionPollInterval, updateSubscriptionFullTextMode, updateSubscriptionNotify, updateSubscriptionBadge, findFolderById, findFeedById, countFeedSubscribers, replaceFeedUrl, moveSubscription, } from "./repository.js";
|
|
3
|
+
import { createFeed, findFeedByUrl, isUserSubscribed, subscribe, unsubscribe as unsubscribeRepo, findSubscriptionForUser, updateSubscriptionLabel, updateSubscriptionFolder, updateSubscriptionPollInterval, updateSubscriptionFullTextMode, updateSubscriptionKindOverride, updateSubscriptionNotify, updateSubscriptionBadge, findFolderById, findFeedById, countFeedSubscribers, replaceFeedUrl, moveSubscription, } from "./repository.js";
|
|
4
4
|
import { pollFeed, probeFeed } from "./poller.js";
|
|
5
5
|
import { assertPublicFeedUrl } from "./blockedHosts.js";
|
|
6
6
|
import { discoverFeeds } from "./discovery.js";
|
|
@@ -109,6 +109,9 @@ export function updateFeedSettings(userId, feedId, settings) {
|
|
|
109
109
|
if (settings.fullTextMode !== undefined) {
|
|
110
110
|
updateSubscriptionFullTextMode(userId, feedId, settings.fullTextMode);
|
|
111
111
|
}
|
|
112
|
+
if (settings.kindOverride !== undefined) {
|
|
113
|
+
updateSubscriptionKindOverride(userId, feedId, settings.kindOverride);
|
|
114
|
+
}
|
|
112
115
|
if (settings.notify !== undefined) {
|
|
113
116
|
updateSubscriptionNotify(userId, feedId, settings.notify);
|
|
114
117
|
}
|
|
@@ -21,6 +21,11 @@ export function serializeSubscription(subscription) {
|
|
|
21
21
|
badge: Boolean(subscription.badge),
|
|
22
22
|
isInbox: Boolean(subscription.is_system_inbox),
|
|
23
23
|
lastError: subscription.last_error,
|
|
24
|
+
kind: subscription.kind_override ?? subscription.detected_kind ?? "article",
|
|
25
|
+
detectedKind: subscription.detected_kind ?? "article",
|
|
26
|
+
kindOverride: subscription.kind_override ?? null,
|
|
27
|
+
description: subscription.description ?? null,
|
|
28
|
+
artworkUrl: subscription.artwork_url ?? null,
|
|
24
29
|
iconHash: subscription.icon_hash ?? null,
|
|
25
30
|
iconUrl: subscription.icon_hash
|
|
26
31
|
? `/api/v1/subscriptions/${subscription.id}/icon?v=${subscription.icon_hash}`
|