This commit is contained in:
Cedric Hoelzl 2020-07-03 11:30:04 +02:00
parent 952d71c9eb
commit a47183886d
2 changed files with 7 additions and 7 deletions

View File

@ -14,7 +14,7 @@ var db = new db_js("rss_chan");
const get_rss = function(url,min_id){ const get_rss = function(url,min_id){
return parser.parseURL(url).then(feed=>feed.items).then(items=>{ return parser.parseURL(url).then(feed=>feed.items).then(items=>{
let idx = items.findIndex(i => i.prop_1 === min_id); let idx = items.findIndex(i => parseInt(i.guid) === min_id);
if(idx>=0) return items.slice(0,idx); if(idx>=0) return items.slice(0,idx);
else return items; else return items;
}); });

View File

@ -33,12 +33,12 @@ const get_url = function(opts){
} }
const get_rss = function(url,min_id){ const get_rss = function(url,min_id){
return parser.parseURL(url).then(feed=>feed.items return parser.parseURL(url).then(feed=>feed.items).then(items=>{
.sort((a, b)=>(parseInt(a.guid)-parseInt(b.guid))) let idx = items.findIndex(i => parseInt(i.guid) === min_id);
.filter((v)=>(parseInt(v.guid)>min_id))); if(idx>=0) return items.slice(0,idx);
else return items;
});
} }
console.log(get_url({org:ORG.BR, lang:'de',since:-2})) get_rss(get_url({org:ORG.BR, lang:'de',since:-3}),79718).then(r=>r.forEach(item=>{
get_rss(get_url({org:ORG.BR, lang:'de',since:-2}),79710).then(r=>r.forEach(item=>{
console.log(`${item.title} (${item.guid}): ${item.link}`); console.log(`${item.title} (${item.guid}): ${item.link}`);
})); }));