aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2021-08-16 20:47:25 -0400
committerAndrew Lee <alee14498@protonmail.com>2021-08-16 20:47:25 -0400
commita1d7eb355f2c74184280c51b688d1bbd0c4e98b1 (patch)
treee28a5d8f3eff026a2467b774451ec9ecb4225fd6 /index.js
parentfba836144622b44fe7674c6e69a3668fd472d1c8 (diff)
downloadYouTube-TV-Client-a1d7eb355f2c74184280c51b688d1bbd0c4e98b1.tar.gz
YouTube-TV-Client-a1d7eb355f2c74184280c51b688d1bbd0c4e98b1.tar.bz2
YouTube-TV-Client-a1d7eb355f2c74184280c51b688d1bbd0c4e98b1.zip
Added an updater; Added snapcraft to readme
Diffstat (limited to 'index.js')
-rw-r--r--index.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/index.js b/index.js
index a44a409..33ff6fb 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,11 @@
const { app, BrowserWindow, session } = require('electron');
+const { autoUpdater } = require("electron-updater");
+const log = require('electron-log');
const package = require("./package.json");
+autoUpdater.logger = log;
+autoUpdater.logger.transports.file.level = 'info';
+
const userAgent = "Mozilla/5.0 (Linux; Tizen 2.3) "+ package.name + "/" + package.version + " AppleWebKit/538.1 (KHTML, like Gecko)Version/2.3 TV Safari/538.1";
const URL = "https://youtube.com/tv";
@@ -23,6 +28,10 @@ function fetchCookie(){
});
}
+app.on('ready', function() {
+ autoUpdater.checkForUpdatesAndNotify();
+});
+
app.whenReady().then(() => {
console.log("Started YouTube TV Client " + package.version);
createWindow();
@@ -40,6 +49,33 @@ app.whenReady().then(() => {
});
+ autoUpdater.on('checking-for-update', () => {
+ console.log('Checking for updates...');
+ });
+
+ autoUpdater.on('update-available', () => {
+ console.log('Update available.');
+ });
+
+
+ autoUpdater.on('update-not-available', () => {
+ console.log('No updates are currently available...');
+ });
+
+ autoUpdater.on('error', (err) => {
+ console.log('Error in auto-updater. ' + err);
+ });
+
+ autoUpdater.on('download-progress', (progressObj) => {
+ let log_message = "Download speed: " + progressObj.bytesPerSecond;
+ log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
+ log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
+ console.log(log_message);
+ });
+
+ autoUpdater.on('update-downloaded', (info) => {
+ console.log('Update downloaded');
+ });
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();