From a4175e9e06ba3699f03c68acd9d4fdd7d8db2865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Sun, 11 Mar 2018 00:43:54 +0000 Subject: [PATCH] Go to specific episode by giving its URL on the command line --- README.md | 4 +++- app/main.js | 15 +++++++++++++++ app/package.json | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 560c005..2bcdb94 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ To support [Marco Arment](http://www.marco.org/), author of Overcast, download t > “Share link” and “Share link with timestamp” copy link directly to the clipboard. -> Automatically goes back to home when episode ends. +> Automatically go back to home when episode ends. + +> Go to specific episode by giving its URL on the command line. Fog screenshotFog screenshot diff --git a/app/main.js b/app/main.js index 4efca2a..1f2e233 100644 --- a/app/main.js +++ b/app/main.js @@ -62,6 +62,14 @@ function focus_webview() { mainWindow.webContents.executeJavaScript('document.getElementById("overcast_webview").focus();'); } +function get_hostname(url) { + if (url.indexOf('://') > -1) { + return url.split('/')[2]; + } else { + return url.split('/')[0]; + } +} + app.on('ready', function() { const min_window_size = [352, 556] @@ -97,6 +105,13 @@ app.on('ready', function() { mainWindow.loadURL('file://' + __dirname + '/index.html'); focus_webview(); + // If given an overcast.fm URL as the argument, try to load it + const overcast_url = process.argv[1]; + if (overcast_url) { + if (get_hostname(overcast_url) != 'overcast.fm') throw new Error('Argument needs to be an overcast.fm URL') + mainWindow.webContents.executeJavaScript('document.getElementById("overcast_webview").src = "' + overcast_url + '"'); + } + // Media keys shortcuts globalShortcut.register('MediaPreviousTrack', function() { mainWindow.webContents.send('media_keys', 'seekbackbutton') }); globalShortcut.register('MediaNextTrack', function() { mainWindow.webContents.send('media_keys', 'seekforwardbutton'); }); diff --git a/app/package.json b/app/package.json index c1c5611..bfdab99 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "fog", - "version": "1.3.1", + "version": "1.4.0", "description": "Unofficial overcast.fm podcast app", "build": { "appId": "com.vitorgalvao.fog",