Skip to content

Commit

Permalink
* (Apollon77) Adjust Activity Record query to Amazon changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Apr 16, 2024
1 parent 7ab0d8c commit 8132e1c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 40 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Thank you for that work.
* docu docu docu (sorry ... will come)

## Changelog:

### __WORK IN PROGRESS__
* (Apollon77) Adjust Activity Record query to Amazon changes
* (NebzHB) fix missing amazonPage reference instead of amazon.de

### 7.0.3 (2024-01-25)
* (Apollon77) Adjust Activity Record query to newest Amazon changes

Expand Down
25 changes: 19 additions & 6 deletions alexa-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fsPath = require('path');

const EventEmitter = require('events');

const officialUserAgent = 'AppleWebKit PitanguiBridge/2.2.556530.0-[HARDWARE=iPhone14_7][SOFTWARE=16.6][DEVICE=iPhone]';
const officialUserAgent = 'AppleWebKit PitanguiBridge/2.2.595606.0-[HARDWARE=iPhone14_7][SOFTWARE=17.4.1][DEVICE=iPhone]';

function _00(val) {
let s = val.toString();
Expand Down Expand Up @@ -651,13 +651,18 @@ class AlexaRemote extends EventEmitter {
(
this.lastVolumes[payload.dopplerId.deviceSerialNumber].volumeSetting === payload.volumeSetting &&
this.lastVolumes[payload.dopplerId.deviceSerialNumber].isMuted === payload.isMuted
) ||
(
this.lastEqualizer[payload.dopplerId.deviceSerialNumber] &&
Math.abs(Date.now() - this.lastEqualizer[payload.dopplerId.deviceSerialNumber].updated) < 2000
)
) {
this.simulateActivity(payload.dopplerId.deviceSerialNumber, payload.destinationUserId);
}
this.lastVolumes[payload.dopplerId.deviceSerialNumber] = {
volumeSetting: payload.volumeSetting,
isMuted: payload.isMuted
isMuted: payload.isMuted,
updated: Date.now()
};

this.emit('ws-volume-change', {
Expand Down Expand Up @@ -706,14 +711,19 @@ class AlexaRemote extends EventEmitter {
this.lastEqualizer[payload.dopplerId.deviceSerialNumber].bass === payload.bass &&
this.lastEqualizer[payload.dopplerId.deviceSerialNumber].treble === payload.treble &&
this.lastEqualizer[payload.dopplerId.deviceSerialNumber].midrange === payload.midrange
) ||
(
this.lastVolumes[payload.dopplerId.deviceSerialNumber] &&
Math.abs(Date.now() - this.lastVolumes[payload.dopplerId.deviceSerialNumber].updated) < 2000
)
) {
this.simulateActivity(payload.dopplerId.deviceSerialNumber, payload.destinationUserId);
}
this.lastEqualizer[payload.dopplerId.deviceSerialNumber] = {
bass: payload.bass,
treble: payload.treble,
midrange: payload.midrange
midrange: payload.midrange,
updated: Date.now()
};

this.emit('ws-equilizer-state-change', {
Expand Down Expand Up @@ -1122,10 +1132,9 @@ class AlexaRemote extends EventEmitter {
'User-Agent' : `${officialUserAgent} ${this._options.apiUserAgentPostfix}`.trim(),
'Content-Type': 'application/json; charset=utf-8',
'Accept': 'application/json; charset=utf-8',
'Accept-Language': this._options.acceptLanguage || 'de-DE',
'Referer': `https://alexa.${this._options.amazonPage}/spa/index.html`,
'Origin': `https://alexa.${this._options.amazonPage}`,
//'Content-Type': 'application/json',
//'Connection': 'keep-alive',
'csrf' : this.csrf,
'Cookie' : this.cookie,
'Accept-Encoding': 'gzip, deflate'
Expand Down Expand Up @@ -1153,6 +1162,10 @@ class AlexaRemote extends EventEmitter {
options.path = path;
options.method = flags.method ? flags.method : flags.data ? 'POST' : 'GET';

if ((options.method === 'GET' || options.method === 'DELETE') && !flags.data) {
delete options.headers['Content-Type'];
}

if (flags.headers) Object.keys(flags.headers).forEach(n => {
options.headers [n] = flags.headers[n];
});
Expand Down Expand Up @@ -2129,7 +2142,7 @@ class AlexaRemote extends EventEmitter {
return this._getCustomerHistoryRecords(options, callback);
}

const csrfPageUrl = `https://www.${this._options.amazonPage}/alexa-privacy/apd/activity?ref=activityHistory`; // disableGlobalNav=true&locale=de-DE
const csrfPageUrl = `https://www.${this._options.amazonPage}/alexa-privacy/apd/activity?disableGlobalNav=true&ref=activityHistory`; // disableGlobalNav=true&locale=de-DE
this.httpsGet(csrfPageUrl, (err, result) => {
if (err || !result) return callback && callback(err, result);

Expand Down
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"devDependencies": {
"@alcalzone/release-script": "^3.7.0",
"@alcalzone/release-script-plugin-license": "^3.7.0",
"eslint": "^8.56.0"
"eslint": "^8.57.0"
},
"scripts": {
"test": "node node_modules/mocha/bin/mocha",
Expand Down

0 comments on commit 8132e1c

Please sign in to comment.