@@ -4,6 +4,7 @@ import { NewArticle } from "./schemas/public/Article.js";
4
4
import { createHash } from "node:crypto" ;
5
5
import * as cheerio from "cheerio" ;
6
6
import { z } from "zod" ;
7
+ import * as entities from "entities" ;
7
8
8
9
type DownloadedArticle = Omit < NewArticle , "id" | "feed_id" > ;
9
10
@@ -52,6 +53,7 @@ const RssChannel = z.object({
52
53
z . object ( {
53
54
title : z . optional ( TextNode ) ,
54
55
description : z . optional ( TextNode ) ,
56
+ "content:encoded" : z . optional ( TextNode ) ,
55
57
link : z . optional ( TextNode ) ,
56
58
guid : z . optional (
57
59
TextNode . extend ( {
@@ -166,15 +168,15 @@ export async function downloadFeed(feedUrl: string): Promise<DownloadedFeed> {
166
168
const articles : DownloadedArticle [ ] = parsedFeed . items . map ( ( item ) => ( {
167
169
article_id : item . id ,
168
170
content : getContent ( item ) ?? "" ,
169
- title : item . title ,
171
+ title : entities . decode ( item . title ) ,
170
172
link : item . link ,
171
173
published : item . updated ,
172
174
} ) ) ;
173
175
174
176
console . debug ( `Processed feed ${ feedUrl } ` ) ;
175
177
176
178
return {
177
- title : parsedFeed . title ,
179
+ title : entities . decode ( parsedFeed . title ) ,
178
180
link : parsedFeed . link ,
179
181
icon,
180
182
articles,
@@ -242,7 +244,10 @@ function parseFeed(xml: string): ParsedFeed {
242
244
id :
243
245
item [ "$$rdf:about" ] ??
244
246
item . link ?. $text ??
245
- hashStrings ( item . title ?. $text ?? "" , item . description ?. $text ?? "" ) ,
247
+ hashStrings (
248
+ item . title ?. $text ?? "" ,
249
+ item . description ?. $text ?? "" ,
250
+ ) ,
246
251
title : item . title ?. $text ?? "" ,
247
252
link : item . link ?. $text ?? "" ,
248
253
updated : new Date ( item [ "dc:date" ] . $text ) ,
@@ -257,11 +262,15 @@ function parseFeed(xml: string): ParsedFeed {
257
262
id :
258
263
item . guid ?. $text ??
259
264
item . link ?. $text ??
260
- hashStrings ( item . title ?. $text ?? "" , item . description ?. $text ?? "" ) ,
265
+ hashStrings (
266
+ item . title ?. $text ?? "" ,
267
+ item . description ?. $text ?? "" ,
268
+ ) ,
261
269
title : item . title ?. $text ?? "" ,
262
270
link : item . link ?. $text ?? "" ,
263
271
updated : item . pubDate ? new Date ( item . pubDate . $text ) : new Date ( ) ,
264
- content : item . description ?. $text ?? "" ,
272
+ content :
273
+ item [ "content:encoded" ] ?. $text ?? item . description ?. $text ?? "" ,
265
274
} ) ) ;
266
275
}
267
276
0 commit comments