Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing when no tor ports are defined + Czech language #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MMM-idos.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Module.register('MMM-idos', {
return {
en: "translations/en.json",
sk: "translations/sk.json",
cz: "translations/sk.json",
cs: "translations/cs.json",
}
},

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ real time estimated departures for public transport in the Czech Republic.
## Installation

Clone this module into your Magic Mirror modules folder.
1. Go into Magic Mirror's `modules` folder
1. Go into Magic Mirror's `modules` folder
2. Execute `git clone https://github.com/soyrubio/MMM-idos.git`.

## Using the module
Expand All @@ -23,9 +23,9 @@ var config = {
modules: [
{
module: 'MMM-idos',
header: 'Praha Masarykovo n.', // no header will be displayed if ommited
header: 'Praha Masarykovo n.', // no header will be displayed if ommited
position: 'top_right', // position of the module

config: {
stopId: 'Praha%20Masarykovo%20n.', // "https://idos.idnes.cz/vlakyautobusymhdvse/odjezdy/vysledky/?f=the_stop
torPorts: ['9050', '9052'], // tor won't be used if ommited
Expand All @@ -36,7 +36,7 @@ var config = {
}
```

If Tor ports are selected, the module will randomly choose one to access to the idos.cz website.
If Tor ports are selected, the module will randomly choose one to access to the idos.cz website.
If you want to set up Tor for anonymous access, and don't know how to, [you can read this article](https://levelup.gitconnected.com/anonymous-web-scrapping-with-node-js-tor-apify-and-cheerio-3b36ec6a45dc).

## Configuration options
Expand All @@ -45,7 +45,7 @@ If you want to set up Tor for anonymous access, and don't know how to, [you can
|--------------------- |------------
| `stopId` | *Required* Id of the stop (parameter "z" in stop's livetable url).<br><br> **Type:** `int` <br> **Default value:** `none`
| `maximumEntries` | *Optional* The maximum entries shown. <br><br> **Type:** `int` <br> **Default value:** `10`
| `refreshInterval` | *Optional* How often to check for the next lines. <br><br> **Type:** `int`<br> **Default value:** `30000` milliseconds (60 seconds)
| `refreshInterval` | *Optional* How often to check for the next lines. <br><br> **Type:** `int`<br> **Default value:** `60000` milliseconds (60 seconds)
| `fade` | *Optional* Fade the future lines to black. (Gradient) <br><br> **Type:** `boolean`<br> **Default value:** `true`
| `fadePoint` | *Optional* Where to start fade? <br><br> **Type:** `float`<br> **Default value:** `0.25` (start on the 1/4 th of the list)
| `blink` | *Optional* Whether departures should blink when departure time is <1 min. <br><br> **Type:** `boolean`<br> **Default value:** `true`
Expand Down
6 changes: 3 additions & 3 deletions node-idos.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* By elrubio https://github.com/soyrubio
* MIT Licensed.
*
*
* This is a web scraper for the MMM-idos module
* The data is scraped from https://idos.idnes.cz/vlakyautobusymhdvse/odjezdy/
*/
Expand Down Expand Up @@ -44,7 +44,7 @@ function parse_body(body) {
}

output.sort(getSortOrder("departurewdelay"));

return output;
}

Expand Down Expand Up @@ -72,7 +72,7 @@ function getDepartureWDelay(dep, delay) {

async function scrape(options, callback) {
try {
var port_arg;
var port_arg = '';
if (options.ports.length > 0) {
const randomPort = options.ports[Math.floor(Math.random() * options.ports.length)];
port_arg = '--proxy-server=socks5://127.0.0.1:' + randomPort;
Expand Down
2 changes: 1 addition & 1 deletion translations/cz.json → translations/cs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"IDOS_NO_LINES": "Žádné odchody",
"IDOS_NO_LINES": "Aktuálně žádné spoje",
"IDOS_FETCH_ERROR": "Nepodařilo se stáhnout data"
}