Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev/1.5.x' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
vexorian committed Nov 27, 2023
2 parents 32ddac1 + 393de74 commit c360dda
Show file tree
Hide file tree
Showing 32 changed files with 584 additions and 120 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/binaries-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Executables and Update Release

on:
workflow_call:
inputs:
release:
required: true
type: string

jobs:
release-files:
runs-on: ubuntu-latest
steps:

- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build dist image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile-builder
load: true
tags: builder
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run dist docker
run: |
docker run -v ./dist:/home/node/app/dist builder sh make_dist.sh
- name: Upload Files
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.release }}
files: |
./dist/dizquetv-win-x64.exe
./dist/dizquetv-win-x86.exe
./dist/dizquetv-linux-x64
./dist/dizquetv-macos-x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/development-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Development Binaries

on:
push:
branches:
- dev/1.5.x

jobs:
binaries:
uses: ./.github/workflows/binaries-build.yaml
with:
release: development-binaries
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/development-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Development Tag

on:
push:
branches:
- dev/1.5.x

jobs:
docker:
uses: ./.github/workflows/docker-build.yaml
with:
tag: development
secrets: inherit
43 changes: 43 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker Build

on:
workflow_call:
inputs:
tag:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Default
Dockerfile: Dockerfile
suffix: ""
- name: nvidia
Dockerfile: Dockerfile-nvidia
suffix: "-nvidia"

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: vexorian/dizquetv:${{ inputs.tag }}${{ matrix.suffix }}
cache-from: type=gha
cache-to: type=gha,mode=max
13 changes: 13 additions & 0 deletions .github/workflows/edge-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Edge Tag

on:
push:
branches:
- edge

jobs:
docker:
uses: ./.github/workflows/docker-build.yaml
with:
tag: edge
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/latest-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Latest Tag

on:
push:
branches:
- main

jobs:
docker:
uses: ./.github/workflows/docker-build.yaml
with:
tag: latest
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/named-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Named Tag

on:
push:
tags:
- '*'

jobs:
docker:
uses: ./.github/workflows/docker-build.yaml
with:
tag: ${{ github.ref_name }}
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/tag-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release Binaries

on:
push:
tags:
- "*"

