Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Commit

Permalink
Go to specific episode by giving its URL on the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorgalvao committed Mar 11, 2018
1 parent 48034d2 commit a4175e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<img src='http://i.imgur.com/6robqC6.png' width='48%' alt='Fog screenshot'><img src='https://i.imgur.com/qjs5b7J.png' width='48%' alt='Fog screenshot'>

Expand Down
15 changes: 15 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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'); });
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a4175e9

Please sign in to comment.