-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMMM-Podcast2.js
94 lines (79 loc) · 2.41 KB
/
MMM-Podcast2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* global Module */
/* Magic Mirror
* Module: MMM-Podcast2
*
* By AxLED
* MIT Licensed.
*/
var IntervalID2 = '';
var isplaying = false;
Module.register('MMM-Podcast2', {
defaults: {
refreshInterval: 1000 * 1800, //refresh every 1800 seconds (30Min)
feedUrl: 'https://www.tagesschau.de/export/video-podcast/webxl/tagesschau-in-100-sekunden_https/',
omxargs: ' --win 320,180,1600,900 -o both '
},
// Define required scripts.
getScripts: function() {
//return ["moment.js", 'MMM-Podcast-xml2json.js', "font-awesome.css"];
return ["moment.js", "font-awesome.css"];
},
getStyles: function() {
return ['MMM-Podcast2.css'];
},
/*getTranslations: function() {
return {
//de: "translations/de.json",
//en: "translations/en.json",
};
},*/
start: function() {
Log.info('Starting module: ' + this.name);
//this.loaded = false;
this.sendSocketNotification('CONFIG', this.config);
//console.log('Axled .js start:');
},
getDom: function() {
},
//Helper, to use module with notification system
notificationReceived: function(notification, payload) {
if(notification === "BUTTON_PRESSED"){
if (isplaying === false){
isplaying = true;
payload = [streamurl,'PLAY'];
} else {
//Stop omx senden
isplaying = false;
payload = [streamurl,'STOP'];
}
this.sendSocketNotification('BUTTON_PRESSED', payload);
}
},
socketNotificationReceived: function(notification, payload) {
if (notification === "STARTED") {
this.startFetchingData(this.config.refreshInterval);
//console.log('Axled STARTED Received:');
} else if (notification === "DATA") {
this.loaded = true;
//var json=xml2json(payload);
var json = payload;
streamurl = json.rss.channel.item.enclosure.url;
//console.log('Axled json:', json);
//console.log('Axled json enclosure:',json.rss.channel.item.enclosure.url);
} else if(payload[0]==='ERROR'){
//console.log('Axled ERROR: ',moment().format('LTS'));
this.Errormessage = payload[1];
//console.log('MMM-Podcast2 Error :',Errormessage);
}
},
startFetchingData: function(interval) {
//console.log('Axled IntervalID2:',IntervalID2);
if (IntervalID2 === ''){
// ... and then repeat in the given interval
IntervalID2 = setInterval(() => {
this.sendSocketNotification("FETCH_DATA", '')
//console.log('Axled MMM-Podcast2 refresh: ',moment().format('LTS'));
}, interval);
}
}
});