diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index df18493..4820348 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19033,13 +19033,15 @@ class Plex { let res = await axios.get(this.authorizeURL(decisionURL), { timeout: this.requestTimeout }); - console.log(res); - console.log('Waiting for new url...'); - await sleep(10000); - res = await axios.get(this.authorizeURL(decisionURL), { - timeout: this.requestTimeout - }); - console.log(res); + while (parseFloat(res.data.MediaContainer.Metadata[0].Media[0].Part[0].key.split('offset=')[1].split('&')[0]) < 10) { + // eslint-disable-next-line no-await-in-loop + await sleep(500); + // eslint-disable-next-line no-await-in-loop + res = await axios.get(this.authorizeURL(decisionURL), { + timeout: this.requestTimeout + }); + console.log('Waiting for new url...'); + } return res.data.MediaContainer.Metadata[0].Media[0].Part[0].key; }; this.getContinueWatching = async () => { diff --git a/src/modules/Plex.ts b/src/modules/Plex.ts index 8e46059..41f3a67 100644 --- a/src/modules/Plex.ts +++ b/src/modules/Plex.ts @@ -475,15 +475,17 @@ class Plex { let res = await axios.get(this.authorizeURL(decisionURL), { timeout: this.requestTimeout }); - console.log(res); - - console.log('Waiting for new url...'); - await sleep(10000); - res = await axios.get(this.authorizeURL(decisionURL), { - timeout: this.requestTimeout - }); - console.log(res); - + while ( + parseFloat(res.data.MediaContainer.Metadata[0].Media[0].Part[0].key.split('offset=')[1].split('&')[0]) < 10 + ) { + // eslint-disable-next-line no-await-in-loop + await sleep(500); + // eslint-disable-next-line no-await-in-loop + res = await axios.get(this.authorizeURL(decisionURL), { + timeout: this.requestTimeout + }); + console.log('Waiting for new url...'); + } return res.data.MediaContainer.Metadata[0].Media[0].Part[0].key; };