Skip to content

Commit

Permalink
fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
keydon committed Apr 20, 2021
1 parent 102f741 commit 1250d11
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"no-shadow": 2,
"no-undef-init": 2,
"no-unused-vars": 2,
"no-use-before-define": 2,
"no-use-before-define": [2, { "functions": true, "classes": false, "variables":true }],
"global-require": 2,
"handle-callback-err": 1,
"no-new-require": 2,
Expand Down
69 changes: 33 additions & 36 deletions apps/tagesschau.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
'use strict';

const express = require('express');
const axios = require('axios');
var xmlParser = require('fast-xml-parser');
const { response } = require('express');

const feedUrl = 'https://www.tagesschau.de/export/video-podcast/webxl/tagesschau_https/';

const playTodaysBroadcast = (response ) => {
console.log("tagesschau", response);
}

const fetchAndPlayTodaysBroadcast = async (request) => {
let feedContent = await axios.get(feedUrl);
let json = xmlParser.parse(feedContent.data, {
ignoreAttributes : false,
});
let lastestItem = json.rss.channel.item[0];
let dayOfPublication = lastestItem.title.split('.', 2)[0];
let todaysDay = (new Date).getDate();

if (dayOfPublication == todaysDay) {
return playFile(request, lastestItem.enclosure['@_url']);
} else {
console.log({dayOfPublication, todaysDay, lastestItem});
return showNotification(request, response, "Heutige Ausgabe noch nicht online", "error");
}
};

exports.build = (exec) => {
const app = express();

app.set('json spaces', 2);
app.all('/playTodaysBroadcast', exec(fetchAndPlayTodaysBroadcast));

return app;
};

const playFile = (request, fileName) => {
return request.kodi.Player.Open({ // eslint-disable-line new-cap
Expand All @@ -58,3 +22,36 @@ const showNotification = (request, response, message, image) => {

return request.kodi.GUI.ShowNotification(param); // eslint-disable-line new-cap
};


const express = require('express');
const axios = require('axios');
const xmlParser = require('fast-xml-parser');

const feedUrl = 'https://www.tagesschau.de/export/video-podcast/webxl/tagesschau_https/';

const fetchAndPlayTodaysBroadcast = async(request) => {
let feedContent = await axios.get(feedUrl);
let json = xmlParser.parse(feedContent.data, {
ignoreAttributes: false
});
let lastestItem = json.rss.channel.item[0];
let dayOfPublication = +lastestItem.title.split('.', 2)[0];
let todaysDay = (new Date()).getDate();

if (dayOfPublication === todaysDay) {
return playFile(request, lastestItem.enclosure['@_url']);
}

console.log({ dayOfPublication, todaysDay, lastestItem });
return showNotification(request, response, 'Heutige Ausgabe noch nicht online', 'error');
};

exports.build = (exec) => {
const app = express();

app.set('json spaces', 2);
app.all('/playTodaysBroadcast', exec(fetchAndPlayTodaysBroadcast));

return app;
};
4 changes: 2 additions & 2 deletions broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ exports.processRequest = (request, response) => {
let endpoint = endpointKey.split(`:`, 1)[0];

let legacyRoute = Helper[endpoint];
if(legacyRoute){
if (legacyRoute) {
return Helper[endpoint](request, response);
}

request.url = '/' + endpoint;
request.url = `/${endpoint}`;
return Promise.resolve(request.app.handle(request, response));
};
2 changes: 1 addition & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ const kodiFindFavourite = (request, favouriteName) => {
throw new Error('Your kodi library does not contain a single favourite!');
}

return fuzzySearchBestMatch(query.result.favourites, favouriteName, ["title"]);
return fuzzySearchBestMatch(query.result.favourites, favouriteName, ['title']);
});
};

Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ app.all('/playyoutube', exec(Helper.kodiPlayYoutube));

app.all('/searchyoutube', exec(Helper.kodiSearchYoutube));

app.all('/playItemOfDirectory', exec(Helper.playItemOfDirectory))
app.all('/playItemOfDirectory', exec(Helper.playItemOfDirectory));


// Parse request to test the end2end kodi connectivity.
Expand Down

0 comments on commit 1250d11

Please sign in to comment.