jobs:
binaries:
uses: ./.github/workflows/binaries-build.yaml
with:
release: ${{ github.ref_name }}
secrets: inherit
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/prepare-commit-msg

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:12.18-alpine3.12
WORKDIR /home/node/app
COPY package*.json ./
COPY package.json ./
RUN npm install && npm install -g browserify nexe@3.3.7
COPY --from=vexorian/dizquetv:nexecache /var/nexe/linux-x64-12.16.2 /var/nexe/
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dizqueTV 1.5.0
# dizqueTV 1.5.1
![Discord](https://img.shields.io/discord/711313431457693727?logo=discord&logoColor=fff&style=flat-square) ![GitHub top language](https://img.shields.io/github/languages/top/vexorian/dizquetv?logo=github&style=flat-square) ![Docker Pulls](https://img.shields.io/docker/pulls/vexorian/dizquetv?logo=docker&logoColor=fff&style=flat-square)

Create live TV channel streams from media on your Plex servers.
Expand Down
19 changes: 18 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const EventService = require("./src/services/event-service");
const OnDemandService = require("./src/services/on-demand-service");
const ProgrammingService = require("./src/services/programming-service");
const ActiveChannelService = require('./src/services/active-channel-service')
const ProgramPlayTimeDB = require('./src/dao/program-play-time-db')

const onShutdown = require("node-graceful-shutdown").onShutdown;

Expand Down Expand Up @@ -95,7 +96,19 @@ channelService = new ChannelService(channelDB);

fillerDB = new FillerDB( path.join(process.env.DATABASE, 'filler') , channelService );
customShowDB = new CustomShowDB( path.join(process.env.DATABASE, 'custom-shows') );
let programPlayTimeDB = new ProgramPlayTimeDB( path.join(process.env.DATABASE, 'play-cache') );

async function initializeProgramPlayTimeDB() {
try {
let t0 = new Date().getTime();
await programPlayTimeDB.load();
let t1 = new Date().getTime();
console.log(`Program Play Time Cache loaded in ${t1-t0} milliseconds.`);
} catch (err) {
console.log(err);
}
}
initializeProgramPlayTimeDB();

fileCache = new FileCacheService( path.join(process.env.DATABASE, 'cache') );
cacheImageService = new CacheImageService(db, fileCache);
Expand Down Expand Up @@ -270,7 +283,7 @@ app.use('/custom.css', express.static(path.join(process.env.DATABASE, 'custom.cs
app.use(api.router(db, channelService, fillerDB, customShowDB, xmltvInterval, guideService, m3uService, eventService ))
app.use('/api/cache/images', cacheImageService.apiRouters())

app.use(video.router( channelService, fillerDB, db, programmingService, activeChannelService ))
app.use(video.router( channelService, fillerDB, db, programmingService, activeChannelService, programPlayTimeDB ))
app.use(hdhr.router)
app.listen(process.env.PORT, () => {
console.log(`HTTP server running on port: http://*:${process.env.PORT}`)
Expand Down Expand Up @@ -309,6 +322,10 @@ function initDB(db, channelDB) {
let data = fs.readFileSync(path.resolve(path.join(__dirname, 'resources/loading-screen.png')))
fs.writeFileSync(process.env.DATABASE + '/images/loading-screen.png', data)
}
if (!fs.existsSync(process.env.DATABASE + '/images/black.png')) {
let data = fs.readFileSync(path.resolve(path.join(__dirname, 'resources/black.png')))
fs.writeFileSync(process.env.DATABASE + '/images/black.png', data)
}
if (!fs.existsSync( path.join(process.env.DATABASE, 'custom.css') )) {
let data = fs.readFileSync(path.resolve(path.join(__dirname, 'resources', 'default-custom.css')))
fs.writeFileSync( path.join(process.env.DATABASE, 'custom.css'), data)
Expand Down
13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"dev-server": "nodemon index.js --ignore ./web/ --ignore ./db/ --ignore ./xmltv.xml",
"compile": "babel index.js -d dist && babel src -d dist/src",
"package": "sh ./make_dist.sh",
"clean": "del-cli --force ./bin ./dist ./.dizquetv ./web/public/bundle.js",
"prepare": "husky install"
"clean": "del-cli --force ./bin ./dist ./.dizquetv ./web/public/bundle.js"
},
"author": "vexorian",
"license": "Zlib",
Expand All @@ -35,9 +34,10 @@
"ng-i18next": "^1.0.7",
"node-graceful-shutdown": "1.1.0",
"node-ssdp": "^4.0.0",
"quickselect": "2.0.0",
"random-js": "2.1.0",
"request": "^2.88.2",
"uuid": "^8.0.0",
"uuid": "9.0.1",
"xml-writer": "^1.7.0"
},
"bin": "dist/index.js",
Expand All @@ -50,9 +50,7 @@
"@commitlint/config-conventional": "^12.1.4",
"browserify": "^16.5.1",
"copyfiles": "^2.2.0",
"cz-conventional-changelog": "^3.3.0",
"del-cli": "^3.0.0",
"husky": "^7.0.0",
"nexe": "^3.3.7",
"nodemon": "^2.0.3",
"watchify": "^3.11.1"
Expand All @@ -61,10 +59,5 @@
"plugins": [
"@babel/plugin-proposal-class-properties"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Binary file added resources/black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 16 additions & 17 deletions src/channel-cache.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const SLACK = require('./constants').SLACK;

let cache = {};
let programPlayTimeCache = {};

let fillerPlayTimeCache = {};
let configCache = {};
let numbers = null;
Expand All @@ -14,11 +14,9 @@ async function getChannelConfig(channelDB, channelId) {
if (channel == null) {
configCache[channelId] = [];
} else {
//console.log("channel=" + JSON.stringify(channel) );
configCache[channelId] = [channel];
}
}
//console.log("channel=" + JSON.stringify(configCache[channelId]).slice(0,200) );
return configCache[channelId];
}

Expand Down Expand Up @@ -106,7 +104,7 @@ function getCurrentLineupItem(channelId, t1) {
return lineupItem;
}

function getKey(channelId, program) {
function getProgramKey(program) {
let serverKey = "!unknown!";
if (typeof(program.serverKey) !== 'undefined') {
if (typeof(program.serverKey) !== 'undefined') {
Expand All @@ -117,36 +115,37 @@ function getKey(channelId, program) {
if (typeof(program.key) !== 'undefined') {
programKey = program.key;
}
return channelId + "|" + serverKey + "|" + programKey;

return serverKey + "|" + programKey;
}


function getFillerKey(channelId, fillerId) {
return channelId + "|" + fillerId;
}



function recordProgramPlayTime(channelId, lineupItem, t0) {
function recordProgramPlayTime(programPlayTime, channelId, lineupItem, t0) {
let remaining;
if ( typeof(lineupItem.streamDuration) !== 'undefined') {
remaining = lineupItem.streamDuration;
} else {
remaining = lineupItem.duration - lineupItem.start;
}
programPlayTimeCache[ getKey(channelId, lineupItem) ] = t0 + remaining;
setProgramLastPlayTime(programPlayTime, channelId, lineupItem, t0 + remaining);
if (typeof(lineupItem.fillerId) !== 'undefined') {
fillerPlayTimeCache[ getFillerKey(channelId, lineupItem.fillerId) ] = t0 + remaining;
}
}

function getProgramLastPlayTime(channelId, program) {
let v = programPlayTimeCache[ getKey(channelId, program) ];
if (typeof(v) === 'undefined') {
return 0;
} else {
return v;
}
function setProgramLastPlayTime(programPlayTime, channelId, lineupItem, t) {
let programKey = getProgramKey(lineupItem);
programPlayTime.update(channelId, programKey, t);
}

function getProgramLastPlayTime(programPlayTime, channelId, program) {
let programKey = getProgramKey(program);
return programPlayTime.getProgramLastPlayTime(channelId, programKey);
}

function getFillerLastPlayTime(channelId, fillerId) {
Expand All @@ -158,8 +157,8 @@ function getFillerLastPlayTime(channelId, fillerId) {
}
}

function recordPlayback(channelId, t0, lineupItem) {
recordProgramPlayTime(channelId, lineupItem, t0);
function recordPlayback(programPlayTime, channelId, t0, lineupItem) {
recordProgramPlayTime(programPlayTime, channelId, lineupItem, t0);

cache[channelId] = {
t0: t0,
Expand Down
Loading

0 comments on commit c360dda

Please sign in to comment.