Skip to content

Commit

Permalink
Merge pull request #2 from ozankaraali/dev
Browse files Browse the repository at this point in the history
PiTV Stable: 1.0.1
  • Loading branch information
ozankaraali authored Mar 6, 2021
2 parents 794ff1a + 9756301 commit d8591b2
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 37 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ A cross-platform STB player client.

## Installation

You need a FFMPEG installation on your machine

You could download the software from [RELEASES](https://github.com/ozankaraali/PiTV/releases).

Alternatively, you could do:
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"config": {
"forge": {
"packagerConfig": {
"icon": "./icon",
"asar": true
"icon": "./icon"
},
"makers": [
{
Expand Down Expand Up @@ -56,9 +55,6 @@
}
],
"plugins": [
[
"@electron-forge/plugin-auto-unpack-natives"
],
[
"@electron-forge/plugin-webpack",
{
Expand Down Expand Up @@ -89,7 +85,7 @@
"@electron-forge/maker-zip": "^6.0.0-beta.54",
"@electron-forge/plugin-auto-unpack-natives": "^6.0.0-beta.54",
"@electron-forge/plugin-webpack": "6.0.0-beta.54",
"@marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
"@zeit/webpack-asset-relocator-loader": "^0.8.0",
"babel-loader": "^8.2.2",
"css-loader": "^4.2.1",
"electron": "11.3.0",
Expand All @@ -105,7 +101,9 @@
"electron-squirrel-startup": "^1.0.0",
"electron-window-state": "^5.0.3",
"express": "ozankaraali/express",
"ffmpeg-static": "3.0.0",
"fluent-ffmpeg": "^2.1.2",
"level": "^6.0.1",
"node-fetch": "^2.6.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
Expand All @@ -117,4 +115,4 @@
"web-vitals": "^1.0.1",
"yarn": "^1.22.10"
}
}
}
44 changes: 27 additions & 17 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import { parse } from 'url';
import os from 'os';
import { app as electronapp } from 'electron';
import fs from 'fs';
import ffmpegStatic from 'ffmpeg-static';
// const ffmpegStaticAsar = ffmpegStatic.replace('app.asar', 'app.asar.unpacked');

// import level from 'level'
fs.chmodSync(ffmpegStatic, 0o755)

import level from 'level'
// import console from 'console';
// const db = level(electronapp.getPath("userData")+"/settings")
const db = level(electronapp.getPath("userData")+"/settings")

const expressApp = express()
const port = 8000
Expand All @@ -29,12 +33,12 @@ let options = null

const readFromConfig = async() => {
try {
// url = await db.get('url')
// mac = await db.get('mac')
let file = fs.readFileSync(electronapp.getPath("userData")+"/conf.json")
let jsonfile = JSON.parse(file)
url = jsonfile.url
mac = jsonfile.mac
url = await db.get('url')
mac = await db.get('mac')
// let file = fs.readFileSync(electronapp.getPath("userData")+"/conf.json")
// let jsonfile = JSON.parse(file)
// url = jsonfile.url
// mac = jsonfile.mac

options = createOptions (url, mac)
return JSON.stringify({url: url, mac: mac})
Expand Down Expand Up @@ -71,17 +75,21 @@ expressApp.get('/config', async(req, res) => {
})

expressApp.post('/config', async(req, res) => {
// await db.put('url', req.body.url.trim())
// await db.put('mac', req.body.mac.trim().toUpperCase())
let jsondata = JSON.stringify({'url':req.body.url.trim(), 'mac':req.body.mac.trim().toUpperCase()})
fs.writeFileSync(electronapp.getPath("userData")+"/conf.json", jsondata, function (err) {
if (err) return console.log(err);
console.log('Hello World > helloworld.txt');
});
await db.put('url', req.body.url.trim())
await db.put('mac', req.body.mac.trim().toUpperCase())
// let jsondata = JSON.stringify({'url':req.body.url.trim(), 'mac':req.body.mac.trim().toUpperCase()})
// fs.writeFileSync(electronapp.getPath("userData")+"/conf.json", jsondata, function (err) {
// if (err) return console.log(err);
// console.log('Hello World > helloworld.txt');
// });
const isRead = await readFromConfig()
res.send(isRead)
})

expressApp.get('/ffmpeg', async (req, res) => {
res.send(JSON.stringify({"static": ffmpegStatic, "asar": ffmpegStaticAsar}))
})

expressApp.get('/allChannels', async (req, res) => {
if (options != null) {
// console.log(options)
Expand Down Expand Up @@ -166,8 +174,10 @@ expressApp.get('/stream/:link*', function (req, res) {
}

osDependentHwAccel()

ffmp.inputOptions(inputOptions)

ffmp
.setFfmpegPath(ffmpegStatic)
.inputOptions(inputOptions)
.outputOptions(outputOptions)
.format('ismv')
.on('error', (err) => {
Expand Down
2 changes: 1 addition & 1 deletion webpack.rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = [
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@marshallofsound/webpack-asset-relocator-loader',
loader: '@zeit/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
Expand Down
Loading

0 comments on commit d8591b2

Please sign in to comment.