ytmytm / MMM-pekavm

MagicMirror² module - PEKA Wirtualny Monitor (Poznań public transport monitor)
MIT License
4 stars 1 forks source link

Add ticker with important messages for stop #2

Closed ytmytm closed 7 years ago

ytmytm commented 7 years ago

This is method findMessagesForBollard which also uses param=symbol (like getTimes) and returns HTML.

This would have to use startDate/endDate to narrow down when message is visible.

Message is relevant only for selected stopID.

From R:

#[1] "{\"success\":[{\"content\":\"INFO: Linie nr 5, 8, 11, 12, 14, 16, 17, 18 od 1.08.2015 do 10.08.2015 - zmiany w kursowaniu linii. Szczegóły: <a href=\\\"http://tiny.pl/gxcbh\\\">www.ztm.poznan.pl<\\/a>\",\"startDate\":\"2015-07-30T10:50:00.000Z\",\"stopsGroups\":[],\"endDate\":\"2015-08-12T00:00:00.000Z\",\"startHour\":650,\"endHour\":1440}]}"
ytmytm commented 7 years ago

http://epoznan.pl/news-news-76720-Zmiany_tras_tramwajow_w_centrum_Zamkniete_bedzie_torowisko_na_al._Marcinkowskiego

Check MRCI71/72 and others mentioned during weekend

It's there on MRCI72 - 2.6 to 4.6

ytmytm commented 7 years ago
cd ~/Projekty/magicmirror/MagicMirror
node

and paste


process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;

const request = require('request');

function getMsg() {
            var params;
            params = {
                url: "http://www.peka.poznan.pl/vm/method.vm",
                form: {
                    method:"findMessagesForBollard",
                    p0:'{"symbol":"'+'MRCI71'+'"}'
                }
            };
            return params;
    }

    var x = request.post(getMsg(), (error, response, body) => {
        if (typeof response !== 'undefined') {
            if (response.statusCode === 200) {
            console.log(body);
        } else {
                    console.log("Error getting connections " + response.statusCode);
                }
        } else {
            console.log("Peka response undefined");
            console.log(x);
            console.log(error);
        }
    })

body = x.response.body
body = '{"success":[{"content":"INFO: Od piątku 2.06 od godz. 20:00 do niedzieli 4.06 nastąpi wstrzymanie ruchu tramwajowego na Alejach Marcinkowskiego. Zmianie ulegną trasy linii nr 2, 5, 9, 13, 16 oraz 201. Szczegóły na stronie  <a href=\\"http://utn.pl/i6m0b\\">www.ztm.poznan.pl<\\/a>.","startDate":"2017-06-01T13:00:00.000Z","stopsGroups":[],"startHour":780,"endDate":"2017-06-04T23:45:00.000Z","endHour":1425}]}'

var res = JSON.parse(body)
console.log(res.success[0].content)