Skip to content

Instantly share code, notes, and snippets.

@scripting
Created November 12, 2023 16:30
Show Gist options
  • Save scripting/b38d686fa384c127a681e7382e23efd6 to your computer and use it in GitHub Desktop.
Save scripting/b38d686fa384c127a681e7382e23efd6 to your computer and use it in GitHub Desktop.
const urlRiver = "https://feedland.org/getriverfromreadinglist?url=https://lists.feedcorps.org/artshow.opml";
function httpRequest (url, timeout, headers, callback) {
timeout = (timeout === undefined) ? 30000 : timeout;
var jxhr = $.ajax ({
url: url,
dataType: "text",
headers,
timeout
})
.success (function (data, status) {
callback (undefined, data);
})
.error (function (status) {
var message;
try { //9/18/21 by DW
message = JSON.parse (status.responseText).message;
}
catch (err) {
message = status.responseText;
}
if ((message === undefined) || (message.length == 0)) { //7/22/22 by DW & 8/31/22 by DW
message = "There was an error communicating with the server.";
}
var err = {
code: status.status,
message
};
callback (err);
});
}
function getRiver (urlRiver, callback) {
httpRequest (urlRiver, undefined, undefined, function (err, jsontext) {
if (err) {
console.log ("servercall: url == " + url + ", err.message == " + err.message);
callback (err);
}
else {
callback (undefined, JSON.parse (jsontext));
}
});
}
function startup () {
console.log ("startup");
getRiver (urlRiver, function (err, river) {
var ct = 0;
if (err) {
console.log (err.message);
}
else {
river.feeds.forEach (function (feed) {
feed.items.forEach (function (item) {
if (item.enclosure !== undefined) {
if (item.enclosure.type !== undefined) {
if (beginsWith (item.enclosure.type, "image/")) {
console.log (padWithZeros (++ct, 3) + ": " + item.enclosure.url);
}
}
}
});
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment