From 6c4785b05b290684cc5a85ffd127a175278834f3 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Thu, 14 Jan 2021 20:31:31 +0100 Subject: [PATCH] DB: use JSON base profile --- p/db/base.json | 16 ++++++++++++++++ p/db/index.js | 10 ++-------- tools/pull-profile-base-data.sh | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 p/db/base.json diff --git a/p/db/base.json b/p/db/base.json new file mode 100644 index 00000000..de5f2a5c --- /dev/null +++ b/p/db/base.json @@ -0,0 +1,16 @@ +{ + "auth": { + "type": "AID", + "aid": "n91dB8Z77MLdoR0K" + }, + "salt": "6264493855566A34304B356676787766", + "client": { + "id": "DB", + "v": "16040000", + "type": "IPH", + "name": "DB Navigator" + }, + "endpoint": "https://reiseauskunft.bahn.de/bin/mgate.exe", + "ext": "DB.R19.04.a", + "ver": "1.15" +} diff --git a/p/db/index.js b/p/db/index.js index 83ac7d2f..ff21a5eb 100644 --- a/p/db/index.js +++ b/p/db/index.js @@ -17,6 +17,7 @@ const _formatStation = require('../../format/station') const {bike} = require('../../format/filters') const products = require('./products') +const baseProfile = require('./base.json') const formatLoyaltyCard = require('./loyalty-cards').format const transformReqBody = (ctx, body) => { @@ -25,11 +26,6 @@ const transformReqBody = (ctx, body) => { // see https://pastebin.com/qZ9WS3Cx req.cfg = {...req.cfg, rtMode: 'HYBRID'} // todo: use `REALTIME`? - body.client = {id: 'DB', v: '16040000', type: 'IPH', name: 'DB Navigator'} - body.ext = 'DB.R19.04.a' - body.ver = '1.15' - body.auth = {type: 'AID', aid: 'n91dB8Z77MLdoR0K'} - return body } @@ -447,11 +443,9 @@ const formatStation = (id) => { // todo: find option for absolute number of results const dbProfile = { + ...baseProfile, locale: 'de-DE', timezone: 'Europe/Berlin', - endpoint: 'https://reiseauskunft.bahn.de/bin/mgate.exe', - - salt: Buffer.from('bdI8UVj40K5fvxwf', 'utf8'), addChecksum: true, transformReqBody, diff --git a/tools/pull-profile-base-data.sh b/tools/pull-profile-base-data.sh index e69db890..d8fe374b 100755 --- a/tools/pull-profile-base-data.sh +++ b/tools/pull-profile-base-data.sh @@ -22,3 +22,4 @@ ext: .options.ext, \ ver: .options.version, \ }" +jq -r --tab "$query" <"$src/de/db-hafas-mgate.json" >../p/db/base.json