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

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
jgierer12 committed Dec 21, 2018
0 parents commit 8e1b8e7
Show file tree
Hide file tree
Showing 24 changed files with 4,135 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": ["google", "eslint:recommended", "prettier"],
"plugins": ["prettier"],
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"rules": {
"prettier/prettier": "warn",
"quotes": ["warn", "backtick"],
"no-console": ["error", { "allow": ["warn", "error", "info"] }],
"consistent-return": "error",
"no-unused-vars": ["error", { "ignoreRestSiblings": true }],
"require-jsdoc": "off",
"valid-jsdoc": "off"
}
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# npm
node_modules

# logfiles
*.log

# build output
dist
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"trailingComma": "es5",
"proseWrap": "always"
}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2018 Jonas Gierer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Pocket Casts for Linux

Electron wrapper around the
[Pocket Casts web app](https://playbeta.pocketcasts.com/web/) with support for
MPRIS (media controls).

![App Screenshot](https://user-images.githubusercontent.com/4331946/50300325-5cc32d80-0484-11e9-8920-92399c93bb7c.png)
![Media Controls screenshot](https://user-images.githubusercontent.com/4331946/50300326-5d5bc400-0484-11e9-998f-87b771ef94be.png)

Pocket Casts is the world's most powerful podcast player. It's a great app to
discover and listen to your favorite podcasts. Many blogs have deemed Pocket
Casts the best podcatcher around.

You need to have a pre-existing Pocket Casts account (it's cheap and worth the
money) to use this app. You can purchase Pocket Casts on their
[official website](https://play.pocketcasts.com/).

> Inspired by
> [felicianotech/pocket-casts-desktop-app](https://github.com/felicianotech/pocket-casts-desktop-app)
## Installation

### AUR

```bash
sudo pacman -S pocket-casts-linux-bin
```

### AppImage

1. Download the AppImage binary from the [releases page](releases).
2. Execute the binary and answer "Yes" when prompted about system integration.

### Snap

> Coming soon!
## License

[MIT](LICENSE)
23 changes: 23 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
appId: pocket-casts-linux
productName: Pocket Casts
artifactName: "${name}-${version}-${arch}.${ext}"
linux:
icon: resources/icon
category: AudioVideo;Audio;
target:
- target: AppImage
arch:
- x64
- ia32
# - target: snap
# arch:
# - x64
# - ia32
- target: pacman
arch:
- x64
- ia32
- target: zip
arch:
- x64
- ia32
51 changes: 51 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"private": true,
"name": "pocket-casts-linux",
"version": "1.0.0",
"license": "MIT",
"description": "Electron wrapper around the Pocket Casts web app with support for MPRIS (media controls)",
"homepage": "https://github.com/jgierer12/pocket-casts-linux",
"author": {
"name": "Jonas Gierer",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/jgierer12/pocket-casts-linux.git"
},
"main": "src/index.js",
"scripts": {
"start": "electron .",
"prebuild": "sudo rm -rf dist",
"build": "sudo electron-builder",
"postbuild": "electron-builder install-app-deps",
"postinstall": "run-s postbuild",
"test": "run-s lint",
"format": "run-p -l format:*",
"format:js": "run-s \"_eslint -- --fix\"",
"format:other": "run-s \"_prettier -- --write\"",
"lint": "run-p -l -c lint:*",
"lint:js": "run-s _eslint",
"lint:other": "run-s \"_prettier -- --list-different\"",
"_eslint": "eslint --color --ignore-path .gitignore \"**/*.js\"",
"_prettier": "prettier --ignore-path .gitignore \"**/*.{json,md,mdx,yml,graphql}\""
},
"dependencies": {
"@trodi/electron-splashscreen": "^0.3.4",
"dom-loaded": "^1.0.1",
"electron-is-dev": "^1.0.1",
"mpris-service": "^1.1.4",
"select-dom": "^4.1.3"
},
"devDependencies": {
"electron": "^3.0.13",
"electron-builder": "^20.38.4",
"electron-reloader": "^0.2.0",
"eslint": "^5.10.0",
"eslint-config-google": "^0.11.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-prettier": "^3.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.15.3"
}
}
Binary file added resources/icon/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon/96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions resources/icon/src.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions src/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { ipcRenderer } = require(`electron`);
const isDev = require(`electron-is-dev`);
const domLoaded = require(`dom-loaded`);
const select = require(`select-dom`);

try {
isDev && require(`electron-reloader`)(module);
} catch (err) {
console.error(err);
}

domLoaded.then(() => {
const getControlsNode = () => select(`.player-controls > .controls`);
let hasControlsNode = false;

const observer = new MutationObserver(() => {
const controlsNode = getControlsNode();
if (!hasControlsNode && controlsNode) {
ipcRenderer.send(`playerReady`);
handlePlayerReady(controlsNode);
}
if (hasControlsNode && !controlsNode) {
ipcRenderer.send(`playerUnready`);
}
hasControlsNode = !!controlsNode;
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
});

const handlePlayerReady = controlsNode => {
const playBtn = select(`.play_pause_button`, controlsNode);
const isPlaying = () => playBtn.classList.contains(`pause_button`);

const podcastImg = select(`.podcast-image img`, controlsNode);
const episodeTitle = select(`.player_episode`, controlsNode);
const podcastTitle = select(`.player_podcast_title`, controlsNode);
const getMetadata = () => ({
podcastImg: podcastImg.src,
episodeTitle: episodeTitle.textContent,
podcastTitle: podcastTitle.textContent,
});

const skipBackBtn = select(`.skip_back_button`, controlsNode);
const skipForwardBtn = select(`.skip_forward_button`, controlsNode);

ipcRenderer.send(`metadataChange`, getMetadata());
ipcRenderer.send(`isPlayingChange`, isPlaying());

ipcRenderer.on(
`setPlaying`,
(ev, newPlaying) => isPlaying() !== newPlaying && playBtn.click()
);
ipcRenderer.on(`skipBack`, () => skipBackBtn.click());
ipcRenderer.on(`skipForward`, () => skipForwardBtn.click());

const playBtnObserver = new MutationObserver(() => {
ipcRenderer.send(`isPlayingChange`, isPlaying());
});
playBtnObserver.observe(playBtn, {
attributes: true,
attributeFilter: [`class`],
});

const episodeTitleObserver = new MutationObserver(() => {
ipcRenderer.send(`metadataChange`, getMetadata());
});
episodeTitleObserver.observe(episodeTitle, {
characterData: true,
subtree: true,
});
};
65 changes: 65 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const path = require(`path`);
const { ipcMain, shell, app } = require(`electron`);
const isDev = require(`electron-is-dev`);
const { initSplashScreen } = require(`@trodi/electron-splashscreen`);

const POCKET_CASTS_URL = `https://playbeta.pocketcasts.com/web/`;

try {
isDev && require(`electron-reloader`)(module);
} catch (err) {
console.error(err);
}

let window;

const createWindow = () => {
const size = { width: 1200, height: 800 };
window = initSplashScreen({
templateUrl: path.join(__dirname, `splash-screen`, `index.html`),
splashScreenOpts: size,
windowOpts: Object.assign(
{
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, `content.js`),
},
},
size
),
});
window.setMenuBarVisibility(false);

isDev && window.webContents.openDevTools();
window.loadURL(POCKET_CASTS_URL);

window.webContents.on(`new-window`, (ev, url) => {
ev.preventDefault();
shell.openExternal(url);
});

window.on(`closed`, () => {
window = null;
});
};

app.on(`ready`, createWindow);

app.on(`window-all-closed`, () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== `darwin`) {
app.quit();
}
});

app.on(`activate`, () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (window === null) {
createWindow();
}
});

ipcMain.once(`playerReady`, () => require(`./mpris`).init(window));
Loading

0 comments on commit 8e1b8e7

Please sign in to comment.