From a1d7eb355f2c74184280c51b688d1bbd0c4e98b1 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 16 Aug 2021 20:47:25 -0400 Subject: Added an updater; Added snapcraft to readme --- index.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'index.js') 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(); -- cgit v1.2.3