Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPV Plugin #62

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ insert_final_newline = true
max_line_length = 120
tab_width = 4

[{package.json, *.yml, *.yaml}]
[{*.yml, *.yaml, *.json}]
indent_size = 2
tab_width = 2
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@cromefire_:registry" "https://gitlab.com/api/v4/packages/npm"
3 changes: 2 additions & 1 deletion CONTRIBUTERS.md → CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Jellyfin Contributors
- [Cromefire_](https://github.com/cromefire)
- [winters-brown](https://github.com/winters-brown)
- [gravypod](https://github.com/gravypod)
- [lachlan](https://github.com/lachlan-00)
Expand All @@ -8,4 +9,4 @@
- [randomevents](https://github.com/randomevents)
- [hatharry](https://github.com/hatharry)
- [KeyserSoze1](https://github.com/KeyserSoze1)
- [heksesang](https://github.com/heksesang)
- [heksesang](https://github.com/heksesang)
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jellyfin-desktop",
"version": "1.0.0",
"version": "1.0.0-alpha0",
"description": "Jellyfin Desktop made with Electron",
"main": "build/main/main.js",
"scripts": {
Expand Down Expand Up @@ -40,9 +40,11 @@
},
"homepage": "https://github.com/jellyfin/jellyfin-desktop#readme",
"dependencies": {
"@cromefire_/nativeshell-api-definition": "^1.0.0-nightly5",
"comlink": "^4.3.0",
"comlink-electron-adapter": "^0.0.1",
"detect-rpi": "^1.4.0",
"electron-settings": "^3.2.0",
"is-windows": "^1.0.2",
"long": "^4.0.0",
"node-mpv": "^1.5.0",
"power-off": "^1.1.2",
Expand All @@ -56,7 +58,7 @@
"@types/node": "^12.12.37",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"electron": "^8.2.4",
"electron": "^8.5.0",
"electron-builder": "^22.5.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions src/common/ipc/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface MainApi {
appVersion(): string;
deviceId(): Promise<string>;
deviceName(): Promise<string>;
}
3 changes: 2 additions & 1 deletion src/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"importHelpers": true,
"lib": ["es2018"],
"types": [],
"composite": true
"composite": true,
"incremental": true
},
"include": ["./**/*.ts"],
"exclude": ["node_modules"]
Expand Down
35 changes: 35 additions & 0 deletions src/main/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { MainApi } from "../common/ipc/api";
import { app } from "electron";
import { hostname } from "os";
import { join } from "path";
import { promises as fs } from "fs";

const genRanHex = (size) => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join("");

async function exists(path: string) {
try {
await fs.access(path);
} catch (e) {
return false;
}
return true;
}

export class MainApiService implements MainApi {
appVersion(): string {
return app.getVersion();
}
async deviceId(): Promise<string> {
const deviceIdPath = join(app.getPath("userData"), "device.id");

if (await exists(deviceIdPath)) {
return fs.readFile(deviceIdPath, { encoding: "utf-8" });
}
const id = genRanHex(16);
await fs.writeFile(deviceIdPath, id, { encoding: "utf-8" });
return id;
}
deviceName(): Promise<string> {
return Promise.resolve(hostname());
}
}
2 changes: 1 addition & 1 deletion src/main/cec/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class CEC {
});

this.process.on("close", function (code) {
console.warn(`cec-client exited with code ${code}`);
console.info(`cec-client exited with code ${code}`);
logStream = createWriteStream(logFile, { flags: "a" });
logStream.write(`child process exited with code ${code}`);
logStream.end();
Expand Down
Loading