liftie 4.2.6 → 4.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli/noaa.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { program } from 'commander';
3
+ import { LIFTIE_USER_AGENT } from '../env.js';
3
4
  import { descriptorPath } from './dirs.js';
4
5
  import forEachResort from './for-each-resort.js';
5
6
 
6
- const userAgent = 'Mozilla/5.0 (compatible; Liftie/1.0; +https://liftie.info)';
7
-
8
7
  function points([lon, lat]) {
9
8
  function shorten(n) {
10
9
  return n.toFixed(4).replace(/0+$/, '');
@@ -27,7 +26,7 @@ async function noaaForResort(resortId, { overwrite }) {
27
26
  const { ll } = descriptor;
28
27
  const res = await fetch(`https://api.weather.gov/points/${points(ll)}`, {
29
28
  headers: {
30
- 'User-Agent': userAgent,
29
+ 'User-Agent': LIFTIE_USER_AGENT,
31
30
  Accept: 'application/geo+json'
32
31
  }
33
32
  });
package/lib/env.js CHANGED
@@ -4,6 +4,7 @@ const {
4
4
  CSP_REPORT_URI,
5
5
  LIFTIE_CSP_ENFORCE,
6
6
  LIFTIE_STATIC_HOST = '',
7
+ LIFTIE_USER_AGENT,
7
8
  LOG_DIR = tmpdir(),
8
9
  NODE_ENV = 'development',
9
10
  OPENWEATHER_API_KEY,
@@ -19,6 +20,7 @@ export {
19
20
  CSP_REPORT_URI,
20
21
  LIFTIE_CSP_ENFORCE,
21
22
  LIFTIE_STATIC_HOST,
23
+ LIFTIE_USER_AGENT,
22
24
  LOG_DIR,
23
25
  NODE_ENV,
24
26
  OPENWEATHER_API_KEY,
@@ -1,4 +1,4 @@
1
- const userAgent = 'Mozilla/5.0 (compatible; Liftie/1.0; +https://liftie.info)';
1
+ import { LIFTIE_USER_AGENT } from '../env.js';
2
2
 
3
3
  export default function request({ host, pathname, query }) {
4
4
  const fullUrl = new URL(pathname, host);
@@ -7,7 +7,7 @@ export default function request({ host, pathname, query }) {
7
7
  }
8
8
  return fetch(fullUrl, {
9
9
  headers: {
10
- 'User-Agent': userAgent,
10
+ 'User-Agent': LIFTIE_USER_AGENT,
11
11
  Accept: '*/*'
12
12
  }
13
13
  });
package/lib/lifts/rest.js CHANGED
@@ -1,7 +1,6 @@
1
+ import { LIFTIE_USER_AGENT } from '../env.js';
1
2
  import { parseHtml } from './parser.js';
2
3
 
3
- const userAgent = 'liftie/1.0.0 (https://liftie.info)';
4
-
5
4
  export default function rest(url, parse, fn) {
6
5
  const fullUrl = new URL(url.pathname, url.host);
7
6
  if (url.query) {
@@ -9,7 +8,7 @@ export default function rest(url, parse, fn) {
9
8
  }
10
9
  const reqInit = {
11
10
  headers: {
12
- 'User-Agent': userAgent,
11
+ 'User-Agent': LIFTIE_USER_AGENT,
13
12
  Accept: 'application/json'
14
13
  }
15
14
  };
@@ -1,12 +1,10 @@
1
1
  export default {
2
- selector: '.table:first-of-type th',
3
- filter: node => node.children.length >= 2,
2
+ selector: '.node--type-lift',
4
3
  parse: {
5
- name: 1,
4
+ name: '0/0/0',
6
5
  status: {
7
- child: 0,
8
- attribute: 'class',
9
- regex: /\s+([a-z]+)$/
6
+ child: 2,
7
+ attribute: 'title'
10
8
  }
11
9
  }
12
10
  };
@@ -2,7 +2,7 @@
2
2
  "name": "Grand Targhee",
3
3
  "url": {
4
4
  "host": "https://www.grandtarghee.com",
5
- "pathname": "/the-mountain/snow-report/"
5
+ "pathname": "/the-mountain/cams-conditions/lifts-trails-report"
6
6
  },
7
7
  "tags": [
8
8
  "Wyoming"
@@ -1,7 +1,7 @@
1
1
  export default {
2
- selector: '.lifts-list.active tbody tr',
2
+ selector: '[data-panel="lift-status"] h4',
3
3
  parse: {
4
- name: 1,
5
- status: 2
4
+ name: '.',
5
+ status: '../+'
6
6
  }
7
7
  };
@@ -1,11 +1,9 @@
1
- export default {
2
- selector: 'div.wrapper > div.row',
3
- parse: {
4
- name: '2/0',
5
- status: {
6
- child: '.',
7
- attribute: 'data-state',
8
- fn: s => (s === '1' ? 'open' : 'closed')
9
- }
10
- }
11
- };
1
+ import coerce from '../../tools/coerce.js';
2
+
3
+ export default function parse(data = {}) {
4
+ const { items = [] } = data;
5
+ return items.reduce((ls, { title, state }) => {
6
+ ls[title] = coerce(state);
7
+ return ls;
8
+ }, {});
9
+ }
@@ -2,7 +2,18 @@
2
2
  "name": "Skiwelt",
3
3
  "url": {
4
4
  "host": "https://www.skiwelt.at",
5
- "pathname": "/dk/liftstatus.html"
5
+ "pathname": "/en/lift-status-winter.html"
6
+ },
7
+ "dataUrl": {
8
+ "host": "https://www.skiwelt.at",
9
+ "pathname": "/webapi/micadoweb",
10
+ "query": {
11
+ "api": "Micado.Ski.Web/Micado.Ski.Web.IO.Api.FacilityApi/List.api",
12
+ "region": "skiwelt",
13
+ "season": "winter",
14
+ "typeIDs": 1
15
+ },
16
+ "json": true
6
17
  },
7
18
  "tags": [
8
19
  "Alps",
@@ -1,7 +1,7 @@
1
1
  export default {
2
- selector: '.lifts_info',
2
+ selector: '.lift_status_top',
3
3
  parse: {
4
- name: 0,
5
- status: node => node.prev.children[0].attribs.alt
4
+ name: '0/0',
5
+ status: '1/0'
6
6
  }
7
7
  };
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "api": {
8
8
  "host": "https://www.skibanff.com",
9
- "pathname": "/api/data/lifts",
9
+ "pathname": "/wp-json/sunshine/v1/lifts",
10
10
  "json": true
11
11
  },
12
12
  "tags": [
@@ -1,3 +1,11 @@
1
1
  export default {
2
- selector: '.lift-listing .asset-container .asset'
2
+ selector: '.mc-lifts__table tbody tr',
3
+ parse: {
4
+ name: '0',
5
+ status: {
6
+ child: '2',
7
+ attribute: 'class',
8
+ regex: /mc__icon-(\w+)/
9
+ }
10
+ }
3
11
  };
@@ -2,7 +2,7 @@
2
2
  "name": "Sun Valley",
3
3
  "url": {
4
4
  "host": "https://www.sunvalley.com",
5
- "pathname": "/mountain-snow-report"
5
+ "pathname": "/the-mountain/mountain-report/"
6
6
  },
7
7
  "tags": [
8
8
  "Idaho"
@@ -1,11 +1,9 @@
1
1
  import Debug from 'debug';
2
- import { LIFTIE_STATIC_HOST as staticHost } from '../env.js';
2
+ import { LIFTIE_USER_AGENT, LIFTIE_STATIC_HOST as staticHost } from '../env.js';
3
3
  import { iconsFromUrl } from './icons.js';
4
4
 
5
5
  const debug = Debug('liftie:weather');
6
6
 
7
- const userAgent = 'Mozilla/5.0 (compatible; Liftie/1.0; +https://liftie.info)';
8
-
9
7
  function normalize(data, ll) {
10
8
  debug('weather %j', data.properties.periods);
11
9
 
@@ -40,7 +38,7 @@ export default function fetchWeather(resort, fn) {
40
38
  fetch(url, {
41
39
  method: 'GET',
42
40
  headers: {
43
- 'User-Agent': userAgent,
41
+ 'User-Agent': LIFTIE_USER_AGENT,
44
42
  Accept: 'application/geo+json'
45
43
  }
46
44
  })
package/lib/webcams.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import Debug from 'debug';
2
+ import { LIFTIE_USER_AGENT } from './env.js';
2
3
  import limiter from './tools/limiter.js';
3
4
  import { minute } from './tools/millis.js';
4
5
 
5
6
  const debug = Debug('liftie:webcams');
6
7
 
7
- const userAgent = 'Mozilla/5.0 (compatible; Liftie/1.0; +https://liftie.info)';
8
-
9
8
  fetchWebcams.interval = {
10
9
  active: 8.5 * minute, // v3 API images are only valid for 10 minutes
11
10
  inactive: Number.POSITIVE_INFINITY
@@ -58,7 +57,7 @@ export default function fetchWebcams(resort, fn) {
58
57
  fetch(url, {
59
58
  headers: {
60
59
  Accept: 'application/json',
61
- 'User-Agent': userAgent,
60
+ 'User-Agent': LIFTIE_USER_AGENT,
62
61
  'x-windy-api-key': WEBCAMS_API_KEY
63
62
  }
64
63
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liftie",
3
- "version": "4.2.6",
3
+ "version": "4.2.8",
4
4
  "description": "Clean, simple, easy to read, fast ski resort lift status",
5
5
  "type": "module",
6
6
  "keywords": [