mirror of
https://github.com/fenwick67/mastofeed
synced 2024-12-23 07:38:10 +01:00
Update convert.js
This commit is contained in:
parent
d4b1891e89
commit
2bcec3c2d1
@ -77,14 +77,25 @@ function buildUp(jsonObj,opts){
|
|||||||
item.enclosures = [];
|
item.enclosures = [];
|
||||||
|
|
||||||
if (item["activity:object"] && item["activity:object"].link){
|
if (item["activity:object"] && item["activity:object"].link){
|
||||||
item["activity:object"].link.forEach(function(link){
|
|
||||||
|
|
||||||
|
if (Array.isArrray(item["activity:object"].link) ){
|
||||||
|
item["activity:object"].link.forEach(parseLink);
|
||||||
|
}else if (typeof item["activity:object"].link == 'object'){
|
||||||
|
parseLink(item["activity:object"].link);
|
||||||
|
}else{
|
||||||
|
console.log('cannot parse links, is type ' +typeof item["activity:object"].link);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseLink(link){
|
||||||
if (!link['@']){return;} // avoid keyerror
|
if (!link['@']){return;} // avoid keyerror
|
||||||
var rel = link['@'].rel;
|
var rel = link['@'].rel;
|
||||||
var href = link['@'].href;
|
var href = link['@'].href;
|
||||||
if (rel == 'enclosure'){
|
if (rel == 'enclosure'){
|
||||||
item.enclosures.push(href);
|
item.enclosures.push(href);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get author info
|
// get author info
|
||||||
@ -102,7 +113,7 @@ function buildUp(jsonObj,opts){
|
|||||||
item.author.displayName = getH(_author,'poco:displayname');
|
item.author.displayName = getH(_author,'poco:displayname');
|
||||||
|
|
||||||
var authorLinks = _author.link || [];
|
var authorLinks = _author.link || [];
|
||||||
authorLinks.forEach(function(link){
|
authorLinks.forEach(function(link){// todo: guard against authorLinks not being an array
|
||||||
if (!link['@']){return;} // avoid keyerror
|
if (!link['@']){return;} // avoid keyerror
|
||||||
var rel = link['@'].rel;
|
var rel = link['@'].rel;
|
||||||
var href = link['@'].href;
|
var href = link['@'].href;
|
||||||
|
Loading…
Reference in New Issue
Block a user