This commit is contained in:
Karsten Hassel
2021-03-02 00:17:13 +01:00
parent ea6eebd809
commit 53e300bd31
3 changed files with 36 additions and 34 deletions

View File

@@ -6,7 +6,7 @@
*/
const Log = require("logger");
const FeedMe = require("feedme");
const request = require("request");
const fetch = require("node-fetch");
const iconv = require("iconv-lite");
/**
@@ -79,22 +79,21 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
});
const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
const opts = {
headers: {
"User-Agent": "Mozilla/5.0 (Node.js " + nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
Pragma: "no-cache"
},
encoding: null
const headers = {
"User-Agent": "Mozilla/5.0 (Node.js " + nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
Pragma: "no-cache"
};
request(url, opts)
.on("error", function (error) {
fetch(url, { headers: headers })
.catch(error => {
fetchFailedCallback(self, error);
scheduleTimer();
})
.pipe(iconv.decodeStream(encoding))
.pipe(parser);
.then(res => {
res.body.pipe(iconv.decodeStream(encoding)).pipe(parser);
});
};
/**