From 7b6e1d8c65a20155e4c24febf0bc37f3fc086fc4 Mon Sep 17 00:00:00 2001 From: BrianPetkovsek <16124109+BrianPetkovsek@users.noreply.github.com> Date: Mon, 17 Sep 2018 03:46:37 -0400 Subject: [PATCH] added moment lib to fix time --- modules/youtube-js/get-youtube.js | 16 +++++++--------- package-lock.json | 8 +++++--- package.json | 7 ++++++- slider-to-add.txt | 1 + 4 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 slider-to-add.txt diff --git a/modules/youtube-js/get-youtube.js b/modules/youtube-js/get-youtube.js index 465da33..4ad5bea 100644 --- a/modules/youtube-js/get-youtube.js +++ b/modules/youtube-js/get-youtube.js @@ -1,5 +1,5 @@ //code -getEpochTime = function(){return Math.round((new Date()).getTime() / 1000)}; +const moment = require('moment'); hasSeeked = false; getInfos = `(function(){ @@ -57,15 +57,13 @@ async function injectRun(mainWindow) { if (videoDuration && videoCurrentTime) { if (!isLive){ if (!videoPaused){ - vidDur = videoDuration; - vidCurtime = videoCurrentTime; + let now = moment.utc(), + remaining = moment.duration(videoDuration - videoCurrentTime, 'seconds'); + endTimestamp = now.add(remaining).unix(); + global.hasSeeked = videoCurrentTimeTemp != Math.floor(endTimestamp) + videoCurrentTimeTemp = Math.floor(endTimestamp) - a = getEpochTime()+(vidDur - vidCurtime); - - global.hasSeeked = videoCurrentTimeTemp != Math.floor(a) - videoCurrentTimeTemp = Math.floor(a) - - rpcData.endTimestamp = a; + rpcData.endTimestamp = endTimestamp; rpcData.state = 'By: '+ creator; }else{ videoName += ' By: '+ creator; diff --git a/package-lock.json b/package-lock.json index fee7e2e..b36c327 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1781,6 +1781,11 @@ "minimist": "0.0.8" } }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2115,9 +2120,6 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, - "q": { - "version": "git+https://github.com/kriskowal/q.git#8545bd6f6953dfd2a5e7fa4052ed6b39e010a8c5" - }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", diff --git a/package.json b/package.json index f2ab3f4..82969a2 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "dependencies": { "discord-rpc": "^3.0.0", "electron-widevinecdm": "^5.0.2", + "moment": "^2.22.2", "q": "git+https://github.com/kriskowal/q.git", "request": "^2.88.0", "temp-write": "^3.4.0", @@ -72,5 +73,9 @@ "win32Dependencies": { "electron-widevinecdm": "^5.0.2" }, - "os" : [ "win32", "!darwin", "!linux" ] + "os": [ + "win32", + "!darwin", + "!linux" + ] } diff --git a/slider-to-add.txt b/slider-to-add.txt new file mode 100644 index 0000000..09fbbb2 --- /dev/null +++ b/slider-to-add.txt @@ -0,0 +1 @@ +https://previews.envatousercontent.com/files/202191611/index.html \ No newline at end of file