Compare commits
81 Commits
2.1.1.0111
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f558a855ae | |||
| 125b0bb35f | |||
| 32c3d779c0 | |||
| ce5b12d8b8 | |||
| 76183bfaa2 | |||
| c577d354e7 | |||
| e48a061ca0 | |||
| ffd43d5217 | |||
| 9bd2b32003 | |||
| 8698983bbf | |||
| 60af423335 | |||
| 57b6be74e2 | |||
| c5545cbf08 | |||
| 339d2d0aa5 | |||
| a04b0ede50 | |||
| 84de46a2f2 | |||
| 5eaf5efdb6 | |||
| fb62353de4 | |||
| fa9d41e10c | |||
| e07d4dd878 | |||
| 6053207034 | |||
| 6a8b4bed28 | |||
| 45685ce592 | |||
| 43a9cf5a7e | |||
| a23cc7a183 | |||
| b069d5bee8 | |||
| 8cb9e43a72 | |||
|
|
0e999b85b9 | ||
|
|
e4b3667fe0 | ||
|
|
e44eff0645 | ||
|
|
884b427754 | ||
|
|
25bad13800 | ||
|
|
d2456b0506 | ||
|
|
19b9a259b1 | ||
|
|
441cefa3a4 | ||
|
|
014f5b7218 | ||
|
|
0310b7e738 | ||
|
|
6d890cfd33 | ||
|
|
410cc3648f | ||
|
|
07f9cac3c5 | ||
|
|
f43ce0f7c5 | ||
|
|
db59f7ef37 | ||
|
|
b407ec5bf0 | ||
|
|
d8fc1aea97 | ||
|
|
38333d65cb | ||
|
|
a6a9b90937 | ||
|
|
2b3fe6a09d | ||
|
|
a09eca59a7 | ||
|
|
0df3b4d755 | ||
|
|
5552514a1f | ||
|
|
5fceb1d34f | ||
|
|
fb5d0a3904 | ||
|
|
28fe4dcf1c | ||
|
|
bc307a7cd4 | ||
|
|
fd3024d7ff | ||
|
|
d3f6725ba6 | ||
|
|
c266012db3 | ||
|
|
d602b60710 | ||
|
|
67b7ba6df9 | ||
|
|
71dfe91272 | ||
|
|
534510a4ec | ||
|
|
2d10fc9313 | ||
|
|
a63a9c0d8f | ||
|
|
dd911d6e5d | ||
|
|
c1970a8393 | ||
|
|
493d612d52 | ||
|
|
4fc4330a94 | ||
|
|
a683533824 | ||
|
|
4b9f5826cf | ||
|
|
ca49d70910 | ||
|
|
1b425018d4 | ||
|
|
87b36c283b | ||
|
|
6da26ff4fb | ||
|
|
cd08985e79 | ||
|
|
dc04519229 | ||
|
|
c4ad96b715 | ||
|
|
45b5e602bb | ||
|
|
1cefbf022d | ||
|
|
d5328f6b1a | ||
|
|
91b80bc8bb | ||
|
|
aa763726a3 |
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.git
|
||||||
|
.github
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
docker-data
|
||||||
|
|
||||||
|
README-DEV.md
|
||||||
|
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
63
.drone.yml
Normal file
63
.drone.yml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: go-test
|
||||||
|
image: cache.coadcorp.com/library/golang
|
||||||
|
commands:
|
||||||
|
- go mod download
|
||||||
|
- go test ./...
|
||||||
|
|
||||||
|
- name: go-build
|
||||||
|
image: cache.coadcorp.com/library/golang
|
||||||
|
commands:
|
||||||
|
- XTEVE_VERSION="$(grep -m1 '^#### ' changelog-beta.md | cut -d' ' -f2 | sed 's/-beta$//')"
|
||||||
|
- test -n "$XTEVE_VERSION" || (echo "Could not parse version from changelog-beta.md" && exit 1)
|
||||||
|
- echo "Building xTeVe version $XTEVE_VERSION from changelog-beta.md"
|
||||||
|
- go build -v -ldflags "-X main.Version=$XTEVE_VERSION" ./...
|
||||||
|
|
||||||
|
- name: dockerfile-lint
|
||||||
|
image: cache.coadcorp.com/hadolint/hadolint:v2.12.0-alpine
|
||||||
|
commands:
|
||||||
|
- hadolint -t error Dockerfile
|
||||||
|
|
||||||
|
- name: compose-validate
|
||||||
|
image: cache.coadcorp.com/library/docker:27-cli
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache docker-cli-compose
|
||||||
|
- docker compose -f docker-compose.yml config -q
|
||||||
|
- docker compose -f docker-compose.host.yml config -q
|
||||||
|
|
||||||
|
- name: docker-build-validate
|
||||||
|
image: gcr.io/kaniko-project/executor:v1.23.2-debug
|
||||||
|
commands:
|
||||||
|
- /kaniko/executor --context "${DRONE_WORKSPACE}" --dockerfile "${DRONE_WORKSPACE}/Dockerfile" --no-push --destination xteve:validate --build-arg TARGETOS=linux --build-arg TARGETARCH=amd64 --build-arg XTEVE_UID=1000 --build-arg XTEVE_GID=1000
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
- name: docker-publish
|
||||||
|
image: plugins/docker
|
||||||
|
environment:
|
||||||
|
XTEVE_UID: "1000"
|
||||||
|
XTEVE_GID: "1000"
|
||||||
|
settings:
|
||||||
|
registry: registry.coadcorp.com
|
||||||
|
repo: registry.coadcorp.com/nathan/xteve
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
username: nathan
|
||||||
|
password:
|
||||||
|
from_secret: registry_password
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
build_args:
|
||||||
|
- TARGETOS=linux
|
||||||
|
- TARGETARCH=amd64
|
||||||
|
build_args_from_env:
|
||||||
|
- XTEVE_UID
|
||||||
|
- XTEVE_GID
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
demo
|
demo
|
||||||
|
dev
|
||||||
compiler
|
compiler
|
||||||
files
|
files
|
||||||
update_xteve*.sh
|
update_xteve*.sh
|
||||||
|
|||||||
52
Dockerfile
Normal file
52
Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
|
FROM golang:1.26-alpine AS builder
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go run ./cmd/webui-gen
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
RUN XTEVE_VERSION="$(grep -m1 '^#### ' changelog-beta.md | cut -d' ' -f2 | sed 's/-beta$//')" \
|
||||||
|
&& test -n "$XTEVE_VERSION" \
|
||||||
|
&& CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
|
||||||
|
go build -trimpath -ldflags="-s -w -X main.Version=$XTEVE_VERSION" -o /out/xteve ./xteve.go
|
||||||
|
|
||||||
|
FROM mwader/static-ffmpeg:latest AS ffmpeg
|
||||||
|
|
||||||
|
FROM alpine:3.23
|
||||||
|
|
||||||
|
ARG XTEVE_UID=1000
|
||||||
|
ARG XTEVE_GID=1000
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata \
|
||||||
|
&& addgroup -S -g "${XTEVE_GID}" xteve \
|
||||||
|
&& adduser -S -D -H -u "${XTEVE_UID}" -G xteve xteve \
|
||||||
|
&& mkdir -p /xteve/config \
|
||||||
|
&& chown -R xteve:xteve /xteve
|
||||||
|
|
||||||
|
WORKDIR /xteve
|
||||||
|
|
||||||
|
COPY --from=builder /out/xteve /usr/local/bin/xteve
|
||||||
|
COPY --from=ffmpeg /ffmpeg /usr/local/bin/ffmpeg
|
||||||
|
COPY --from=ffmpeg /ffprobe /usr/local/bin/ffprobe
|
||||||
|
COPY docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
USER xteve
|
||||||
|
|
||||||
|
EXPOSE 34400/tcp
|
||||||
|
|
||||||
|
ENV XTEVE_CONFIG=/xteve/config
|
||||||
|
ENV XTEVE_PORT=34400
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||||
|
CMD wget -qO- "http://127.0.0.1:${XTEVE_PORT}/lineup_status.json" > /dev/null || exit 1
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
56
README.md
56
README.md
@@ -48,6 +48,59 @@ Documentation for setup and configuration is [here](https://github.com/xteve-pro
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Project Analysis (UI + Operations)
|
||||||
|
|
||||||
|
The core architecture is strong: a Go backend with websocket-driven UI updates, filesystem-based state, and very low runtime overhead.
|
||||||
|
The weakest points are mostly operational and UX-focused:
|
||||||
|
|
||||||
|
* UI was historically utility-first and desktop-biased, with limited responsive behavior and visual hierarchy.
|
||||||
|
* Container usage was documented externally but there was no first-party Dockerfile/compose setup in this repository.
|
||||||
|
* Static web assets are generated into `src/webUI.go`, which works, but creates large diffs and a heavier edit/build cycle.
|
||||||
|
|
||||||
|
### Recommended next technical improvements
|
||||||
|
|
||||||
|
1. Replace generated `src/webUI.go` with Go `embed` for simpler static asset management and cleaner PR diffs.
|
||||||
|
2. Add CI checks (`go test ./...`, build on Linux/arm64/amd64, docker build smoke test).
|
||||||
|
3. Add a dedicated health endpoint (for example `/healthz`) to decouple health checks from HDHomeRun endpoints.
|
||||||
|
4. Add integration tests around websocket commands that mutate settings/files to reduce regression risk.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Container-First Run (Included In This Repo)
|
||||||
|
|
||||||
|
### Build image
|
||||||
|
```bash
|
||||||
|
docker build -t xteve:local .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run with Docker Compose (bridge mode)
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Compose file: `docker-compose.yml`
|
||||||
|
Persistent config volume: `./docker-data/config:/xteve/config`
|
||||||
|
|
||||||
|
### Run with Docker Compose (host networking, Linux recommended for discovery)
|
||||||
|
```bash
|
||||||
|
docker compose -f docker-compose.host.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Host networking improves LAN discovery behavior (SSDP/DLNA) for Plex/Emby in many setups.
|
||||||
|
|
||||||
|
### Container environment variables
|
||||||
|
|
||||||
|
* `XTEVE_CONFIG` (default: `/xteve/config`)
|
||||||
|
* `XTEVE_PORT` (default: `34400`)
|
||||||
|
|
||||||
|
### Image details
|
||||||
|
|
||||||
|
* Multi-stage build (Go builder + minimal Alpine runtime)
|
||||||
|
* Runs as non-root user (`xteve`)
|
||||||
|
* Built-in healthcheck against `http://127.0.0.1:${XTEVE_PORT}/lineup_status.json`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Downloads v2 | 64 Bit only
|
## Downloads v2 | 64 Bit only
|
||||||
#### 64 Bit Intel / AMD
|
#### 64 Bit Intel / AMD
|
||||||
|
|
||||||
@@ -117,7 +170,7 @@ When the branch is changed, an update is only performed if there is a new versio
|
|||||||
## Build from source code [Go / Golang]
|
## Build from source code [Go / Golang]
|
||||||
|
|
||||||
#### Requirements
|
#### Requirements
|
||||||
* [Go](https://golang.org) (go1.12.4 or newer)
|
* [Go](https://golang.org) (go1.16.2 or newer)
|
||||||
|
|
||||||
#### Dependencies
|
#### Dependencies
|
||||||
* [go-ssdp](https://github.com/koron/go-ssdp)
|
* [go-ssdp](https://github.com/koron/go-ssdp)
|
||||||
@@ -156,4 +209,3 @@ var GitHub = GitHubStruct{Branch: "master", User: "xteve-project", Repo: "xTeVe-
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
#### 2.2.0.0201-beta
|
||||||
|
Add UI enhancement for range selecting checkboxes
|
||||||
|
|
||||||
|
#### 2.2.0.0200-beta
|
||||||
|
```diff
|
||||||
|
+ Major web UI redesign focused on cleaner layout, better information hierarchy, and faster daily workflows.
|
||||||
|
+ Large mobile UX overhaul: responsive navigation, improved spacing, touch-friendly controls, and better small-screen mapping/config flows.
|
||||||
|
+ Accessibility pass across auth, configuration, and main app screens (focus visibility, keyboard flow, ARIA/announcer updates, contrast and status feedback improvements).
|
||||||
|
+ Settings UX improvements and additional polish in frontend behavior for menu, configuration, and authentication interactions.
|
||||||
|
+ Added optional Plex API refresh integration with new settings: use_plexAPI, plex.url, plex.token.
|
||||||
|
+ Added debounced/queued Plex DVR guide reload workflow after lineup and XEPG updates to reduce manual refresh work in Plex.
|
||||||
|
+ Container/runtime improvements and validation updates for easier, safer container usage.
|
||||||
|
+ Added Drone CI pipeline for tests/build checks, Docker/Compose validation, and Docker image publishing to registry.coadcorp.com via plugins/docker.
|
||||||
|
+ Pipeline build version is now derived from changelog-beta.md and validated against source version to prevent release/version drift.
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2.1.1.0116-beta
|
||||||
|
If no user agent is specified, the default FFmpeg or VLC user agent is used.
|
||||||
|
|
||||||
|
#### 2.1.1.0115-beta
|
||||||
|
```diff
|
||||||
|
+ GZIP compression for xteve.xml file. (http://xteve.ip:34400/xmltv/xteve.xml.gz)
|
||||||
|
- Removed protocol setting for reverse proxy. HTTPS can also be configured in the proxy, where it makes more sense.
|
||||||
|
```
|
||||||
|
|
||||||
#### 2.1.0.0106-beta
|
#### 2.1.0.0106-beta
|
||||||
```diff
|
```diff
|
||||||
+ User-Agent is now also used by VLC and FFmpeg.
|
+ User-Agent is now also used by VLC and FFmpeg.
|
||||||
|
|||||||
15
cmd/webui-gen/main.go
Normal file
15
cmd/webui-gen/main.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"xteve/src"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
src.HTMLInit("webUI", "src", "html"+string(os.PathSeparator), "src"+string(os.PathSeparator)+"webUI.go")
|
||||||
|
if err := src.BuildGoFile(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
18
docker-compose.host.yml
Normal file
18
docker-compose.host.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
services:
|
||||||
|
xteve:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
XTEVE_UID: ${XTEVE_UID:-1000}
|
||||||
|
XTEVE_GID: ${XTEVE_GID:-1000}
|
||||||
|
container_name: xteve
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
environment:
|
||||||
|
XTEVE_CONFIG: /xteve/config
|
||||||
|
XTEVE_PORT: "34400"
|
||||||
|
XTEVE_UID: ${XTEVE_UID:-1000}
|
||||||
|
XTEVE_GID: ${XTEVE_GID:-1000}
|
||||||
|
volumes:
|
||||||
|
- ./docker-data/config:/xteve/config
|
||||||
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
services:
|
||||||
|
xteve:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
XTEVE_UID: ${XTEVE_UID:-1000}
|
||||||
|
XTEVE_GID: ${XTEVE_GID:-1000}
|
||||||
|
container_name: xteve
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
XTEVE_CONFIG: /xteve/config
|
||||||
|
XTEVE_PORT: "34400"
|
||||||
|
XTEVE_UID: ${XTEVE_UID:-1000}
|
||||||
|
XTEVE_GID: ${XTEVE_GID:-1000}
|
||||||
|
ports:
|
||||||
|
- "34400:34400/tcp"
|
||||||
|
- "1900:1900/udp"
|
||||||
|
volumes:
|
||||||
|
- ./docker-data/config:/xteve/config
|
||||||
97
docker/entrypoint.sh
Executable file
97
docker/entrypoint.sh
Executable file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_DIR="/xteve/config"
|
||||||
|
LEGACY_CONFIG_DIRS="/config /xteve /home/xteve/.xteve"
|
||||||
|
|
||||||
|
resolve_config_dir() {
|
||||||
|
if [ -n "${XTEVE_CONFIG:-}" ] && [ "${XTEVE_CONFIG}" != "${DEFAULT_CONFIG_DIR}" ]; then
|
||||||
|
printf "%s" "${XTEVE_CONFIG}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "${DEFAULT_CONFIG_DIR}/settings.json" ]; then
|
||||||
|
printf "%s" "${DEFAULT_CONFIG_DIR}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
for dir in ${LEGACY_CONFIG_DIRS}; do
|
||||||
|
if [ -f "${dir}/settings.json" ]; then
|
||||||
|
printf "%s" "${dir}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
printf "%s" "${DEFAULT_CONFIG_DIR}"
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_if_missing() {
|
||||||
|
src="$1"
|
||||||
|
dst="$2"
|
||||||
|
|
||||||
|
if [ -e "${src}" ] && [ ! -e "${dst}" ]; then
|
||||||
|
cp -R "${src}" "${dst}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
settings_initialized() {
|
||||||
|
file="$1"
|
||||||
|
|
||||||
|
if [ ! -s "${file}" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q '"uuid"' "${file}" 2>/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
CONFIG_DIR="$(resolve_config_dir)"
|
||||||
|
PORT="${XTEVE_PORT:-34400}"
|
||||||
|
|
||||||
|
mkdir -p "${CONFIG_DIR}"
|
||||||
|
|
||||||
|
if ! settings_initialized "${CONFIG_DIR}/settings.json"; then
|
||||||
|
for legacy_dir in ${LEGACY_CONFIG_DIRS}; do
|
||||||
|
if [ "${legacy_dir}" = "${CONFIG_DIR}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if settings_initialized "${legacy_dir}/settings.json"; then
|
||||||
|
echo "[entrypoint] Migrating existing configuration from ${legacy_dir} to ${CONFIG_DIR}"
|
||||||
|
|
||||||
|
for file in authentication.json pms.json settings.json xepg.json urls.json; do
|
||||||
|
if [ "${file}" = "settings.json" ] || [ "${file}" = "xepg.json" ] || [ "${file}" = "urls.json" ]; then
|
||||||
|
cp -f "${legacy_dir}/${file}" "${CONFIG_DIR}/${file}" 2>/dev/null || true
|
||||||
|
else
|
||||||
|
copy_if_missing "${legacy_dir}/${file}" "${CONFIG_DIR}/${file}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for dir_name in data cache backup tmp; do
|
||||||
|
copy_if_missing "${legacy_dir}/${dir_name}" "${CONFIG_DIR}/${dir_name}"
|
||||||
|
done
|
||||||
|
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! touch "${CONFIG_DIR}/.xteve-write-test" 2>/dev/null; then
|
||||||
|
echo "[entrypoint] ERROR: Config directory is not writable: ${CONFIG_DIR}" >&2
|
||||||
|
echo "[entrypoint] Running as UID:GID $(id -u):$(id -g)" >&2
|
||||||
|
ls -ld "${CONFIG_DIR}" >&2 || true
|
||||||
|
echo "[entrypoint] Hint: ensure host path ownership/permissions allow this UID:GID to write, or set matching container UID/GID at build time." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
rm -f "${CONFIG_DIR}/.xteve-write-test"
|
||||||
|
|
||||||
|
echo "[entrypoint] Using config directory: ${CONFIG_DIR}"
|
||||||
|
echo "[entrypoint] Running as UID:GID $(id -u):$(id -g)"
|
||||||
|
if [ -f "${CONFIG_DIR}/settings.json" ]; then
|
||||||
|
echo "[entrypoint] settings.json details: $(ls -l "${CONFIG_DIR}/settings.json" | awk '{print $1, $3, $4, $5, $9}')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /usr/local/bin/xteve -config "${CONFIG_DIR}" -port "${PORT}" "$@"
|
||||||
14
go.mod
Normal file
14
go.mod
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
module xteve
|
||||||
|
|
||||||
|
go 1.25
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gorilla/websocket v1.5.3
|
||||||
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
|
||||||
|
github.com/koron/go-ssdp v0.1.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
golang.org/x/net v0.50.0 // indirect
|
||||||
|
golang.org/x/sys v0.41.0 // indirect
|
||||||
|
)
|
||||||
28
go.sum
Normal file
28
go.sum
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
|
||||||
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||||
|
github.com/koron/go-ssdp v0.0.2 h1:fL3wAoyT6hXHQlORyXUW4Q23kkQpJRgEAYcZB5BR71o=
|
||||||
|
github.com/koron/go-ssdp v0.0.2/go.mod h1:XoLfkAiA2KeZsYh4DbHxD7h3nR2AZNqVQOa+LJuqPYs=
|
||||||
|
github.com/koron/go-ssdp v0.1.0 h1:ckl5x5H6qSNFmi+wCuROvvGUu2FQnMbQrU95IHCcv3Y=
|
||||||
|
github.com/koron/go-ssdp v0.1.0/go.mod h1:GltaDBjtK1kemZOusWYLGotV0kBeEf59Bp0wtSB0uyU=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
|
||||||
|
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||||
|
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||||
|
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
|
||||||
|
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
|
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||||
|
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
@@ -13,16 +13,16 @@
|
|||||||
<script language="javascript" type="text/javascript" src="js/base_ts.js"></script>
|
<script language="javascript" type="text/javascript" src="js/base_ts.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="javascript: readyForConfiguration(0);">
|
<body class="auth-screen wizard-screen" onload="javascript: readyForConfiguration(0);">
|
||||||
|
|
||||||
<div id="loading" class="block">
|
<div id="loading" class="block" role="status" aria-live="polite" aria-label="Loading" aria-hidden="false">
|
||||||
<div class="loader"></div>
|
<div class="loader"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="header" class="imgCenter"></div>
|
<div id="header" class="imgCenter"></div>
|
||||||
<div id="box">
|
<main id="box" role="main" aria-labelledby="head-text">
|
||||||
|
|
||||||
<table id="clientInfo" class="visible">
|
<table id="clientInfo" class="visible" aria-label="Server information">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tdKey">Version:</td>
|
<td class="tdKey">Version:</td>
|
||||||
<td id="version" class="tdVal"> </td>
|
<td id="version" class="tdVal"> </td>
|
||||||
@@ -46,13 +46,14 @@
|
|||||||
<div id="headline">
|
<div id="headline">
|
||||||
<h1 id="head-text" class="center">Configuration</h1>
|
<h1 id="head-text" class="center">Configuration</h1>
|
||||||
</div>
|
</div>
|
||||||
<p id="err" class="errorMsg center"></p>
|
<p id="err" class="errorMsg center" role="alert" aria-live="assertive" aria-atomic="true"></p>
|
||||||
<div id="content">
|
<div id="content" role="region" aria-live="polite" aria-busy="false" tabindex="-1" aria-label="Configuration step">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<p id="sr-announcer" class="sr-only" aria-live="polite" aria-atomic="true"></p>
|
||||||
<div id="box-footer">
|
<div id="box-footer">
|
||||||
<input id="next" class="" type="button" name="next" value="Next" onclick="javascript: saveWizard();">
|
<input id="next" class="" type="button" name="next" value="Next" aria-controls="content" onclick="javascript: saveWizard();">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -10,38 +10,38 @@
|
|||||||
<script language="javascript" type="text/javascript" src="js/authentication_ts.js"></script>
|
<script language="javascript" type="text/javascript" src="js/authentication_ts.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class="auth-screen">
|
||||||
|
|
||||||
<div id="header" class="imgCenter"></div>
|
<div id="header" class="imgCenter"></div>
|
||||||
|
|
||||||
<div id="box">
|
<main id="box" role="main" aria-labelledby="head-text">
|
||||||
|
|
||||||
<div id="headline">
|
<div id="headline">
|
||||||
<h1 id="head-text" class="center">{{.account.headline}}</h1>
|
<h1 id="head-text" class="center">{{.account.headline}}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p id="err" class="errorMsg center"></p>
|
<p id="err" class="errorMsg center" role="alert" aria-live="assertive" aria-atomic="true"></p>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
<form id="authentication" action="/web/" method="post">
|
<form id="authentication" action="" method="post" aria-describedby="err" novalidate>
|
||||||
|
|
||||||
<h5>{{.account.username.title}}:</h5>
|
<label for="username">{{.account.username.title}}:</label>
|
||||||
<input id="username" type="text" name="username" placeholder="Username" value="">
|
<input id="username" type="text" name="username" placeholder="Username" value="" autocomplete="username">
|
||||||
<h5>{{.account.password.title}}:</h5>
|
<label for="password">{{.account.password.title}}:</label>
|
||||||
<input id="password" type="password" name="password" placeholder="Password" value="">
|
<input id="password" type="password" name="password" placeholder="Password" value="" autocomplete="new-password">
|
||||||
<h5>{{.account.confirm.title}}:</h5>
|
<label for="confirm">{{.account.confirm.title}}:</label>
|
||||||
<input id="confirm" type="password" name="confirm" placeholder="Confirm" value="">
|
<input id="confirm" type="password" name="confirm" placeholder="Confirm" value="" autocomplete="new-password">
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="box-footer">
|
<div id="box-footer">
|
||||||
<input id="submit" class="" type="button" value="{{.button.craeteAccount}}" onclick="javascript: login();">
|
<input id="submit" class="" type="button" value="{{.button.craeteAccount}}" aria-label="{{.button.craeteAccount}}" onclick="javascript: login();">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
File diff suppressed because it is too large
Load Diff
1322
html/css/screen.css
1322
html/css/screen.css
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<!---
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
-->
|
|
||||||
<title>xTeVe</title>
|
<title>xTeVe</title>
|
||||||
<link rel="stylesheet" href="css/screen.css" type="text/css">
|
<link rel="stylesheet" href="css/screen.css" type="text/css">
|
||||||
<link rel="stylesheet" href="css/base.css" type="text/css">
|
<link rel="stylesheet" href="css/base.css" type="text/css">
|
||||||
@@ -17,16 +15,19 @@
|
|||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="javascript: PageReady();">
|
<body class="app-shell" onload="javascript: PageReady();">
|
||||||
|
|
||||||
<div id="loading" class="none">
|
<a class="skip-link" href="#content">Skip to main content</a>
|
||||||
|
|
||||||
|
<div id="loading" class="none" role="status" aria-live="polite" aria-label="Loading" aria-hidden="true">
|
||||||
<div class="loader"></div>
|
<div class="loader"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="popup" class="none">
|
<div id="popup" class="none" role="dialog" aria-modal="true" aria-hidden="true" tabindex="-1">
|
||||||
<div id="popup-custom"></div>
|
<div id="popup-custom" role="document" tabindex="-1"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="layout-overlay" aria-hidden="true" tabindex="-1"></div>
|
||||||
<div id="layout">
|
<div id="layout">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -40,55 +41,62 @@
|
|||||||
</div>
|
</div>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div id="menu-wrapper" class="layout-left">
|
<aside id="menu-wrapper" class="layout-left" aria-label="Sidebar menu">
|
||||||
<div id= "branch"></div>
|
<div id= "branch"></div>
|
||||||
<div id="logo"></div>
|
<div id="logo"></div>
|
||||||
<nav id="main-menu"></nav>
|
<nav id="main-menu" role="menubar" aria-label="Main navigation"></nav>
|
||||||
</div>
|
</aside>
|
||||||
|
|
||||||
<div class="layout-right">
|
<main id="shell-main" class="layout-right">
|
||||||
|
<header id="shell-header">
|
||||||
|
<button id="menu-toggle" type="button" aria-expanded="false" aria-controls="menu-wrapper" aria-label="Toggle navigation menu">Menu</button>
|
||||||
|
<h2 id="shell-title">xTeVe Control Panel</h2>
|
||||||
|
<p id="connection-indicator" class="status-idle" role="status" aria-live="polite" aria-atomic="true">Connecting...</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
<table id="clientInfo" class="">
|
<table id="clientInfo" class="" aria-label="Server information">
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tdKey">xTeVe:</td>
|
<td class="tdKey">xTeVe:</td>
|
||||||
<td id="version" class="tdVal"> </td>
|
<td id="version" class="tdVal" data-label="xTeVe"> </td>
|
||||||
<td class="tdKey">OS:</td>
|
<td class="tdKey">OS:</td>
|
||||||
<td id="os" class="tdVal"> </td>
|
<td id="os" class="tdVal" data-label="OS"> </td>
|
||||||
<td class="tdKey phone">DVR IP:</td>
|
<td class="tdKey phone">DVR IP:</td>
|
||||||
<td id="DVR" class="tdVal phone"> </td>
|
<td id="DVR" class="tdVal phone" data-label="DVR IP"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tdKey">UUID:</td>
|
<td class="tdKey">UUID:</td>
|
||||||
<td id="uuid" class="tdVal"> </td>
|
<td id="uuid" class="tdVal" data-label="UUID"> </td>
|
||||||
<td class="tdKey">Arch:</td>
|
<td class="tdKey">Arch:</td>
|
||||||
<td id="arch" class="tdVal"> </td>
|
<td id="arch" class="tdVal" data-label="Arch"> </td>
|
||||||
<td class="tdKey phone">M3U URL:</td>
|
<td class="tdKey phone">M3U URL:</td>
|
||||||
<td id="m3u-url" class="tdVal phone"> </td>
|
<td id="m3u-url" class="tdVal phone" data-label="M3U URL"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tdKey">Available Streams:</td>
|
<td class="tdKey">Available Streams:</td>
|
||||||
<td id="streams" class="tdVal"> </td>
|
<td id="streams" class="tdVal" data-label="Available Streams"> </td>
|
||||||
<td class="tdKey">EPG Source:</td>
|
<td class="tdKey">EPG Source:</td>
|
||||||
<td id="epgSource" class="tdVal"> </td>
|
<td id="epgSource" class="tdVal" data-label="EPG Source"> </td>
|
||||||
<td class="tdKey phone">XEPG URL:</td>
|
<td class="tdKey phone">XEPG URL:</td>
|
||||||
<td id="xepg-url" class="tdVal phone"> </td>
|
<td id="xepg-url" class="tdVal phone" data-label="XEPG URL"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tdKey">XEPG Channels:</td>
|
<td class="tdKey">XEPG Channels:</td>
|
||||||
<td id="xepg" class="tdVal"> </td>
|
<td id="xepg" class="tdVal" data-label="XEPG Channels"> </td>
|
||||||
<td class="tdKey">Errors:</td>
|
<td class="tdKey">Errors:</td>
|
||||||
<td id="errors" class="tdVal"> </td>
|
<td id="errors" class="tdVal" data-label="Errors"> </td>
|
||||||
<td class="tdKey">Warnings:</td>
|
<td class="tdKey">Warnings:</td>
|
||||||
<td id="warnings" class="tdVal"> </td>
|
<td id="warnings" class="tdVal" data-label="Warnings"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="myStreamsBox" class="notVisible">
|
<div id="status-cards" class="dashboard-cards" role="list" aria-live="polite" aria-label="System summary"></div>
|
||||||
|
|
||||||
|
<div id="myStreamsBox" class="notVisible" aria-live="polite" aria-label="Stream details">
|
||||||
|
|
||||||
<div id="allStreams">
|
<div id="allStreams">
|
||||||
<table id="activeStreams"></table>
|
<table id="activeStreams"></table>
|
||||||
@@ -97,9 +105,10 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content" class=""></div>
|
<div id="content" class="" role="region" aria-live="polite" aria-busy="false" tabindex="-1" aria-label="Main content"></div>
|
||||||
|
<p id="sr-announcer" class="sr-only" aria-live="polite" aria-atomic="true"></p>
|
||||||
|
|
||||||
</div>
|
</main>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
function login() {
|
function login() {
|
||||||
var err = false;
|
var err = false;
|
||||||
|
var firstInvalid = null;
|
||||||
var data = new Object();
|
var data = new Object();
|
||||||
var div = document.getElementById("content");
|
var div = document.getElementById("content");
|
||||||
var form = document.getElementById("authentication");
|
var form = document.getElementById("authentication");
|
||||||
|
var errElement = document.getElementById("err");
|
||||||
|
if (errElement != null) {
|
||||||
|
errElement.innerHTML = "";
|
||||||
|
}
|
||||||
var inputs = div.getElementsByTagName("INPUT");
|
var inputs = div.getElementsByTagName("INPUT");
|
||||||
console.log(inputs);
|
console.log(inputs);
|
||||||
for (var i = inputs.length - 1; i >= 0; i--) {
|
for (var i = inputs.length - 1; i >= 0; i--) {
|
||||||
@@ -10,23 +15,54 @@ function login() {
|
|||||||
var value = inputs[i].value;
|
var value = inputs[i].value;
|
||||||
if (value.length == 0) {
|
if (value.length == 0) {
|
||||||
inputs[i].style.borderColor = "red";
|
inputs[i].style.borderColor = "red";
|
||||||
|
inputs[i].setAttribute("aria-invalid", "true");
|
||||||
|
if (firstInvalid == null) {
|
||||||
|
firstInvalid = inputs[i];
|
||||||
|
}
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
inputs[i].style.borderColor = "";
|
||||||
|
inputs[i].setAttribute("aria-invalid", "false");
|
||||||
|
}
|
||||||
data[key] = value;
|
data[key] = value;
|
||||||
}
|
}
|
||||||
if (err == true) {
|
if (err == true) {
|
||||||
|
if (firstInvalid != null) {
|
||||||
|
firstInvalid.focus();
|
||||||
|
}
|
||||||
data = new Object();
|
data = new Object();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty("confirm")) {
|
if (data.hasOwnProperty("confirm")) {
|
||||||
if (data["confirm"] != data["password"]) {
|
if (data["confirm"] != data["password"]) {
|
||||||
alert("sdafsd");
|
|
||||||
document.getElementById('password').style.borderColor = "red";
|
document.getElementById('password').style.borderColor = "red";
|
||||||
document.getElementById('confirm').style.borderColor = "red";
|
document.getElementById('confirm').style.borderColor = "red";
|
||||||
|
document.getElementById('password').setAttribute("aria-invalid", "true");
|
||||||
|
document.getElementById('confirm').setAttribute("aria-invalid", "true");
|
||||||
document.getElementById("err").innerHTML = "{{.account.failed}}";
|
document.getElementById("err").innerHTML = "{{.account.failed}}";
|
||||||
|
document.getElementById('password').focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(data);
|
console.log(data);
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
var form = document.getElementById("authentication");
|
||||||
|
if (form == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var inputs = form.getElementsByTagName("INPUT");
|
||||||
|
for (var i = 0; i < inputs.length; i++) {
|
||||||
|
inputs[i].addEventListener("keydown", function (event) {
|
||||||
|
if (event.key == "Enter") {
|
||||||
|
event.preventDefault();
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (inputs.length > 0) {
|
||||||
|
inputs[0].focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ var SEARCH_MAPPING = new Object();
|
|||||||
var UNDO = new Object();
|
var UNDO = new Object();
|
||||||
var SERVER_CONNECTION = false;
|
var SERVER_CONNECTION = false;
|
||||||
var WS_AVAILABLE = false;
|
var WS_AVAILABLE = false;
|
||||||
// Menü
|
var ACTIVE_MENU_ID = "";
|
||||||
|
var LAST_FOCUSED_ELEMENT = null;
|
||||||
|
var LAST_BULK_CHECKBOX = null;
|
||||||
|
// Menu
|
||||||
var menuItems = new Array();
|
var menuItems = new Array();
|
||||||
menuItems.push(new MainMenuItem("playlist", "{{.mainMenu.item.playlist}}", "m3u.png", "{{.mainMenu.headline.playlist}}"));
|
menuItems.push(new MainMenuItem("playlist", "{{.mainMenu.item.playlist}}", "m3u.png", "{{.mainMenu.headline.playlist}}"));
|
||||||
//menuItems.push(new MainMenuItem("pmsID", "{{.mainMenu.item.pmsID}}", "number.png", "{{.mainMenu.headline.pmsID}}"))
|
//menuItems.push(new MainMenuItem("pmsID", "{{.mainMenu.item.pmsID}}", "number.png", "{{.mainMenu.headline.pmsID}}"))
|
||||||
@@ -18,9 +21,9 @@ menuItems.push(new MainMenuItem("log", "{{.mainMenu.item.log}}", "log.png", "{{.
|
|||||||
menuItems.push(new MainMenuItem("logout", "{{.mainMenu.item.logout}}", "logout.png", "{{.mainMenu.headline.logout}}"));
|
menuItems.push(new MainMenuItem("logout", "{{.mainMenu.item.logout}}", "logout.png", "{{.mainMenu.headline.logout}}"));
|
||||||
// Kategorien für die Einstellungen
|
// Kategorien für die Einstellungen
|
||||||
var settingsCategory = new Array();
|
var settingsCategory = new Array();
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.general}}", "xteveAutoUpdate,tuner,epgSource,api,scheme.m3u,scheme.xml"));
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.general}}", "xteveAutoUpdate,tuner,epgSource,api,use_plexAPI,plex.url,plex.token"));
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.files}}", "update,files.update,temp.path,cache.images,xepg.replace.missing.images"));
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.files}}", "update,files.update,temp.path,cache.images,xepg.missing.epg.mode,xepg.replace.missing.images"));
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.streaming}}", "buffer,buffer.size.kb,buffer.timeout,user.agent,ffmpeg.path,ffmpeg.options,vlc.path,vlc.options"));
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.streaming}}", "buffer,udpxy,buffer.size.kb,buffer.timeout,user.agent,ffmpeg.path,ffmpeg.options,vlc.path,vlc.options"));
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.backup}}", "backup.path,backup.keep"));
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.backup}}", "backup.path,backup.keep"));
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.authentication}}", "authentication.web,authentication.pms,authentication.m3u,authentication.xml,authentication.api"));
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.authentication}}", "authentication.web,authentication.pms,authentication.m3u,authentication.xml,authentication.api"));
|
||||||
function showPopUpElement(elm) {
|
function showPopUpElement(elm) {
|
||||||
@@ -44,7 +47,74 @@ function showElement(elmID, type) {
|
|||||||
cssClass = "none";
|
cssClass = "none";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
document.getElementById(elmID).className = cssClass;
|
var element = document.getElementById(elmID);
|
||||||
|
if (element == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.className = cssClass;
|
||||||
|
element.setAttribute("aria-hidden", type == true ? "false" : "true");
|
||||||
|
if (elmID == "loading" && document.body != null) {
|
||||||
|
document.body.setAttribute("aria-busy", type == true ? "true" : "false");
|
||||||
|
}
|
||||||
|
if (elmID == "popup") {
|
||||||
|
var popupContent_1 = document.getElementById("popup-custom");
|
||||||
|
if (type == true) {
|
||||||
|
LAST_FOCUSED_ELEMENT = document.activeElement;
|
||||||
|
if (popupContent_1 != null) {
|
||||||
|
setTimeout(function () {
|
||||||
|
popupContent_1.focus();
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (LAST_FOCUSED_ELEMENT != null && LAST_FOCUSED_ELEMENT.focus != undefined) {
|
||||||
|
setTimeout(function () {
|
||||||
|
LAST_FOCUSED_ELEMENT.focus();
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
LAST_FOCUSED_ELEMENT = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function announceToScreenReader(message) {
|
||||||
|
if (message == undefined || message.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var region = document.getElementById("sr-announcer");
|
||||||
|
if (region == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
region.innerText = "";
|
||||||
|
setTimeout(function () {
|
||||||
|
region.innerText = message;
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
function setConnectionState(state, text) {
|
||||||
|
var label = text;
|
||||||
|
if (label == undefined || label.length == 0) {
|
||||||
|
switch (state) {
|
||||||
|
case "online":
|
||||||
|
label = "Connected";
|
||||||
|
break;
|
||||||
|
case "busy":
|
||||||
|
label = "Syncing";
|
||||||
|
break;
|
||||||
|
case "offline":
|
||||||
|
label = "Offline";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
label = "Connecting";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var indicator = document.getElementById("connection-indicator");
|
||||||
|
if (indicator == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
indicator.className = "status-" + state;
|
||||||
|
indicator.innerText = label;
|
||||||
|
indicator.setAttribute("aria-label", "Connection status: " + label);
|
||||||
|
announceToScreenReader("Connection status " + label);
|
||||||
}
|
}
|
||||||
function changeButtonAction(element, buttonID, attribute) {
|
function changeButtonAction(element, buttonID, attribute) {
|
||||||
var value = element.options[element.selectedIndex].value;
|
var value = element.options[element.selectedIndex].value;
|
||||||
@@ -114,6 +184,48 @@ function getAllSelectedChannels() {
|
|||||||
}
|
}
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
function scheduleChannelRangeSelection(checkbox, event) {
|
||||||
|
var shiftPressed = false;
|
||||||
|
if (event != undefined && event.shiftKey == true) {
|
||||||
|
shiftPressed = true;
|
||||||
|
}
|
||||||
|
// Run after the native checkbox toggle so we copy the final checked state.
|
||||||
|
setTimeout(function () {
|
||||||
|
selectChannelRange(checkbox, shiftPressed);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
function selectChannelRange(checkbox, shiftPressed) {
|
||||||
|
if (BULK_EDIT == false || checkbox == undefined || checkbox == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var table = document.getElementById("content_table");
|
||||||
|
if (table == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var trs = table.getElementsByTagName("TR");
|
||||||
|
var visibleCheckboxes = new Array();
|
||||||
|
for (var i = 1; i < trs.length; i++) {
|
||||||
|
if (trs[i].style.display != "none") {
|
||||||
|
var bulkCheckbox = trs[i].querySelector("input.bulk");
|
||||||
|
if (bulkCheckbox != null) {
|
||||||
|
visibleCheckboxes.push(bulkCheckbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var currentIndex = visibleCheckboxes.indexOf(checkbox);
|
||||||
|
var previousIndex = -1;
|
||||||
|
if (LAST_BULK_CHECKBOX != null) {
|
||||||
|
previousIndex = visibleCheckboxes.indexOf(LAST_BULK_CHECKBOX);
|
||||||
|
}
|
||||||
|
if (shiftPressed == true && previousIndex > -1 && currentIndex > -1) {
|
||||||
|
var start = Math.min(previousIndex, currentIndex);
|
||||||
|
var end = Math.max(previousIndex, currentIndex);
|
||||||
|
for (var i = start; i <= end; i++) {
|
||||||
|
visibleCheckboxes[i].checked = checkbox.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LAST_BULK_CHECKBOX = checkbox;
|
||||||
|
}
|
||||||
function selectAllChannels() {
|
function selectAllChannels() {
|
||||||
var bulk = false;
|
var bulk = false;
|
||||||
var trs = document.getElementById("content_table").getElementsByTagName("TR");
|
var trs = document.getElementById("content_table").getElementsByTagName("TR");
|
||||||
@@ -132,6 +244,7 @@ function selectAllChannels() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LAST_BULK_CHECKBOX = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
function bulkEdit() {
|
function bulkEdit() {
|
||||||
@@ -150,6 +263,7 @@ function bulkEdit() {
|
|||||||
rows[i].className = className;
|
rows[i].className = className;
|
||||||
rows[i].checked = false;
|
rows[i].checked = false;
|
||||||
}
|
}
|
||||||
|
LAST_BULK_CHECKBOX = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
function sortTable(column) {
|
function sortTable(column) {
|
||||||
@@ -160,15 +274,29 @@ function sortTable(column) {
|
|||||||
var table = document.getElementById("content_table");
|
var table = document.getElementById("content_table");
|
||||||
var tableHead = table.getElementsByTagName("TR")[0];
|
var tableHead = table.getElementsByTagName("TR")[0];
|
||||||
var tableItems = tableHead.getElementsByTagName("TD");
|
var tableItems = tableHead.getElementsByTagName("TD");
|
||||||
|
for (var h = 0; h < tableItems.length; h++) {
|
||||||
|
if (tableItems[h].getAttribute("role") == "columnheader") {
|
||||||
|
tableItems[h].setAttribute("aria-sort", "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
var sortObj = new Object();
|
var sortObj = new Object();
|
||||||
var x, xValue;
|
var x, xValue;
|
||||||
var tableHeader;
|
var tableHeader;
|
||||||
var sortByString = false;
|
var sortByString = false;
|
||||||
if (column > 0 && COLUMN_TO_SORT > 0) {
|
if (column > 0 && COLUMN_TO_SORT > 0) {
|
||||||
tableItems[COLUMN_TO_SORT].className = "pointer";
|
tableItems[COLUMN_TO_SORT].classList.remove("sortThis");
|
||||||
tableItems[column].className = "sortThis";
|
tableItems[COLUMN_TO_SORT].classList.add("pointer");
|
||||||
|
tableItems[column].classList.remove("pointer");
|
||||||
|
tableItems[column].classList.add("sortThis");
|
||||||
}
|
}
|
||||||
COLUMN_TO_SORT = column;
|
COLUMN_TO_SORT = column;
|
||||||
|
var mobileSort = document.getElementById("mapping-sort-mobile");
|
||||||
|
if (mobileSort != null && (column == 1 || column == 3 || column == 4 || column == 5)) {
|
||||||
|
mobileSort.value = column.toString();
|
||||||
|
}
|
||||||
|
if (tableItems[column] != undefined && tableItems[column].getAttribute("role") == "columnheader") {
|
||||||
|
tableItems[column].setAttribute("aria-sort", "ascending");
|
||||||
|
}
|
||||||
var rows = table.rows;
|
var rows = table.rows;
|
||||||
if (rows[1] != undefined) {
|
if (rows[1] != undefined) {
|
||||||
tableHeader = rows[0];
|
tableHeader = rows[0];
|
||||||
@@ -226,8 +354,9 @@ function createSearchObj() {
|
|||||||
SEARCH_MAPPING = new Object();
|
SEARCH_MAPPING = new Object();
|
||||||
var data = SERVER["xepg"]["epgMapping"];
|
var data = SERVER["xepg"]["epgMapping"];
|
||||||
var channels = getObjKeys(data);
|
var channels = getObjKeys(data);
|
||||||
var channelKeys = ["x-active", "x-channelID", "x-name", "_file.m3u.name", "x-group-title"];
|
var channelKeys = ["x-active", "x-channelID", "x-name", "_file.m3u.name", "x-group-title", "x-xmltv-file"];
|
||||||
channels.forEach(function (id) {
|
channels.forEach(function (id) {
|
||||||
|
SEARCH_MAPPING[id] = "";
|
||||||
channelKeys.forEach(function (key) {
|
channelKeys.forEach(function (key) {
|
||||||
if (key == "x-active") {
|
if (key == "x-active") {
|
||||||
switch (data[id][key]) {
|
switch (data[id][key]) {
|
||||||
@@ -240,7 +369,15 @@ function createSearchObj() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SEARCH_MAPPING[id] = SEARCH_MAPPING[id] + data[id][key] + " ";
|
if (key == "x-xmltv-file") {
|
||||||
|
var xmltvFile = getValueFromProviderFile(data[id][key], "xmltv", "name");
|
||||||
|
if (xmltvFile != undefined) {
|
||||||
|
SEARCH_MAPPING[id] = SEARCH_MAPPING[id] + xmltvFile + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SEARCH_MAPPING[id] = SEARCH_MAPPING[id] + data[id][key] + " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -252,6 +389,9 @@ function searchInMapping() {
|
|||||||
for (var i = 1; i < trs.length; ++i) {
|
for (var i = 1; i < trs.length; ++i) {
|
||||||
var id = trs[i].getAttribute("id");
|
var id = trs[i].getAttribute("id");
|
||||||
var element = SEARCH_MAPPING[id];
|
var element = SEARCH_MAPPING[id];
|
||||||
|
if (element == undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (element.toLowerCase().includes(searchValue.toLowerCase())) {
|
switch (element.toLowerCase().includes(searchValue.toLowerCase())) {
|
||||||
case true:
|
case true:
|
||||||
document.getElementById(id).style.display = "";
|
document.getElementById(id).style.display = "";
|
||||||
@@ -261,17 +401,19 @@ function searchInMapping() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
announceToScreenReader("Search updated");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
function calculateWrapperHeight() {
|
function calculateWrapperHeight() {
|
||||||
if (document.getElementById("box-wrapper")) {
|
var elm = document.getElementById("box-wrapper");
|
||||||
var elm = document.getElementById("box-wrapper");
|
var content = document.getElementById("content");
|
||||||
var divs = new Array("myStreamsBox", "clientInfo", "content");
|
if (elm != null && content != null) {
|
||||||
var elementsHeight = 0 - elm.offsetHeight;
|
var contentTop = content.getBoundingClientRect().top;
|
||||||
for (var i = 0; i < divs.length; i++) {
|
var freeSpace = window.innerHeight - contentTop - 26;
|
||||||
elementsHeight = elementsHeight + document.getElementById(divs[i]).offsetHeight;
|
if (freeSpace < 180) {
|
||||||
|
freeSpace = 180;
|
||||||
}
|
}
|
||||||
elm.style.height = window.innerHeight - elementsHeight + "px";
|
elm.style.height = freeSpace + "px";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var __extends = (this && this.__extends) || (function () {
|
|||||||
var extendStatics = function (d, b) {
|
var extendStatics = function (d, b) {
|
||||||
extendStatics = Object.setPrototypeOf ||
|
extendStatics = Object.setPrototypeOf ||
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||||
return extendStatics(d, b);
|
return extendStatics(d, b);
|
||||||
};
|
};
|
||||||
return function (d, b) {
|
return function (d, b) {
|
||||||
@@ -35,7 +35,9 @@ var WizardItem = /** @class */ (function (_super) {
|
|||||||
var key = this.key;
|
var key = this.key;
|
||||||
var content = new PopupContent();
|
var content = new PopupContent();
|
||||||
var description;
|
var description;
|
||||||
|
var wizardField = null;
|
||||||
var doc = document.getElementById(this.DocumentID);
|
var doc = document.getElementById(this.DocumentID);
|
||||||
|
doc.setAttribute("aria-busy", "true");
|
||||||
doc.innerHTML = "";
|
doc.innerHTML = "";
|
||||||
doc.appendChild(headline);
|
doc.appendChild(headline);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -50,6 +52,7 @@ var WizardItem = /** @class */ (function (_super) {
|
|||||||
select.setAttribute("class", "wizard");
|
select.setAttribute("class", "wizard");
|
||||||
select.id = key;
|
select.id = key;
|
||||||
doc.appendChild(select);
|
doc.appendChild(select);
|
||||||
|
wizardField = select;
|
||||||
description = "{{.wizard.tuner.description}}";
|
description = "{{.wizard.tuner.description}}";
|
||||||
break;
|
break;
|
||||||
case "epgSource":
|
case "epgSource":
|
||||||
@@ -59,6 +62,7 @@ var WizardItem = /** @class */ (function (_super) {
|
|||||||
select.setAttribute("class", "wizard");
|
select.setAttribute("class", "wizard");
|
||||||
select.id = key;
|
select.id = key;
|
||||||
doc.appendChild(select);
|
doc.appendChild(select);
|
||||||
|
wizardField = select;
|
||||||
description = "{{.wizard.epgSource.description}}";
|
description = "{{.wizard.epgSource.description}}";
|
||||||
break;
|
break;
|
||||||
case "m3u":
|
case "m3u":
|
||||||
@@ -67,6 +71,7 @@ var WizardItem = /** @class */ (function (_super) {
|
|||||||
input.setAttribute("class", "wizard");
|
input.setAttribute("class", "wizard");
|
||||||
input.id = key;
|
input.id = key;
|
||||||
doc.appendChild(input);
|
doc.appendChild(input);
|
||||||
|
wizardField = input;
|
||||||
description = "{{.wizard.m3u.description}}";
|
description = "{{.wizard.m3u.description}}";
|
||||||
break;
|
break;
|
||||||
case "xmltv":
|
case "xmltv":
|
||||||
@@ -75,6 +80,7 @@ var WizardItem = /** @class */ (function (_super) {
|
|||||||
input.setAttribute("class", "wizard");
|
input.setAttribute("class", "wizard");
|
||||||
input.id = key;
|
input.id = key;
|
||||||
doc.appendChild(input);
|
doc.appendChild(input);
|
||||||
|
wizardField = input;
|
||||||
description = "{{.wizard.xmltv.description}}";
|
description = "{{.wizard.xmltv.description}}";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -82,8 +88,20 @@ var WizardItem = /** @class */ (function (_super) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var pre = document.createElement("PRE");
|
var pre = document.createElement("PRE");
|
||||||
|
pre.id = "wizard-description-" + key;
|
||||||
pre.innerHTML = description;
|
pre.innerHTML = description;
|
||||||
doc.appendChild(pre);
|
doc.appendChild(pre);
|
||||||
|
if (wizardField != null) {
|
||||||
|
wizardField.setAttribute("aria-label", this.headline);
|
||||||
|
wizardField.setAttribute("aria-describedby", pre.id);
|
||||||
|
setTimeout(function () {
|
||||||
|
wizardField.focus();
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
doc.setAttribute("aria-busy", "false");
|
||||||
|
if (typeof announceToScreenReader == "function") {
|
||||||
|
announceToScreenReader(this.headline + " step");
|
||||||
|
}
|
||||||
console.log(headline, key);
|
console.log(headline, key);
|
||||||
};
|
};
|
||||||
return WizardItem;
|
return WizardItem;
|
||||||
@@ -145,3 +163,20 @@ configurationWizard.push(new WizardItem("tuner", "{{.wizard.tuner.title}}"));
|
|||||||
configurationWizard.push(new WizardItem("epgSource", "{{.wizard.epgSource.title}}"));
|
configurationWizard.push(new WizardItem("epgSource", "{{.wizard.epgSource.title}}"));
|
||||||
configurationWizard.push(new WizardItem("m3u", "{{.wizard.m3u.title}}"));
|
configurationWizard.push(new WizardItem("m3u", "{{.wizard.m3u.title}}"));
|
||||||
configurationWizard.push(new WizardItem("xmltv", "{{.wizard.xmltv.title}}"));
|
configurationWizard.push(new WizardItem("xmltv", "{{.wizard.xmltv.title}}"));
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
var container = document.getElementById("content");
|
||||||
|
if (container == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
container.addEventListener("keydown", function (event) {
|
||||||
|
if (event.key != "Enter") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var target = event.target;
|
||||||
|
if (target == null || target.tagName != "INPUT") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
saveWizard();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -21,15 +21,22 @@ function showLogs(bottom) {
|
|||||||
var log = new Log();
|
var log = new Log();
|
||||||
var logs = SERVER["log"]["log"];
|
var logs = SERVER["log"]["log"];
|
||||||
var div = document.getElementById("content_log");
|
var div = document.getElementById("content_log");
|
||||||
|
var wrapper = document.getElementById("box-wrapper");
|
||||||
|
var shouldStickToBottom = bottom;
|
||||||
div.innerHTML = "";
|
div.innerHTML = "";
|
||||||
|
if (wrapper != null && shouldStickToBottom == false) {
|
||||||
|
var distanceToBottom = wrapper.scrollHeight - wrapper.scrollTop - wrapper.clientHeight;
|
||||||
|
if (distanceToBottom < 80) {
|
||||||
|
shouldStickToBottom = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
var keys = getObjKeys(logs);
|
var keys = getObjKeys(logs);
|
||||||
keys.forEach(function (logID) {
|
keys.forEach(function (logID) {
|
||||||
var entry = log.createLog(logs[logID]);
|
var entry = log.createLog(logs[logID]);
|
||||||
div.append(entry);
|
div.append(entry);
|
||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (bottom == true) {
|
if (shouldStickToBottom == true && wrapper != null) {
|
||||||
var wrapper = document.getElementById("box-wrapper");
|
|
||||||
wrapper.scrollTop = wrapper.scrollHeight;
|
wrapper.scrollTop = wrapper.scrollHeight;
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var __extends = (this && this.__extends) || (function () {
|
|||||||
var extendStatics = function (d, b) {
|
var extendStatics = function (d, b) {
|
||||||
extendStatics = Object.setPrototypeOf ||
|
extendStatics = Object.setPrototypeOf ||
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||||
return extendStatics(d, b);
|
return extendStatics(d, b);
|
||||||
};
|
};
|
||||||
return function (d, b) {
|
return function (d, b) {
|
||||||
@@ -43,7 +43,14 @@ var MainMenuItem = /** @class */ (function (_super) {
|
|||||||
var item = document.createElement("LI");
|
var item = document.createElement("LI");
|
||||||
item.setAttribute("onclick", "javascript: openThisMenu(this)");
|
item.setAttribute("onclick", "javascript: openThisMenu(this)");
|
||||||
item.setAttribute("id", this.id);
|
item.setAttribute("id", this.id);
|
||||||
|
item.setAttribute("data-menu", this.menuKey);
|
||||||
|
item.setAttribute("role", "menuitem");
|
||||||
|
item.setAttribute("tabindex", "0");
|
||||||
|
item.setAttribute("aria-controls", "content");
|
||||||
|
item.setAttribute("aria-label", this.value);
|
||||||
|
item.setAttribute("onkeydown", "if(event.key==='Enter' || event.key===' '){event.preventDefault();openThisMenu(this);}");
|
||||||
var img = this.createIMG(this.imgSrc);
|
var img = this.createIMG(this.imgSrc);
|
||||||
|
img.setAttribute("alt", "");
|
||||||
var value = this.createValue(this.value);
|
var value = this.createValue(this.value);
|
||||||
item.appendChild(img);
|
item.appendChild(img);
|
||||||
item.appendChild(value);
|
item.appendChild(value);
|
||||||
@@ -63,7 +70,7 @@ var MainMenuItem = /** @class */ (function (_super) {
|
|||||||
this.tableHeader = ["{{.users.table.username}}", "{{.users.table.password}}", "{{.users.table.web}}", "{{.users.table.pms}}", "{{.users.table.m3u}}", "{{.users.table.xml}}", "{{.users.table.api}}"];
|
this.tableHeader = ["{{.users.table.username}}", "{{.users.table.password}}", "{{.users.table.web}}", "{{.users.table.pms}}", "{{.users.table.m3u}}", "{{.users.table.xml}}", "{{.users.table.api}}"];
|
||||||
break;
|
break;
|
||||||
case "mapping":
|
case "mapping":
|
||||||
this.tableHeader = ["BULK", "{{.mapping.table.chNo}}", "{{.mapping.table.logo}}", "{{.mapping.table.channelName}}", "{{.mapping.table.playlist}}", "{{.mapping.table.groupTitle}}", "{{.mapping.table.xmltvFile}}", "{{.mapping.table.xmltvID}}"];
|
this.tableHeader = ["BULK", "{{.mapping.table.chNo}}", "{{.mapping.table.logo}}", "{{.mapping.table.channelName}}", "{{.mapping.table.playlist}}", "{{.mapping.table.groupTitle}}", "{{.mapping.table.xmltvFile}}", "{{.mapping.table.xmltvID}}", "{{.mapping.table.edit}}"];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//console.log(this.menuKey, this.tableHeader);
|
//console.log(this.menuKey, this.tableHeader);
|
||||||
@@ -356,39 +363,27 @@ var Content = /** @class */ (function () {
|
|||||||
cell.child = true;
|
cell.child = true;
|
||||||
cell.childType = "IMG";
|
cell.childType = "IMG";
|
||||||
cell.imageURL = data[key]["tvg-logo"];
|
cell.imageURL = data[key]["tvg-logo"];
|
||||||
var td = cell.createCell();
|
tr.appendChild(cell.createCell());
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
|
||||||
td.id = key;
|
|
||||||
tr.appendChild(td);
|
|
||||||
// Kanalname
|
// Kanalname
|
||||||
var cell = new Cell();
|
var cell = new Cell();
|
||||||
cell.child = true;
|
cell.child = true;
|
||||||
cell.childType = "P";
|
cell.childType = "P";
|
||||||
cell.className = data[key]["x-category"];
|
cell.className = data[key]["x-category"];
|
||||||
cell.value = data[key]["x-name"];
|
cell.value = data[key]["x-name"];
|
||||||
var td = cell.createCell();
|
tr.appendChild(cell.createCell());
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
|
||||||
td.id = key;
|
|
||||||
tr.appendChild(td);
|
|
||||||
// Playlist
|
// Playlist
|
||||||
var cell = new Cell();
|
var cell = new Cell();
|
||||||
cell.child = true;
|
cell.child = true;
|
||||||
cell.childType = "P";
|
cell.childType = "P";
|
||||||
//cell.value = data[key]["_file.m3u.name"]
|
//cell.value = data[key]["_file.m3u.name"]
|
||||||
cell.value = getValueFromProviderFile(data[key]["_file.m3u.id"], "m3u", "name");
|
cell.value = getValueFromProviderFile(data[key]["_file.m3u.id"], "m3u", "name");
|
||||||
var td = cell.createCell();
|
tr.appendChild(cell.createCell());
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
|
||||||
td.id = key;
|
|
||||||
tr.appendChild(td);
|
|
||||||
// Gruppe (group-title)
|
// Gruppe (group-title)
|
||||||
var cell = new Cell();
|
var cell = new Cell();
|
||||||
cell.child = true;
|
cell.child = true;
|
||||||
cell.childType = "P";
|
cell.childType = "P";
|
||||||
cell.value = data[key]["x-group-title"];
|
cell.value = data[key]["x-group-title"];
|
||||||
var td = cell.createCell();
|
tr.appendChild(cell.createCell());
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
|
||||||
td.id = key;
|
|
||||||
tr.appendChild(td);
|
|
||||||
// XMLTV Datei
|
// XMLTV Datei
|
||||||
var cell = new Cell();
|
var cell = new Cell();
|
||||||
cell.child = true;
|
cell.child = true;
|
||||||
@@ -399,10 +394,7 @@ var Content = /** @class */ (function () {
|
|||||||
else {
|
else {
|
||||||
cell.value = data[key]["x-xmltv-file"];
|
cell.value = data[key]["x-xmltv-file"];
|
||||||
}
|
}
|
||||||
var td = cell.createCell();
|
tr.appendChild(cell.createCell());
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
|
||||||
td.id = key;
|
|
||||||
tr.appendChild(td);
|
|
||||||
// XMLTV Kanal
|
// XMLTV Kanal
|
||||||
var cell = new Cell();
|
var cell = new Cell();
|
||||||
cell.child = true;
|
cell.child = true;
|
||||||
@@ -413,10 +405,17 @@ var Content = /** @class */ (function () {
|
|||||||
value = data[key]["x-mapping"].substring(0, 20) + "...";
|
value = data[key]["x-mapping"].substring(0, 20) + "...";
|
||||||
}
|
}
|
||||||
cell.value = value;
|
cell.value = value;
|
||||||
var td = cell.createCell();
|
tr.appendChild(cell.createCell());
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
var cell = new Cell();
|
||||||
td.id = key;
|
cell.child = true;
|
||||||
tr.appendChild(td);
|
cell.childType = "EDIT";
|
||||||
|
cell.value = "{{.button.edit}}";
|
||||||
|
var editTd = cell.createCell();
|
||||||
|
var editButton = editTd.firstChild;
|
||||||
|
editButton.setAttribute('onclick', 'javascript: openPopUp("mapping", this)');
|
||||||
|
editButton.setAttribute("id", key);
|
||||||
|
editButton.setAttribute("aria-label", "Edit " + data[key]["x-name"]);
|
||||||
|
tr.appendChild(editTd);
|
||||||
rows.push(tr);
|
rows.push(tr);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -451,7 +450,7 @@ var Cell = /** @class */ (function () {
|
|||||||
break;
|
break;
|
||||||
case "INPUTCHANNEL":
|
case "INPUTCHANNEL":
|
||||||
element = document.createElement("INPUT");
|
element = document.createElement("INPUT");
|
||||||
element.setAttribute("onchange", "javscript: changeChannelNumber(this)");
|
element.setAttribute("onchange", "javascript: changeChannelNumber(this)");
|
||||||
element.value = this.value;
|
element.value = this.value;
|
||||||
element.type = "text";
|
element.type = "text";
|
||||||
break;
|
break;
|
||||||
@@ -460,6 +459,9 @@ var Cell = /** @class */ (function () {
|
|||||||
element.checked = this.value;
|
element.checked = this.value;
|
||||||
element.type = "checkbox";
|
element.type = "checkbox";
|
||||||
element.className = "bulk hideBulk";
|
element.className = "bulk hideBulk";
|
||||||
|
element.addEventListener("click", function (event) {
|
||||||
|
scheduleChannelRangeSelection(element, event);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case "BULK_HEAD":
|
case "BULK_HEAD":
|
||||||
element = document.createElement("INPUT");
|
element = document.createElement("INPUT");
|
||||||
@@ -475,6 +477,12 @@ var Cell = /** @class */ (function () {
|
|||||||
element.setAttribute("onerror", "javascript: this.onerror=null;this.src=''");
|
element.setAttribute("onerror", "javascript: this.onerror=null;this.src=''");
|
||||||
//onerror="this.onerror=null;this.src='missing.gif';"
|
//onerror="this.onerror=null;this.src='missing.gif';"
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "EDIT":
|
||||||
|
element = document.createElement("INPUT");
|
||||||
|
element.type = "button";
|
||||||
|
element.value = this.value;
|
||||||
|
element.className = "mapping-edit-button";
|
||||||
}
|
}
|
||||||
td.appendChild(element);
|
td.appendChild(element);
|
||||||
}
|
}
|
||||||
@@ -483,10 +491,18 @@ var Cell = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
if (this.onclick == true) {
|
if (this.onclick == true) {
|
||||||
td.setAttribute("onclick", this.onclickFunktion);
|
td.setAttribute("onclick", this.onclickFunktion);
|
||||||
td.className = "pointer";
|
td.className = "pointer keyboard-clickable";
|
||||||
|
td.setAttribute("tabindex", "0");
|
||||||
|
td.setAttribute("role", "button");
|
||||||
|
td.setAttribute("onkeydown", "if(event.key==='Enter' || event.key===' '){event.preventDefault();this.click();}");
|
||||||
}
|
}
|
||||||
if (this.tdClassName != undefined) {
|
if (this.tdClassName != undefined) {
|
||||||
td.className = this.tdClassName;
|
if (td.className.length > 0) {
|
||||||
|
td.className = td.className + " " + this.tdClassName;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
td.className = this.tdClassName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return td;
|
return td;
|
||||||
};
|
};
|
||||||
@@ -510,6 +526,7 @@ var ShowContent = /** @class */ (function (_super) {
|
|||||||
COLUMN_TO_SORT = -1;
|
COLUMN_TO_SORT = -1;
|
||||||
// Alten Inhalt löschen
|
// Alten Inhalt löschen
|
||||||
var doc = document.getElementById(this.DocumentID);
|
var doc = document.getElementById(this.DocumentID);
|
||||||
|
doc.setAttribute("aria-busy", "true");
|
||||||
doc.innerHTML = "";
|
doc.innerHTML = "";
|
||||||
showPreview(false);
|
showPreview(false);
|
||||||
// Überschrift
|
// Überschrift
|
||||||
@@ -556,11 +573,33 @@ var ShowContent = /** @class */ (function (_super) {
|
|||||||
var input = this.createInput("button", menuKey, "{{.button.bulkEdit}}");
|
var input = this.createInput("button", menuKey, "{{.button.bulkEdit}}");
|
||||||
input.setAttribute("onclick", 'javascript: bulkEdit()');
|
input.setAttribute("onclick", 'javascript: bulkEdit()');
|
||||||
interaction.appendChild(input);
|
interaction.appendChild(input);
|
||||||
|
var sortSelect = document.createElement("SELECT");
|
||||||
|
sortSelect.setAttribute("id", "mapping-sort-mobile");
|
||||||
|
sortSelect.className = "mobile-only-control";
|
||||||
|
sortSelect.setAttribute("aria-label", "Sort mapping");
|
||||||
|
var sortOptions = [
|
||||||
|
{ label: "{{.mapping.table.chNo}}", value: "1" },
|
||||||
|
{ label: "{{.mapping.table.channelName}}", value: "3" },
|
||||||
|
{ label: "{{.mapping.table.playlist}}", value: "4" },
|
||||||
|
{ label: "{{.mapping.table.groupTitle}}", value: "5" }
|
||||||
|
];
|
||||||
|
sortOptions.forEach(function (optionData) {
|
||||||
|
var option = document.createElement("OPTION");
|
||||||
|
option.innerText = optionData.label;
|
||||||
|
option.value = optionData.value;
|
||||||
|
sortSelect.appendChild(option);
|
||||||
|
});
|
||||||
|
sortSelect.value = "1";
|
||||||
|
sortSelect.onchange = function () {
|
||||||
|
sortTable(parseInt(this.value, 10));
|
||||||
|
};
|
||||||
|
interaction.appendChild(sortSelect);
|
||||||
var input = this.createInput("search", "search", "");
|
var input = this.createInput("search", "search", "");
|
||||||
input.setAttribute("id", "searchMapping");
|
input.setAttribute("id", "searchMapping");
|
||||||
input.setAttribute("placeholder", "{{.button.search}}");
|
input.setAttribute("placeholder", "{{.button.search}}");
|
||||||
|
input.setAttribute("aria-label", "{{.button.search}}");
|
||||||
input.className = "search";
|
input.className = "search";
|
||||||
input.setAttribute("onchange", 'javascript: searchInMapping()');
|
input.setAttribute("oninput", 'javascript: searchInMapping()');
|
||||||
interaction.appendChild(input);
|
interaction.appendChild(input);
|
||||||
break;
|
break;
|
||||||
case "settings":
|
case "settings":
|
||||||
@@ -580,6 +619,7 @@ var ShowContent = /** @class */ (function (_super) {
|
|||||||
var settings = this.createDIV();
|
var settings = this.createDIV();
|
||||||
wrapper.appendChild(settings);
|
wrapper.appendChild(settings);
|
||||||
showSettings();
|
showSettings();
|
||||||
|
finalizeContentAccessibility(headline);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case "log":
|
case "log":
|
||||||
@@ -593,6 +633,7 @@ var ShowContent = /** @class */ (function (_super) {
|
|||||||
var logs = this.createDIV();
|
var logs = this.createDIV();
|
||||||
wrapper.appendChild(logs);
|
wrapper.appendChild(logs);
|
||||||
showLogs(true);
|
showLogs(true);
|
||||||
|
finalizeContentAccessibility(headline);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case "logout":
|
case "logout":
|
||||||
@@ -665,30 +706,392 @@ var ShowContent = /** @class */ (function (_super) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showElement("loading", false);
|
showElement("loading", false);
|
||||||
|
finalizeContentAccessibility(headline);
|
||||||
};
|
};
|
||||||
return ShowContent;
|
return ShowContent;
|
||||||
}(Content));
|
}(Content));
|
||||||
|
var SHELL_LAYOUT_READY = false;
|
||||||
|
function isKeyboardActivationKey(event) {
|
||||||
|
return event.key == "Enter" || event.key == " ";
|
||||||
|
}
|
||||||
|
function makeKeyboardClickable(element, label) {
|
||||||
|
if (element == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (element.getAttribute("data-keyboard-ready") == "true") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var tagName = element.tagName.toUpperCase();
|
||||||
|
if (tagName == "INPUT" || tagName == "BUTTON" || tagName == "SELECT" || tagName == "TEXTAREA" || tagName == "A") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.setAttribute("data-keyboard-ready", "true");
|
||||||
|
if (element.getAttribute("tabindex") == null) {
|
||||||
|
element.setAttribute("tabindex", "0");
|
||||||
|
}
|
||||||
|
if (element.getAttribute("role") == null) {
|
||||||
|
element.setAttribute("role", "button");
|
||||||
|
}
|
||||||
|
element.classList.add("keyboard-clickable");
|
||||||
|
if (label != undefined && label.length > 0) {
|
||||||
|
if (element.getAttribute("aria-label") == null || element.getAttribute("aria-label").length == 0) {
|
||||||
|
element.setAttribute("aria-label", label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
element.addEventListener("keydown", function (event) {
|
||||||
|
if (isKeyboardActivationKey(event) == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
this.click();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function applyTableAccessibility(table, sectionName) {
|
||||||
|
if (table == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
table.setAttribute("role", "table");
|
||||||
|
var rows = table.getElementsByTagName("TR");
|
||||||
|
var headerLabels = [];
|
||||||
|
if (rows.length > 0) {
|
||||||
|
var headerCells = rows[0].getElementsByTagName("TD");
|
||||||
|
for (var h = 0; h < headerCells.length; h++) {
|
||||||
|
var headerLabel = headerCells[h].innerText;
|
||||||
|
if (headerLabel == undefined || headerLabel.length == 0) {
|
||||||
|
headerLabel = "Value";
|
||||||
|
}
|
||||||
|
if (headerLabel == "BULK") {
|
||||||
|
headerLabel = "Select";
|
||||||
|
}
|
||||||
|
headerLabels.push(headerLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
rows[i].setAttribute("role", "row");
|
||||||
|
if (rows[i].getAttribute("onclick") != null) {
|
||||||
|
var rowLabel = rows[i].innerText;
|
||||||
|
if (rowLabel == undefined || rowLabel.length == 0) {
|
||||||
|
rowLabel = sectionName + " row";
|
||||||
|
}
|
||||||
|
makeKeyboardClickable(rows[i], rowLabel);
|
||||||
|
}
|
||||||
|
var cells = rows[i].getElementsByTagName("TD");
|
||||||
|
for (var c = 0; c < cells.length; c++) {
|
||||||
|
if (i == 0) {
|
||||||
|
cells[c].setAttribute("role", "columnheader");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cells[c].setAttribute("role", "cell");
|
||||||
|
}
|
||||||
|
var dataLabel = headerLabels[c];
|
||||||
|
if (dataLabel == undefined || dataLabel.length == 0) {
|
||||||
|
dataLabel = "Value";
|
||||||
|
}
|
||||||
|
cells[c].setAttribute("data-label", dataLabel);
|
||||||
|
var checkbox = cells[c].querySelector('input[type="checkbox"]');
|
||||||
|
if (checkbox != null) {
|
||||||
|
cells[c].setAttribute("data-cell-type", "checkbox");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var image = cells[c].querySelector("img");
|
||||||
|
if (image != null) {
|
||||||
|
cells[c].setAttribute("data-cell-type", "image");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var actionButton = cells[c].querySelector("input.mapping-edit-button, button.mapping-edit-button");
|
||||||
|
if (actionButton != null) {
|
||||||
|
cells[c].setAttribute("data-cell-type", "action");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cells[c].removeAttribute("data-cell-type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cells[c].getAttribute("onclick") != null) {
|
||||||
|
var cellLabel = cells[c].innerText;
|
||||||
|
if (cellLabel == undefined || cellLabel.length == 0) {
|
||||||
|
cellLabel = sectionName + " details";
|
||||||
|
}
|
||||||
|
makeKeyboardClickable(cells[c], cellLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function finalizeContentAccessibility(sectionName) {
|
||||||
|
var content = document.getElementById("content");
|
||||||
|
if (content == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
content.setAttribute("aria-busy", "false");
|
||||||
|
var heading = content.getElementsByTagName("H3")[0];
|
||||||
|
if (heading != null) {
|
||||||
|
heading.setAttribute("tabindex", "-1");
|
||||||
|
setTimeout(function () {
|
||||||
|
heading.focus();
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
applyTableAccessibility(document.getElementById("content_table"), sectionName);
|
||||||
|
if (sectionName != undefined && sectionName.length > 0) {
|
||||||
|
announceToScreenReader(sectionName + " loaded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setLayoutMenuState(open) {
|
||||||
|
if (document.body == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (open == true) {
|
||||||
|
document.body.classList.add("menu-open");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.body.classList.remove("menu-open");
|
||||||
|
}
|
||||||
|
var toggle = document.getElementById("menu-toggle");
|
||||||
|
if (toggle != null) {
|
||||||
|
toggle.setAttribute("aria-expanded", open == true ? "true" : "false");
|
||||||
|
toggle.setAttribute("aria-label", open == true ? "Close navigation menu" : "Open navigation menu");
|
||||||
|
}
|
||||||
|
var overlay = document.getElementById("layout-overlay");
|
||||||
|
if (overlay != null) {
|
||||||
|
overlay.setAttribute("aria-hidden", open == true ? "false" : "true");
|
||||||
|
}
|
||||||
|
var wrapper = document.getElementById("menu-wrapper");
|
||||||
|
if (wrapper != null) {
|
||||||
|
if (window.innerWidth <= 900) {
|
||||||
|
wrapper.setAttribute("aria-hidden", open == true ? "false" : "true");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrapper.setAttribute("aria-hidden", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (window.innerWidth <= 900 && open == false && toggle != null && wrapper != null && wrapper.contains(document.activeElement)) {
|
||||||
|
toggle.focus();
|
||||||
|
}
|
||||||
|
if (window.innerWidth <= 900 && open == true && wrapper != null) {
|
||||||
|
var firstMenuItem = wrapper.querySelector("#main-menu li");
|
||||||
|
if (firstMenuItem != null) {
|
||||||
|
setTimeout(function () {
|
||||||
|
firstMenuItem.focus();
|
||||||
|
}, 30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function toggleLayoutMenu() {
|
||||||
|
if (document.body == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var isOpen = document.body.classList.contains("menu-open");
|
||||||
|
setLayoutMenuState(!isOpen);
|
||||||
|
}
|
||||||
|
function closeLayoutMenuIfMobile() {
|
||||||
|
if (window.innerWidth <= 900) {
|
||||||
|
setLayoutMenuState(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setActiveMenu(menuID) {
|
||||||
|
ACTIVE_MENU_ID = menuID.toString();
|
||||||
|
var menu = document.getElementById("main-menu");
|
||||||
|
if (menu == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var items = menu.getElementsByTagName("LI");
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
items[i].classList.remove("menu-active");
|
||||||
|
items[i].removeAttribute("aria-current");
|
||||||
|
}
|
||||||
|
var activeItem = document.getElementById(ACTIVE_MENU_ID);
|
||||||
|
var activeMenuKey = "";
|
||||||
|
if (activeItem != null) {
|
||||||
|
activeItem.classList.add("menu-active");
|
||||||
|
activeItem.setAttribute("aria-current", "page");
|
||||||
|
var menuKeyValue = activeItem.getAttribute("data-menu");
|
||||||
|
if (menuKeyValue != null) {
|
||||||
|
activeMenuKey = menuKeyValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (document.body != null) {
|
||||||
|
if (activeMenuKey.length > 0) {
|
||||||
|
document.body.setAttribute("data-active-menu", activeMenuKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.body.removeAttribute("data-active-menu");
|
||||||
|
}
|
||||||
|
if (activeMenuKey == "log") {
|
||||||
|
document.body.classList.add("menu-log-focus");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.body.classList.remove("menu-log-focus");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function renderStatusCards() {
|
||||||
|
var wrapper = document.getElementById("status-cards");
|
||||||
|
if (wrapper == null || SERVER.hasOwnProperty("clientInfo") == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var info = SERVER["clientInfo"];
|
||||||
|
var errors = parseInt(info["errors"], 10);
|
||||||
|
var warnings = parseInt(info["warnings"], 10);
|
||||||
|
var cards = [
|
||||||
|
{ label: "Streams", value: info["streams"], tone: "ok" },
|
||||||
|
{ label: "EPG Source", value: info["epgSource"], tone: "neutral" },
|
||||||
|
{ label: "XEPG Channels", value: info["xepg"], tone: "ok" },
|
||||||
|
{ label: "Errors", value: info["errors"], tone: errors > 0 ? "error" : "ok" },
|
||||||
|
{ label: "Warnings", value: info["warnings"], tone: warnings > 0 ? "warn" : "ok" },
|
||||||
|
{ label: "DVR", value: info["DVR"], tone: "neutral" }
|
||||||
|
];
|
||||||
|
wrapper.innerHTML = "";
|
||||||
|
cards.forEach(function (card) {
|
||||||
|
var box = document.createElement("DIV");
|
||||||
|
box.className = "status-card status-card-" + card.tone;
|
||||||
|
box.setAttribute("role", "listitem");
|
||||||
|
var label = document.createElement("P");
|
||||||
|
label.className = "status-card-label";
|
||||||
|
label.innerText = card.label;
|
||||||
|
var value = document.createElement("P");
|
||||||
|
value.className = "status-card-value";
|
||||||
|
if (card.value == undefined || card.value == "") {
|
||||||
|
value.innerText = "-";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value.innerText = card.value;
|
||||||
|
}
|
||||||
|
box.appendChild(label);
|
||||||
|
box.appendChild(value);
|
||||||
|
box.setAttribute("aria-label", card.label + ": " + value.innerText);
|
||||||
|
wrapper.appendChild(box);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function initShellLayout() {
|
||||||
|
if (SHELL_LAYOUT_READY == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var toggle = document.getElementById("menu-toggle");
|
||||||
|
if (toggle != null) {
|
||||||
|
toggle.onclick = function () {
|
||||||
|
toggleLayoutMenu();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var overlay = document.getElementById("layout-overlay");
|
||||||
|
if (overlay != null) {
|
||||||
|
overlay.onclick = function () {
|
||||||
|
setLayoutMenuState(false);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
document.addEventListener("keydown", function (event) {
|
||||||
|
if (event.key == "Escape") {
|
||||||
|
setLayoutMenuState(false);
|
||||||
|
showElement("popup", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.key == "/") {
|
||||||
|
var target = event.target;
|
||||||
|
var tagName = target != null && target.tagName != undefined ? target.tagName : "";
|
||||||
|
var onInput = tagName == "INPUT" || tagName == "TEXTAREA" || tagName == "SELECT";
|
||||||
|
if (onInput == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var search = document.getElementById("searchMapping");
|
||||||
|
if (search != null) {
|
||||||
|
event.preventDefault();
|
||||||
|
search.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setLayoutMenuState(false);
|
||||||
|
setConnectionState("idle");
|
||||||
|
SHELL_LAYOUT_READY = true;
|
||||||
|
}
|
||||||
|
function shouldPollLogs() {
|
||||||
|
if (document.hidden == true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (document.getElementById("content_log") == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ACTIVE_MENU_ID.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var activeItem = document.getElementById(ACTIVE_MENU_ID);
|
||||||
|
if (activeItem == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return activeItem.getAttribute("data-menu") == "log";
|
||||||
|
}
|
||||||
function PageReady() {
|
function PageReady() {
|
||||||
|
initShellLayout();
|
||||||
var server = new Server("getServerConfig");
|
var server = new Server("getServerConfig");
|
||||||
server.request(new Object());
|
server.request(new Object());
|
||||||
|
var bootstrapAttempts = 0;
|
||||||
|
var maxBootstrapAttempts = 5;
|
||||||
|
var bootstrapTimer = window.setInterval(function () {
|
||||||
|
if (SERVER.hasOwnProperty("clientInfo") == true) {
|
||||||
|
window.clearInterval(bootstrapTimer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SERVER_CONNECTION == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bootstrapAttempts++;
|
||||||
|
var retryServer = new Server("getServerConfig");
|
||||||
|
retryServer.request(new Object());
|
||||||
|
if (bootstrapAttempts >= maxBootstrapAttempts) {
|
||||||
|
window.clearInterval(bootstrapTimer);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
window.addEventListener("resize", function () {
|
window.addEventListener("resize", function () {
|
||||||
|
if (window.innerWidth > 900) {
|
||||||
|
setLayoutMenuState(false);
|
||||||
|
}
|
||||||
calculateWrapperHeight();
|
calculateWrapperHeight();
|
||||||
}, true);
|
}, true);
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
|
if (shouldPollLogs() == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
updateLog();
|
updateLog();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
function isClientInfoHttpURL(value) {
|
||||||
|
return /^https?:\/\//i.test(value);
|
||||||
|
}
|
||||||
|
function setClientInfoValue(key, value) {
|
||||||
|
var element = document.getElementById(key);
|
||||||
|
if (element == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var textValue = "";
|
||||||
|
if (value != undefined && value != null) {
|
||||||
|
textValue = String(value);
|
||||||
|
}
|
||||||
|
if ((key == "m3u-url" || key == "xepg-url") && isClientInfoHttpURL(textValue)) {
|
||||||
|
element.innerHTML = "";
|
||||||
|
var anchor = document.createElement("A");
|
||||||
|
anchor.href = textValue;
|
||||||
|
anchor.target = "_blank";
|
||||||
|
anchor.rel = "noopener noreferrer";
|
||||||
|
anchor.textContent = textValue;
|
||||||
|
element.appendChild(anchor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.innerHTML = textValue;
|
||||||
|
}
|
||||||
function createLayout() {
|
function createLayout() {
|
||||||
|
var contentRegion = document.getElementById("content");
|
||||||
|
if (contentRegion != null) {
|
||||||
|
contentRegion.setAttribute("aria-busy", "true");
|
||||||
|
}
|
||||||
// Client Info
|
// Client Info
|
||||||
var obj = SERVER["clientInfo"];
|
var obj = SERVER["clientInfo"];
|
||||||
var keys = getObjKeys(obj);
|
var keys = getObjKeys(obj);
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
if (document.getElementById(keys[i])) {
|
setClientInfoValue(keys[i], obj[keys[i]]);
|
||||||
document.getElementById(keys[i]).innerHTML = obj[keys[i]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
renderStatusCards();
|
||||||
if (!document.getElementById("main-menu")) {
|
if (!document.getElementById("main-menu")) {
|
||||||
|
if (contentRegion != null) {
|
||||||
|
contentRegion.setAttribute("aria-busy", "false");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Menü erstellen
|
// Menü erstellen
|
||||||
@@ -713,12 +1116,35 @@ function createLayout() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ACTIVE_MENU_ID.length > 0 && document.getElementById(ACTIVE_MENU_ID)) {
|
||||||
|
setActiveMenu(ACTIVE_MENU_ID);
|
||||||
|
}
|
||||||
|
setLayoutMenuState(document.body.classList.contains("menu-open"));
|
||||||
|
var content = document.getElementById("content");
|
||||||
|
var menu = document.getElementById("main-menu");
|
||||||
|
if (ACTIVE_MENU_ID.length == 0 && content != null && menu != null) {
|
||||||
|
if (content.innerHTML.replace(/\\s/g, "").length == 0) {
|
||||||
|
var firstItem = menu.getElementsByTagName("LI")[0];
|
||||||
|
if (firstItem != undefined) {
|
||||||
|
firstItem.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contentRegion != null) {
|
||||||
|
contentRegion.setAttribute("aria-busy", "false");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
function openThisMenu(element) {
|
function openThisMenu(element) {
|
||||||
var id = element.id;
|
var id = element.id;
|
||||||
var content = new ShowContent(id);
|
var content = new ShowContent(id);
|
||||||
|
setActiveMenu(id);
|
||||||
content.show();
|
content.show();
|
||||||
|
var contentArea = document.getElementById("content");
|
||||||
|
if (contentArea != null) {
|
||||||
|
contentArea.scrollTop = 0;
|
||||||
|
}
|
||||||
|
closeLayoutMenuIfMobile();
|
||||||
calculateWrapperHeight();
|
calculateWrapperHeight();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -756,9 +1182,26 @@ var PopupContent = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
PopupContent.prototype.createHeadline = function (headline) {
|
PopupContent.prototype.createHeadline = function (headline) {
|
||||||
this.doc.innerHTML = "";
|
this.doc.innerHTML = "";
|
||||||
|
var titleBar = document.createElement("DIV");
|
||||||
|
titleBar.className = "popup-title";
|
||||||
var element = document.createElement("H3");
|
var element = document.createElement("H3");
|
||||||
|
element.id = "popup-title-text";
|
||||||
element.innerHTML = headline.toUpperCase();
|
element.innerHTML = headline.toUpperCase();
|
||||||
this.doc.appendChild(element);
|
titleBar.appendChild(element);
|
||||||
|
var closeButton = document.createElement("BUTTON");
|
||||||
|
closeButton.setAttribute("type", "button");
|
||||||
|
closeButton.className = "popup-close";
|
||||||
|
closeButton.setAttribute("aria-label", "Close dialog");
|
||||||
|
closeButton.innerHTML = "×";
|
||||||
|
closeButton.onclick = function () {
|
||||||
|
showElement("popup", false);
|
||||||
|
};
|
||||||
|
titleBar.appendChild(closeButton);
|
||||||
|
this.doc.appendChild(titleBar);
|
||||||
|
var popup = document.getElementById("popup");
|
||||||
|
if (popup != null) {
|
||||||
|
popup.setAttribute("aria-labelledby", "popup-title-text");
|
||||||
|
}
|
||||||
// Tabelle erstellen
|
// Tabelle erstellen
|
||||||
this.table = document.createElement("TABLE");
|
this.table = document.createElement("TABLE");
|
||||||
this.doc.appendChild(this.table);
|
this.doc.appendChild(this.table);
|
||||||
@@ -1285,7 +1728,7 @@ function openPopUp(dataType, element) {
|
|||||||
// Erweitern der EPG Kategorie
|
// Erweitern der EPG Kategorie
|
||||||
var dbKey = "x-category";
|
var dbKey = "x-category";
|
||||||
var text = ["-", "Kids (Emby only)", "News", "Movie", "Series", "Sports"];
|
var text = ["-", "Kids (Emby only)", "News", "Movie", "Series", "Sports"];
|
||||||
var values = ["-", "Kids", "News", "Movie", "Series", "Sports"];
|
var values = ["", "Kids", "News", "Movie", "Series", "Sports"];
|
||||||
var select = content.createSelect(text, values, data[dbKey], dbKey);
|
var select = content.createSelect(text, values, data[dbKey], dbKey);
|
||||||
select.setAttribute("onchange", "javascript: this.className = 'changed'");
|
select.setAttribute("onchange", "javascript: this.className = 'changed'");
|
||||||
content.appendRow("{{.mapping.epgCategory.title}}", select);
|
content.appendRow("{{.mapping.epgCategory.title}}", select);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ var Server = /** @class */ (function () {
|
|||||||
if (this.cmd != "updateLog") {
|
if (this.cmd != "updateLog") {
|
||||||
showElement("loading", true);
|
showElement("loading", true);
|
||||||
UNDO = new Object();
|
UNDO = new Object();
|
||||||
|
setConnectionState("busy");
|
||||||
}
|
}
|
||||||
switch (window.location.protocol) {
|
switch (window.location.protocol) {
|
||||||
case "http:":
|
case "http:":
|
||||||
@@ -20,11 +21,61 @@ var Server = /** @class */ (function () {
|
|||||||
this.protocol = "wss://";
|
this.protocol = "wss://";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var url = this.protocol + window.location.hostname + ":" + window.location.port + "/data/" + "?Token=" + getCookie("Token");
|
var wsHost = window.location.host;
|
||||||
|
if (wsHost == undefined || wsHost.length < 1) {
|
||||||
|
wsHost = window.location.hostname;
|
||||||
|
}
|
||||||
|
var url = this.protocol + wsHost + "/data/" + "?Token=" + getCookie("Token");
|
||||||
data["cmd"] = this.cmd;
|
data["cmd"] = this.cmd;
|
||||||
|
var requestCmd = data["cmd"];
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
|
var isLogUpdate = data["cmd"] == "updateLog";
|
||||||
|
var responseReceived = false;
|
||||||
|
var requestFinished = false;
|
||||||
|
var timeoutMs = 12000;
|
||||||
|
var requestTimeout;
|
||||||
|
var finishRequest = function (state, responseSuccess) {
|
||||||
|
if (responseSuccess === void 0) { responseSuccess = false; }
|
||||||
|
if (requestFinished == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
requestFinished = true;
|
||||||
|
SERVER_CONNECTION = false;
|
||||||
|
window.clearTimeout(requestTimeout);
|
||||||
|
if (responseSuccess == true) {
|
||||||
|
if (state == "online") {
|
||||||
|
WS_FAILURE_COUNT = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WS_FAILURE_COUNT++;
|
||||||
|
}
|
||||||
|
if (isLogUpdate == false) {
|
||||||
|
showElement("loading", false);
|
||||||
|
}
|
||||||
|
if (state != "") {
|
||||||
|
setConnectionState(state);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
requestTimeout = window.setTimeout(function () {
|
||||||
|
console.log("Websocket request timed out.");
|
||||||
|
var timeoutState = "offline";
|
||||||
|
if (isLogUpdate == true && WS_FAILURE_COUNT < 2) {
|
||||||
|
timeoutState = "idle";
|
||||||
|
}
|
||||||
|
finishRequest(timeoutState, false);
|
||||||
|
try {
|
||||||
|
ws.close();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}, timeoutMs);
|
||||||
ws.onopen = function () {
|
ws.onopen = function () {
|
||||||
WS_AVAILABLE = true;
|
WS_AVAILABLE = true;
|
||||||
|
if (data["cmd"] != "updateLog") {
|
||||||
|
setConnectionState("busy");
|
||||||
|
}
|
||||||
console.log("REQUEST (JS):");
|
console.log("REQUEST (JS):");
|
||||||
console.log(data);
|
console.log(data);
|
||||||
console.log("REQUEST: (JSON)");
|
console.log("REQUEST: (JSON)");
|
||||||
@@ -33,14 +84,18 @@ var Server = /** @class */ (function () {
|
|||||||
};
|
};
|
||||||
ws.onerror = function (e) {
|
ws.onerror = function (e) {
|
||||||
console.log("No websocket connection to xTeVe could be established. Check your network configuration.");
|
console.log("No websocket connection to xTeVe could be established. Check your network configuration.");
|
||||||
SERVER_CONNECTION = false;
|
var errorState = "offline";
|
||||||
if (WS_AVAILABLE == false) {
|
if (isLogUpdate == true && WS_FAILURE_COUNT < 2) {
|
||||||
|
errorState = "idle";
|
||||||
|
}
|
||||||
|
finishRequest(errorState, false);
|
||||||
|
if (WS_AVAILABLE == false && isLogUpdate == false && requestCmd != "getServerConfig") {
|
||||||
alert("No websocket connection to xTeVe could be established. Check your network configuration.");
|
alert("No websocket connection to xTeVe could be established. Check your network configuration.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ws.onmessage = function (e) {
|
ws.onmessage = function (e) {
|
||||||
SERVER_CONNECTION = false;
|
responseReceived = true;
|
||||||
showElement("loading", false);
|
finishRequest("online", true);
|
||||||
console.log("RESPONSE:");
|
console.log("RESPONSE:");
|
||||||
var response = JSON.parse(e.data);
|
var response = JSON.parse(e.data);
|
||||||
console.log(response);
|
console.log(response);
|
||||||
@@ -48,6 +103,7 @@ var Server = /** @class */ (function () {
|
|||||||
document.cookie = "Token=" + response["token"];
|
document.cookie = "Token=" + response["token"];
|
||||||
}
|
}
|
||||||
if (response["status"] == false) {
|
if (response["status"] == false) {
|
||||||
|
setConnectionState("offline");
|
||||||
alert(response["err"]);
|
alert(response["err"]);
|
||||||
if (response.hasOwnProperty("reload")) {
|
if (response.hasOwnProperty("reload")) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -94,9 +150,20 @@ var Server = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
createLayout();
|
createLayout();
|
||||||
};
|
};
|
||||||
|
ws.onclose = function () {
|
||||||
|
if (responseReceived == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var closeState = "offline";
|
||||||
|
if (isLogUpdate == true && WS_FAILURE_COUNT < 2) {
|
||||||
|
closeState = "idle";
|
||||||
|
}
|
||||||
|
finishRequest(closeState, false);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
return Server;
|
return Server;
|
||||||
}());
|
}());
|
||||||
|
var WS_FAILURE_COUNT = 0;
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
var value = "; " + document.cookie;
|
var value = "; " + document.cookie;
|
||||||
var parts = value.split("; " + name + "=");
|
var parts = value.split("; " + name + "=");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var __extends = (this && this.__extends) || (function () {
|
|||||||
var extendStatics = function (d, b) {
|
var extendStatics = function (d, b) {
|
||||||
extendStatics = Object.setPrototypeOf ||
|
extendStatics = Object.setPrototypeOf ||
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||||
return extendStatics(d, b);
|
return extendStatics(d, b);
|
||||||
};
|
};
|
||||||
return function (d, b) {
|
return function (d, b) {
|
||||||
@@ -74,6 +74,29 @@ var SettingsCategory = /** @class */ (function () {
|
|||||||
setting.appendChild(tdLeft);
|
setting.appendChild(tdLeft);
|
||||||
setting.appendChild(tdRight);
|
setting.appendChild(tdRight);
|
||||||
break;
|
break;
|
||||||
|
case "plex.url":
|
||||||
|
var tdLeft = document.createElement("TD");
|
||||||
|
tdLeft.innerHTML = "{{.settings.plexURL.title}}" + ":";
|
||||||
|
var tdRight = document.createElement("TD");
|
||||||
|
var input = content.createInput("text", "plex.url", data);
|
||||||
|
input.setAttribute("placeholder", "{{.settings.plexURL.placeholder}}");
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'");
|
||||||
|
tdRight.appendChild(input);
|
||||||
|
setting.appendChild(tdLeft);
|
||||||
|
setting.appendChild(tdRight);
|
||||||
|
break;
|
||||||
|
case "plex.token":
|
||||||
|
var tdLeft = document.createElement("TD");
|
||||||
|
tdLeft.innerHTML = "{{.settings.plexToken.title}}" + ":";
|
||||||
|
var tdRight = document.createElement("TD");
|
||||||
|
var input = content.createInput("password", "plex.token", data);
|
||||||
|
input.setAttribute("placeholder", "{{.settings.plexToken.placeholder}}");
|
||||||
|
input.setAttribute("autocomplete", "off");
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'");
|
||||||
|
tdRight.appendChild(input);
|
||||||
|
setting.appendChild(tdLeft);
|
||||||
|
setting.appendChild(tdRight);
|
||||||
|
break;
|
||||||
case "buffer.timeout":
|
case "buffer.timeout":
|
||||||
var tdLeft = document.createElement("TD");
|
var tdLeft = document.createElement("TD");
|
||||||
tdLeft.innerHTML = "{{.settings.bufferTimeout.title}}" + ":";
|
tdLeft.innerHTML = "{{.settings.bufferTimeout.title}}" + ":";
|
||||||
@@ -240,7 +263,30 @@ var SettingsCategory = /** @class */ (function () {
|
|||||||
setting.appendChild(tdLeft);
|
setting.appendChild(tdLeft);
|
||||||
setting.appendChild(tdRight);
|
setting.appendChild(tdRight);
|
||||||
break;
|
break;
|
||||||
|
case "use_plexAPI":
|
||||||
|
var tdLeft = document.createElement("TD");
|
||||||
|
tdLeft.innerHTML = "{{.settings.usePlexAPI.title}}" + ":";
|
||||||
|
var tdRight = document.createElement("TD");
|
||||||
|
var input = content.createCheckbox(settingsKey);
|
||||||
|
input.checked = data;
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'");
|
||||||
|
tdRight.appendChild(input);
|
||||||
|
setting.appendChild(tdLeft);
|
||||||
|
setting.appendChild(tdRight);
|
||||||
|
break;
|
||||||
// Select
|
// Select
|
||||||
|
case "xepg.missing.epg.mode":
|
||||||
|
var tdLeft = document.createElement("TD");
|
||||||
|
tdLeft.innerHTML = "{{.settings.xepgMissingEPGMode.title}}" + ":";
|
||||||
|
var tdRight = document.createElement("TD");
|
||||||
|
var text = ["{{.settings.xepgMissingEPGMode.info_strict}}", "{{.settings.xepgMissingEPGMode.info_relaxed}}"];
|
||||||
|
var values = ["strict", "relaxed"];
|
||||||
|
var select = content.createSelect(text, values, data, settingsKey);
|
||||||
|
select.setAttribute("onchange", "javascript: this.className = 'changed'");
|
||||||
|
tdRight.appendChild(select);
|
||||||
|
setting.appendChild(tdLeft);
|
||||||
|
setting.appendChild(tdRight);
|
||||||
|
break;
|
||||||
case "tuner":
|
case "tuner":
|
||||||
var tdLeft = document.createElement("TD");
|
var tdLeft = document.createElement("TD");
|
||||||
tdLeft.innerHTML = "{{.settings.tuner.title}}" + ":";
|
tdLeft.innerHTML = "{{.settings.tuner.title}}" + ":";
|
||||||
@@ -305,27 +351,14 @@ var SettingsCategory = /** @class */ (function () {
|
|||||||
setting.appendChild(tdLeft);
|
setting.appendChild(tdLeft);
|
||||||
setting.appendChild(tdRight);
|
setting.appendChild(tdRight);
|
||||||
break;
|
break;
|
||||||
case "scheme.m3u":
|
case "udpxy":
|
||||||
var tdLeft = document.createElement("TD");
|
var tdLeft = document.createElement("TD");
|
||||||
tdLeft.innerHTML = "{{.settings.schemeM3U.title}}" + ":";
|
tdLeft.innerHTML = "{{.settings.udpxy.title}}" + ":";
|
||||||
var tdRight = document.createElement("TD");
|
var tdRight = document.createElement("TD");
|
||||||
var text = ["HTTP", "HTTPS"];
|
var input = content.createInput("text", "udpxy", data);
|
||||||
var values = ["HTTP", "HTTPS"];
|
input.setAttribute("placeholder", "{{.settings.udpxy.placeholder}}");
|
||||||
var select = content.createSelect(text, values, data, settingsKey);
|
input.setAttribute("onchange", "javascript: this.className = 'changed'");
|
||||||
select.setAttribute("onchange", "javascript: this.className = 'changed'");
|
tdRight.appendChild(input);
|
||||||
tdRight.appendChild(select);
|
|
||||||
setting.appendChild(tdLeft);
|
|
||||||
setting.appendChild(tdRight);
|
|
||||||
break;
|
|
||||||
case "scheme.xml":
|
|
||||||
var tdLeft = document.createElement("TD");
|
|
||||||
tdLeft.innerHTML = "{{.settings.schemeXML.title}}" + ":";
|
|
||||||
var tdRight = document.createElement("TD");
|
|
||||||
var text = ["HTTP", "HTTPS"];
|
|
||||||
var values = ["HTTP", "HTTPS"];
|
|
||||||
var select = content.createSelect(text, values, data, settingsKey);
|
|
||||||
select.setAttribute("onchange", "javascript: this.className = 'changed'");
|
|
||||||
tdRight.appendChild(select);
|
|
||||||
setting.appendChild(tdLeft);
|
setting.appendChild(tdLeft);
|
||||||
setting.appendChild(tdRight);
|
setting.appendChild(tdRight);
|
||||||
break;
|
break;
|
||||||
@@ -377,6 +410,12 @@ var SettingsCategory = /** @class */ (function () {
|
|||||||
case "user.agent":
|
case "user.agent":
|
||||||
text = "{{.settings.userAgent.description}}";
|
text = "{{.settings.userAgent.description}}";
|
||||||
break;
|
break;
|
||||||
|
case "plex.url":
|
||||||
|
text = "{{.settings.plexURL.description}}";
|
||||||
|
break;
|
||||||
|
case "plex.token":
|
||||||
|
text = "{{.settings.plexToken.description}}";
|
||||||
|
break;
|
||||||
case "ffmpeg.path":
|
case "ffmpeg.path":
|
||||||
text = "{{.settings.ffmpegPath.description}}";
|
text = "{{.settings.ffmpegPath.description}}";
|
||||||
break;
|
break;
|
||||||
@@ -401,6 +440,9 @@ var SettingsCategory = /** @class */ (function () {
|
|||||||
case "api":
|
case "api":
|
||||||
text = "{{.settings.api.description}}";
|
text = "{{.settings.api.description}}";
|
||||||
break;
|
break;
|
||||||
|
case "use_plexAPI":
|
||||||
|
text = "{{.settings.usePlexAPI.description}}";
|
||||||
|
break;
|
||||||
case "files.update":
|
case "files.update":
|
||||||
text = "{{.settings.filesUpdate.description}}";
|
text = "{{.settings.filesUpdate.description}}";
|
||||||
break;
|
break;
|
||||||
@@ -410,11 +452,11 @@ var SettingsCategory = /** @class */ (function () {
|
|||||||
case "xepg.replace.missing.images":
|
case "xepg.replace.missing.images":
|
||||||
text = "{{.settings.replaceEmptyImages.description}}";
|
text = "{{.settings.replaceEmptyImages.description}}";
|
||||||
break;
|
break;
|
||||||
case "scheme.m3u":
|
case "xepg.missing.epg.mode":
|
||||||
text = "{{.settings.schemeM3U.description}}";
|
text = "{{.settings.xepgMissingEPGMode.description}}";
|
||||||
break;
|
break;
|
||||||
case "scheme.xml":
|
case "udpxy":
|
||||||
text = "{{.settings.schemeXML.description}}";
|
text = "{{.settings.udpxy.description}}";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
text = "";
|
text = "";
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"mainMenu": {
|
"mainMenu":
|
||||||
"item":{
|
{
|
||||||
|
"item":
|
||||||
|
{
|
||||||
"playlist": "Playlist",
|
"playlist": "Playlist",
|
||||||
"pmsID": "PMS ID",
|
"pmsID": "PMS ID",
|
||||||
"filter": "Filter",
|
"filter": "Filter",
|
||||||
@@ -11,7 +13,8 @@
|
|||||||
"log": "Log",
|
"log": "Log",
|
||||||
"logout": "Logout"
|
"logout": "Logout"
|
||||||
},
|
},
|
||||||
"headline": {
|
"headline":
|
||||||
|
{
|
||||||
"playlist": "Local or remote playlists",
|
"playlist": "Local or remote playlists",
|
||||||
"filter": "Filter playlist",
|
"filter": "Filter playlist",
|
||||||
"xmltv": "Local or remote XMLTV files",
|
"xmltv": "Local or remote XMLTV files",
|
||||||
@@ -22,19 +25,23 @@
|
|||||||
"logout": "Logout"
|
"logout": "Logout"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"confirm":{
|
"confirm":
|
||||||
|
{
|
||||||
"restore": "All data will be replaced with those from the backup. Should the files be restored?"
|
"restore": "All data will be replaced with those from the backup. Should the files be restored?"
|
||||||
},
|
},
|
||||||
"alert": {
|
"alert":
|
||||||
|
{
|
||||||
"fileLoadingError": "File couldn't be loaded",
|
"fileLoadingError": "File couldn't be loaded",
|
||||||
"invalidChannelNumber": "Invalid channel number",
|
"invalidChannelNumber": "Invalid channel number",
|
||||||
"missingInput": "Missing input"
|
"missingInput": "Missing input"
|
||||||
},
|
},
|
||||||
"button":{
|
"button":
|
||||||
|
{
|
||||||
"back": "Back",
|
"back": "Back",
|
||||||
"backup": "Backup",
|
"backup": "Backup",
|
||||||
"bulkEdit": "Bulk Edit",
|
"bulkEdit": "Bulk Edit",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"edit": "Edit",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"done": "Done",
|
"done": "Done",
|
||||||
"login": "Login",
|
"login": "Login",
|
||||||
@@ -48,58 +55,70 @@
|
|||||||
"resetLogs": "Reset Logs",
|
"resetLogs": "Reset Logs",
|
||||||
"uploadLogo": "Upload Logo"
|
"uploadLogo": "Upload Logo"
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter":
|
||||||
"table": {
|
{
|
||||||
|
"table":
|
||||||
|
{
|
||||||
"name": "Filter Name",
|
"name": "Filter Name",
|
||||||
"type": "Filter Type",
|
"type": "Filter Type",
|
||||||
"filter": "Filter"
|
"filter": "Filter"
|
||||||
},
|
},
|
||||||
"custom": "Custom",
|
"custom": "Custom",
|
||||||
"group": "Group",
|
"group": "Group",
|
||||||
"name": {
|
"name":
|
||||||
|
{
|
||||||
"title": "Filter Name",
|
"title": "Filter Name",
|
||||||
"placeholder": "Filter name",
|
"placeholder": "Filter name",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"description": {
|
"description":
|
||||||
|
{
|
||||||
"title": "Description",
|
"title": "Description",
|
||||||
"placeholder": "Description",
|
"placeholder": "Description",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"type": {
|
"type":
|
||||||
|
{
|
||||||
"title": "Type",
|
"title": "Type",
|
||||||
"groupTitle": "Group Title",
|
"groupTitle": "Group Title",
|
||||||
"customFilter": "Custom Filter"
|
"customFilter": "Custom Filter"
|
||||||
},
|
},
|
||||||
"caseSensitive": {
|
"caseSensitive":
|
||||||
|
{
|
||||||
"title": "Case Sensitive",
|
"title": "Case Sensitive",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"filterRule": {
|
"filterRule":
|
||||||
|
{
|
||||||
"title": "Filter Rule",
|
"title": "Filter Rule",
|
||||||
"placeholder": "Sport {HD} !{ES,IT}",
|
"placeholder": "Sport {HD} !{ES,IT}",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"filterGroup": {
|
"filterGroup":
|
||||||
|
{
|
||||||
"title": "Group Title",
|
"title": "Group Title",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": "Select a M3U group. (Counter)<br>Changing the group title in the M3U invalidates the filter."
|
"description": "Select a M3U group. (Counter)<br>Changing the group title in the M3U invalidates the filter."
|
||||||
},
|
},
|
||||||
"include": {
|
"include":
|
||||||
|
{
|
||||||
"title": "Include",
|
"title": "Include",
|
||||||
"placeholder": "FHD,UHD",
|
"placeholder": "FHD,UHD",
|
||||||
"description": "Channel name must include.<br>(Comma separated) Comma means or"
|
"description": "Channel name must include.<br>(Comma separated) Comma means or"
|
||||||
},
|
},
|
||||||
"exclude": {
|
"exclude":
|
||||||
|
{
|
||||||
"title": "Exclude",
|
"title": "Exclude",
|
||||||
"placeholder": "ES,IT",
|
"placeholder": "ES,IT",
|
||||||
"description": "Channel name must not contain.<br>(Comma separated) Comma means or"
|
"description": "Channel name must not contain.<br>(Comma separated) Comma means or"
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"playlist": {
|
"playlist":
|
||||||
"table": {
|
{
|
||||||
|
"table":
|
||||||
|
{
|
||||||
"playlist": "Playlist",
|
"playlist": "Playlist",
|
||||||
"tuner": "Tuner",
|
"tuner": "Tuner",
|
||||||
"lastUpdate": "Last Update",
|
"lastUpdate": "Last Update",
|
||||||
@@ -110,129 +129,156 @@
|
|||||||
"tvgID": "tvg-id",
|
"tvgID": "tvg-id",
|
||||||
"uniqueID": "Unique ID"
|
"uniqueID": "Unique ID"
|
||||||
},
|
},
|
||||||
"playlistType": {
|
"playlistType":
|
||||||
|
{
|
||||||
"title": "Playlist type",
|
"title": "Playlist type",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"type": {
|
"type":
|
||||||
|
{
|
||||||
"title": "Type",
|
"title": "Type",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"name": {
|
"name":
|
||||||
|
{
|
||||||
"title": "Name",
|
"title": "Name",
|
||||||
"placeholder": "Playlist name",
|
"placeholder": "Playlist name",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"description": {
|
"description":
|
||||||
|
{
|
||||||
"title": "Description",
|
"title": "Description",
|
||||||
"placeholder": "Description",
|
"placeholder": "Description",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"fileM3U": {
|
"fileM3U":
|
||||||
|
{
|
||||||
"title": "M3U File",
|
"title": "M3U File",
|
||||||
"placeholder": "File path or URL of the M3U",
|
"placeholder": "File path or URL of the M3U",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"fileHDHR": {
|
"fileHDHR":
|
||||||
|
{
|
||||||
"title": "HDHomeRun IP",
|
"title": "HDHomeRun IP",
|
||||||
"placeholder": "IP address and port (192.168.1.10:5004)",
|
"placeholder": "IP address and port (192.168.1.10:5004)",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"tuner": {
|
"tuner":
|
||||||
|
{
|
||||||
"title": "Tuner / Streams",
|
"title": "Tuner / Streams",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": "Number of parallel connections that can be established to the provider. <br>Only available with activated buffer.<br>New settings will only be applied after quitting all streams."
|
"description": "Number of parallel connections that can be established to the provider. <br>Only available with activated buffer.<br>New settings will only be applied after quitting all streams."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"xmltv": {
|
"xmltv":
|
||||||
"table": {
|
{
|
||||||
|
"table":
|
||||||
|
{
|
||||||
"guide": "Guide",
|
"guide": "Guide",
|
||||||
"lastUpdate": "Last Update",
|
"lastUpdate": "Last Update",
|
||||||
"availability": "Availability",
|
"availability": "Availability",
|
||||||
"channels": "Channels",
|
"channels": "Channels",
|
||||||
"programs": "Programs"
|
"programs": "Programs"
|
||||||
},
|
},
|
||||||
"name": {
|
"name":
|
||||||
|
{
|
||||||
"title": "Name",
|
"title": "Name",
|
||||||
"placeholder": "Guide name",
|
"placeholder": "Guide name",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"description": {
|
"description":
|
||||||
|
{
|
||||||
"title": "Description",
|
"title": "Description",
|
||||||
"placeholder": "Description",
|
"placeholder": "Description",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"fileXMLTV": {
|
"fileXMLTV":
|
||||||
|
{
|
||||||
"title": "XMLTV File",
|
"title": "XMLTV File",
|
||||||
"placeholder": "File path or URL of the XMLTV",
|
"placeholder": "File path or URL of the XMLTV",
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mapping": {
|
"mapping":
|
||||||
"table": {
|
{
|
||||||
|
"table":
|
||||||
|
{
|
||||||
"chNo": "Ch. No.",
|
"chNo": "Ch. No.",
|
||||||
"logo": "Logo",
|
"logo": "Logo",
|
||||||
"channelName": "Channel Name",
|
"channelName": "Channel Name",
|
||||||
"playlist": "Playlist",
|
"playlist": "Playlist",
|
||||||
"groupTitle": "Group Title",
|
"groupTitle": "Group Title",
|
||||||
"xmltvFile": "XMLTV File",
|
"xmltvFile": "XMLTV File",
|
||||||
"xmltvID": "XMLTV ID"
|
"xmltvID": "XMLTV ID",
|
||||||
|
"edit": "Edit"
|
||||||
},
|
},
|
||||||
"active": {
|
"active":
|
||||||
|
{
|
||||||
"title": "Active",
|
"title": "Active",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"channelName": {
|
"channelName":
|
||||||
|
{
|
||||||
"title": "Channel Name",
|
"title": "Channel Name",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"description": {
|
"description":
|
||||||
|
{
|
||||||
"title": "Channel Description",
|
"title": "Channel Description",
|
||||||
"placeholder": "Used by the Dummy as an XML description",
|
"placeholder": "Used by the Dummy as an XML description",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"updateChannelName": {
|
"updateChannelName":
|
||||||
|
{
|
||||||
"title": "Update Channel Name",
|
"title": "Update Channel Name",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"channelLogo": {
|
"channelLogo":
|
||||||
|
{
|
||||||
"title": "Logo URL",
|
"title": "Logo URL",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"updateChannelLogo": {
|
"updateChannelLogo":
|
||||||
|
{
|
||||||
"title": "Update Channel Logo",
|
"title": "Update Channel Logo",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"epgCategory": {
|
"epgCategory":
|
||||||
|
{
|
||||||
"title": "EPG Category",
|
"title": "EPG Category",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"m3uGroupTitle": {
|
"m3uGroupTitle":
|
||||||
|
{
|
||||||
"title": "Group Title (xteve.m3u)",
|
"title": "Group Title (xteve.m3u)",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"xmltvFile": {
|
"xmltvFile":
|
||||||
|
{
|
||||||
"title": "XMLTV File",
|
"title": "XMLTV File",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"xmltvChannel": {
|
"xmltvChannel":
|
||||||
|
{
|
||||||
"title": "XMLTV Channel",
|
"title": "XMLTV Channel",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"users": {
|
"users":
|
||||||
"table": {
|
{
|
||||||
|
"table":
|
||||||
|
{
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
"web": "WEB",
|
"web": "WEB",
|
||||||
@@ -241,97 +287,132 @@
|
|||||||
"xml": "XML",
|
"xml": "XML",
|
||||||
"api": "API"
|
"api": "API"
|
||||||
},
|
},
|
||||||
"username": {
|
"username":
|
||||||
|
{
|
||||||
"title": "Username",
|
"title": "Username",
|
||||||
"placeholder": "Username",
|
"placeholder": "Username",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"password": {
|
"password":
|
||||||
|
{
|
||||||
"title": "Password",
|
"title": "Password",
|
||||||
"placeholder": "Password",
|
"placeholder": "Password",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"confirm": {
|
"confirm":
|
||||||
|
{
|
||||||
"title": "Confirm",
|
"title": "Confirm",
|
||||||
"placeholder": "Password confirm",
|
"placeholder": "Password confirm",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"web": {
|
"web":
|
||||||
|
{
|
||||||
"title": "Web Access",
|
"title": "Web Access",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"pms": {
|
"pms":
|
||||||
|
{
|
||||||
"title": "PMS Access",
|
"title": "PMS Access",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"m3u": {
|
"m3u":
|
||||||
|
{
|
||||||
"title": "M3U Access",
|
"title": "M3U Access",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"xml": {
|
"xml":
|
||||||
|
{
|
||||||
"title": "XML Access",
|
"title": "XML Access",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"api": {
|
"api":
|
||||||
|
{
|
||||||
"title": "API Access",
|
"title": "API Access",
|
||||||
"placeholder": "",
|
"placeholder": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings":
|
||||||
"category": {
|
{
|
||||||
|
"category":
|
||||||
|
{
|
||||||
"general": "General",
|
"general": "General",
|
||||||
"files": "Files",
|
"files": "Files",
|
||||||
"streaming": "Streaming",
|
"streaming": "Streaming",
|
||||||
"backup": "Backup",
|
"backup": "Backup",
|
||||||
"authentication": "Authentication"
|
"authentication": "Authentication"
|
||||||
},
|
},
|
||||||
"update": {
|
"update":
|
||||||
|
{
|
||||||
"title": "Schedule for updating (Playlist, XMLTV, Backup)",
|
"title": "Schedule for updating (Playlist, XMLTV, Backup)",
|
||||||
"placeholder": "0000,1000,2000",
|
"placeholder": "0000,1000,2000",
|
||||||
"description": "Time in 24 hour format (0800 = 8:00 am). More times can be entered comma separated."
|
"description": "Time in 24 hour format (0800 = 8:00 am). More times can be entered comma separated. Leave this field empty if no updates are to be carried out."
|
||||||
},
|
},
|
||||||
"api": {
|
"api":
|
||||||
|
{
|
||||||
"title": "API Interface",
|
"title": "API Interface",
|
||||||
"description": "Via API interface it is possible to send commands to xTeVe. API documentation is <a href='https://github.com/xteve-project/xTeVe-Documentation/blob/master/en/configuration.md#api'>here</a>"
|
"description": "Via API interface it is possible to send commands to xTeVe. API documentation is <a href='https://github.com/xteve-project/xTeVe-Documentation/blob/master/en/configuration.md#api'>here</a>"
|
||||||
},
|
},
|
||||||
"epgSource": {
|
"usePlexAPI":
|
||||||
|
{
|
||||||
|
"title": "Use Plex API Refresh",
|
||||||
|
"description": "When enabled, xTeVe calls Plex directly to refresh DVR guide data after lineup or XEPG updates."
|
||||||
|
},
|
||||||
|
"plexURL":
|
||||||
|
{
|
||||||
|
"title": "Plex Server URL",
|
||||||
|
"description": "Base URL of your Plex server. Example: http://192.168.1.10:32400",
|
||||||
|
"placeholder": "http://plex-host:32400"
|
||||||
|
},
|
||||||
|
"plexToken":
|
||||||
|
{
|
||||||
|
"title": "Plex API Token",
|
||||||
|
"description": "Plex token used for authenticated API calls to refresh your DVR guide.",
|
||||||
|
"placeholder": "Plex X-Plex-Token"
|
||||||
|
},
|
||||||
|
"epgSource":
|
||||||
|
{
|
||||||
"title": "EPG Source",
|
"title": "EPG Source",
|
||||||
"description": "PMS:<br>- Use EPG data from Plex or Emby <br><br>XEPG:<br>- Use of one or more XMLTV files<br>- Channel management<br>- M3U / XMLTV export (HTTP link for IPTV apps)"
|
"description": "PMS:<br>- Use EPG data from Plex or Emby <br><br>XEPG:<br>- Use of one or more XMLTV files<br>- Channel management<br>- M3U / XMLTV export (HTTP link for IPTV apps)"
|
||||||
},
|
},
|
||||||
"tuner":{
|
"tuner":
|
||||||
|
{
|
||||||
"title": "Number of Tuners",
|
"title": "Number of Tuners",
|
||||||
"description": "Number of parallel connections that can be established to the provider.<br>Available for: Plex, Emby (HDHR), M3U (with active buffer).<br>After a change, xTeVe must be delete in the Plex / Emby DVR settings and set up again."
|
"description": "Number of parallel connections that can be established to the provider.<br>Available for: Plex, Emby (HDHR), M3U (with active buffer).<br>After a change, xTeVe must be delete in the Plex / Emby DVR settings and set up again."
|
||||||
},
|
},
|
||||||
"schemeM3U":{
|
"filesUpdate":
|
||||||
"title": "URL protocol for xteve.m3u",
|
{
|
||||||
"description": "Determines which URL protocol is used for the xTeVe streaming URLs. If you using a reverse proxy over HTTPS, set this to HTTPS."
|
|
||||||
},
|
|
||||||
"schemeXML":{
|
|
||||||
"title": "URL protocol for xteve.xml",
|
|
||||||
"description": "Determines which URL protocol is used for the xTeVe image URLs. If you using a reverse proxy over HTTPS, set this to HTTPS."
|
|
||||||
},
|
|
||||||
"filesUpdate": {
|
|
||||||
"title": "Updates all files at startup",
|
"title": "Updates all files at startup",
|
||||||
"description": "Updates all playlists, tuner and XMLTV files at startup."
|
"description": "Updates all playlists, tuner and XMLTV files at startup."
|
||||||
},
|
},
|
||||||
"cacheImages": {
|
"cacheImages":
|
||||||
|
{
|
||||||
"title": "Image Caching",
|
"title": "Image Caching",
|
||||||
"description": "All images from the XMLTV file are cached, allowing faster rendering of the grid in the client.<br>Downloading the images may take a while and will be done in the background."
|
"description": "All images from the XMLTV file are cached, allowing faster rendering of the grid in the client.<br>Downloading the images may take a while and will be done in the background."
|
||||||
},
|
},
|
||||||
"replaceEmptyImages": {
|
"replaceEmptyImages":
|
||||||
|
{
|
||||||
"title": "Replace missing program images",
|
"title": "Replace missing program images",
|
||||||
"description": "If the poster in the XMLTV program is missing, the channel logo will be used."
|
"description": "If the poster in the XMLTV program is missing, the channel logo will be used."
|
||||||
},
|
},
|
||||||
"xteveAutoUpdate": {
|
"xepgMissingEPGMode":
|
||||||
|
{
|
||||||
|
"title": "Missing EPG Handling",
|
||||||
|
"description": "Strict: channels are deactivated when XMLTV mappings disappear.<br>Relaxed: channels stay active with last-known mappings and fall back to a dummy guide whenever guide data cannot be resolved.",
|
||||||
|
"info_strict": "Strict (deactivate channels)",
|
||||||
|
"info_relaxed": "Relaxed (keep active / dummy guide)"
|
||||||
|
},
|
||||||
|
"xteveAutoUpdate":
|
||||||
|
{
|
||||||
"title": "Automatic update of xTeVe",
|
"title": "Automatic update of xTeVe",
|
||||||
"description": "If a new version of xTeVe is available, it will be automatically installed. The updates are downloaded from GitHub."
|
"description": "If a new version of xTeVe is available, it will be automatically installed. The updates are downloaded from GitHub."
|
||||||
},
|
},
|
||||||
"streamBuffering": {
|
"streamBuffering":
|
||||||
|
{
|
||||||
"title": "Stream Buffer",
|
"title": "Stream Buffer",
|
||||||
"description": "Functions of the buffer:<br>- The stream is passed from xTeVe, FFmpeg or VLC to Plex, Emby or M3U Player<br>- Small jerking of the streams can be compensated<br>- HLS / M3U8 support<br>- RTP / RTPS support (only FFmpeg or VLC)<br>- Re-streaming<br>- Separate tuner limit for each playlist",
|
"description": "Functions of the buffer:<br>- The stream is passed from xTeVe, FFmpeg or VLC to Plex, Emby or M3U Player<br>- Small jerking of the streams can be compensated<br>- HLS / M3U8 support<br>- RTP / RTPS support (only FFmpeg or VLC)<br>- Re-streaming<br>- Separate tuner limit for each playlist",
|
||||||
"info_false": "No Buffer (Client connects to the streaming server)",
|
"info_false": "No Buffer (Client connects to the streaming server)",
|
||||||
@@ -340,119 +421,152 @@
|
|||||||
"info_vlc": "VLC connects to the streaming server"
|
"info_vlc": "VLC connects to the streaming server"
|
||||||
|
|
||||||
},
|
},
|
||||||
"ffmpegPath": {
|
"udpxy":
|
||||||
|
{
|
||||||
|
"title": "UDPxy address",
|
||||||
|
"description": "The address of your UDPxy server. If set, and the channel URLs in the m3u is multicast, xTeVe will rewrite it so that it is accessed via the UDPxy service.",
|
||||||
|
"placeholder": "host:port"
|
||||||
|
},
|
||||||
|
"ffmpegPath":
|
||||||
|
{
|
||||||
"title": "FFmpeg Binary Path",
|
"title": "FFmpeg Binary Path",
|
||||||
"description": "Path to FFmpeg binary.",
|
"description": "Path to FFmpeg binary.",
|
||||||
"placeholder": "/path/to/ffmpeg"
|
"placeholder": "/path/to/ffmpeg"
|
||||||
},
|
},
|
||||||
"ffmpegOptions": {
|
"ffmpegOptions":
|
||||||
|
{
|
||||||
"title": "FFmpeg Options",
|
"title": "FFmpeg Options",
|
||||||
"description": "FFmpeg options.<br>Only change if you know what you are doing.<br>Leave blank to set default settings.",
|
"description": "FFmpeg options.<br>Only change if you know what you are doing.<br>Leave blank to set default settings.",
|
||||||
"placeholder": "Leave blank to set default settings"
|
"placeholder": "Leave blank to set default settings"
|
||||||
},
|
},
|
||||||
"vlcPath": {
|
"vlcPath":
|
||||||
|
{
|
||||||
"title": "VLC / CVLC Binary Path",
|
"title": "VLC / CVLC Binary Path",
|
||||||
"description": "Path to VLC / CVLC binary.",
|
"description": "Path to VLC / CVLC binary.",
|
||||||
"placeholder": "/path/to/cvlc"
|
"placeholder": "/path/to/cvlc"
|
||||||
},
|
},
|
||||||
"vlcOptions": {
|
"vlcOptions":
|
||||||
|
{
|
||||||
"title": "VLC / CVLC Options",
|
"title": "VLC / CVLC Options",
|
||||||
"description": "VLC / CVLC options.<br>Only change if you know what you are doing.<br>Leave blank to set default settings.",
|
"description": "VLC / CVLC options.<br>Only change if you know what you are doing.<br>Leave blank to set default settings.",
|
||||||
"placeholder": "Leave blank to set default settings"
|
"placeholder": "Leave blank to set default settings"
|
||||||
},
|
},
|
||||||
"bufferSize": {
|
"bufferSize":
|
||||||
|
{
|
||||||
"title": "Buffer Size",
|
"title": "Buffer Size",
|
||||||
"description": "Buffer size in MB.<br>M3U8: If the TS segment smaller then the buffer size, the file size of the segment is used."
|
"description": "Buffer size in MB.<br>M3U8: If the TS segment smaller then the buffer size, the file size of the segment is used."
|
||||||
},
|
},
|
||||||
"bufferTimeout": {
|
"bufferTimeout":
|
||||||
|
{
|
||||||
"title": "Timeout for new client connections",
|
"title": "Timeout for new client connections",
|
||||||
"description": "The xTeVe buffer waits until new client connections are established. Helpful for fast channel switching. Value in milliseconds.",
|
"description": "The xTeVe buffer waits until new client connections are established. Helpful for fast channel switching. Value in milliseconds.",
|
||||||
"placeholder": "100"
|
"placeholder": "100"
|
||||||
},
|
},
|
||||||
"userAgent": {
|
"userAgent":
|
||||||
|
{
|
||||||
"title": "User Agent",
|
"title": "User Agent",
|
||||||
"description": "User Agent for HTTP requests. For every HTTP connection, this value is used for the user agent. Should only be changed if xTeVe is blocked.",
|
"description": "User Agent for HTTP requests. For every HTTP connection, this value is used for the user agent. Should only be changed if xTeVe is blocked.",
|
||||||
"placeholder": "xTeVe"
|
"placeholder": "xTeVe"
|
||||||
},
|
},
|
||||||
"backupPath": {
|
"backupPath":
|
||||||
|
{
|
||||||
"title": "Location for automatic backups",
|
"title": "Location for automatic backups",
|
||||||
"placeholder": "/mnt/data/backup/xteve/",
|
"placeholder": "/mnt/data/backup/xteve/",
|
||||||
"description": "Before any update of the provider data by the schedule, xTeVe creates a backup. The path for the automatic backups can be changed. xTeVe requires write permission for this folder."
|
"description": "Before any update of the provider data by the schedule, xTeVe creates a backup. The path for the automatic backups can be changed. xTeVe requires write permission for this folder."
|
||||||
},
|
},
|
||||||
"tempPath": {
|
"tempPath":
|
||||||
|
{
|
||||||
"title": "Location for the temporary files",
|
"title": "Location for the temporary files",
|
||||||
"placeholder": "/tmp/xteve/",
|
"placeholder": "/tmp/xteve/",
|
||||||
"description": "Location for the buffer files."
|
"description": "Location for the buffer files."
|
||||||
},
|
},
|
||||||
"backupKeep": {
|
"backupKeep":
|
||||||
|
{
|
||||||
"title": "Number of backups to keep",
|
"title": "Number of backups to keep",
|
||||||
"description": "Number of backups to keep. Older backups are automatically deleted."
|
"description": "Number of backups to keep. Older backups are automatically deleted."
|
||||||
},
|
},
|
||||||
"authenticationWEB": {
|
"authenticationWEB":
|
||||||
|
{
|
||||||
"title": "WEB Authentication",
|
"title": "WEB Authentication",
|
||||||
"description": "Access to the web interface only possible with credentials."
|
"description": "Access to the web interface only possible with credentials."
|
||||||
},
|
},
|
||||||
"authenticationPMS": {
|
"authenticationPMS":
|
||||||
|
{
|
||||||
"title": "PMS Authentication",
|
"title": "PMS Authentication",
|
||||||
"description": "Plex requests are only possible with authentication. <br><b>Warning!!!</b> After activating this function xTeVe must be delete in the PMS DVR settings and set up again."
|
"description": "Plex requests are only possible with authentication. <br><b>Warning!!!</b> After activating this function xTeVe must be delete in the PMS DVR settings and set up again."
|
||||||
},
|
},
|
||||||
"authenticationM3U": {
|
"authenticationM3U":
|
||||||
|
{
|
||||||
"title": "M3U Authentication",
|
"title": "M3U Authentication",
|
||||||
"description": "Downloading the xteve.m3u file via an HTTP request is only possible with authentication."
|
"description": "Downloading the xteve.m3u file via an HTTP request is only possible with authentication."
|
||||||
},
|
},
|
||||||
"authenticationXML": {
|
"authenticationXML":
|
||||||
|
{
|
||||||
"title": "XML Authentication",
|
"title": "XML Authentication",
|
||||||
"description": "Downloading the xteve.xml file via an HTTP request is only possible with authentication"
|
"description": "Downloading the xteve.xml file via an HTTP request is only possible with authentication"
|
||||||
},
|
},
|
||||||
"authenticationAPI": {
|
"authenticationAPI":
|
||||||
|
{
|
||||||
"title": "API Authentication",
|
"title": "API Authentication",
|
||||||
"description": "Access to the API interface is only possible with authentication."
|
"description": "Access to the API interface is only possible with authentication."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"wizard": {
|
"wizard":
|
||||||
"epgSource": {
|
{
|
||||||
|
"epgSource":
|
||||||
|
{
|
||||||
"title": "EPG Source",
|
"title": "EPG Source",
|
||||||
"description": "PMS:<br>- Use EPG data from Plex or Emby <br><br>XEPG:<br>- Use of one or more XMLTV files<br>- Channel management<br>- M3U / XMLTV export (HTTP link for IPTV apps)"
|
"description": "PMS:<br>- Use EPG data from Plex or Emby <br><br>XEPG:<br>- Use of one or more XMLTV files<br>- Channel management<br>- M3U / XMLTV export (HTTP link for IPTV apps)"
|
||||||
},
|
},
|
||||||
"tuner":{
|
"tuner":
|
||||||
|
{
|
||||||
"title": "Number of tuners",
|
"title": "Number of tuners",
|
||||||
"description": "Number of parallel connections that can be established to the provider.<br>Available for: Plex, Emby (HDHR), M3U (with active buffer).<br>After a change, xTeVe must be delete in the Plex / Emby DVR settings and set up again."
|
"description": "Number of parallel connections that can be established to the provider.<br>Available for: Plex, Emby (HDHR), M3U (with active buffer).<br>After a change, xTeVe must be delete in the Plex / Emby DVR settings and set up again."
|
||||||
},
|
},
|
||||||
"m3u": {
|
"m3u":
|
||||||
|
{
|
||||||
"title": "M3U Playlist",
|
"title": "M3U Playlist",
|
||||||
"placeholder": "File path or URL of the M3U",
|
"placeholder": "File path or URL of the M3U",
|
||||||
"description": "Local or remote playlists"
|
"description": "Local or remote playlists"
|
||||||
},
|
},
|
||||||
"xmltv": {
|
"xmltv":
|
||||||
|
{
|
||||||
"title": "XMLTV File",
|
"title": "XMLTV File",
|
||||||
"placeholder": "File path or URL of the XMLTV",
|
"placeholder": "File path or URL of the XMLTV",
|
||||||
"description": "Local or remote XMLTV file"
|
"description": "Local or remote XMLTV file"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"login": {
|
"login":
|
||||||
|
{
|
||||||
"failed": "User authentication failed",
|
"failed": "User authentication failed",
|
||||||
"headline": "Login",
|
"headline": "Login",
|
||||||
"username": {
|
"username":
|
||||||
|
{
|
||||||
"title": "Username",
|
"title": "Username",
|
||||||
"placeholder": "Username"
|
"placeholder": "Username"
|
||||||
},
|
},
|
||||||
"password": {
|
"password":
|
||||||
|
{
|
||||||
"title": "Password",
|
"title": "Password",
|
||||||
"placeholder": "Password"
|
"placeholder": "Password"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"account": {
|
"account":
|
||||||
|
{
|
||||||
"failed": "Password does not match",
|
"failed": "Password does not match",
|
||||||
"headline": "Create user account",
|
"headline": "Create user account",
|
||||||
"username": {
|
"username":
|
||||||
|
{
|
||||||
"title": "Username",
|
"title": "Username",
|
||||||
"placeholder": "Username"
|
"placeholder": "Username"
|
||||||
},
|
},
|
||||||
"password": {
|
"password":
|
||||||
|
{
|
||||||
"title": "Password",
|
"title": "Password",
|
||||||
"placeholder": "Password"
|
"placeholder": "Password"
|
||||||
},
|
},
|
||||||
"confirm": {
|
"confirm":
|
||||||
|
{
|
||||||
"title": "Confirm",
|
"title": "Confirm",
|
||||||
"placeholder": "Confirm"
|
"placeholder": "Confirm"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,36 +10,36 @@
|
|||||||
<script language="javascript" type="text/javascript" src="js/authentication_ts.js"></script>
|
<script language="javascript" type="text/javascript" src="js/authentication_ts.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class="auth-screen">
|
||||||
|
|
||||||
<div id="header" class="imgCenter"></div>
|
<div id="header" class="imgCenter"></div>
|
||||||
|
|
||||||
<div id="box">
|
<main id="box" role="main" aria-labelledby="head-text">
|
||||||
|
|
||||||
<div id="headline">
|
<div id="headline">
|
||||||
<h1 id="head-text" class="center">{{.login.headline}}</h1>
|
<h1 id="head-text" class="center">{{.login.headline}}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p id="err" class="errorMsg center">{{.authenticationErr}}</p>
|
<p id="err" class="errorMsg center" role="alert" aria-live="assertive" aria-atomic="true">{{.authenticationErr}}</p>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
<form id="authentication" action="/web/" method="post">
|
<form id="authentication" action="" method="post" aria-describedby="err" novalidate>
|
||||||
|
|
||||||
<h5>{{.login.username.title}}:</h5>
|
<label for="username">{{.login.username.title}}:</label>
|
||||||
<input id="username" type="text" name="username" placeholder="Username" value="">
|
<input id="username" type="text" name="username" placeholder="Username" value="" autocomplete="username">
|
||||||
<h5>{{.login.password.title}}:</h5>
|
<label for="password">{{.login.password.title}}:</label>
|
||||||
<input id="password" type="password" name="password" placeholder="Password" value="">
|
<input id="password" type="password" name="password" placeholder="Password" value="" autocomplete="current-password">
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="box-footer">
|
<div id="box-footer">
|
||||||
<input id="submit" class="" type="button" value="{{.button.login}}" onclick="javascript: login();">
|
<input id="submit" class="" type="button" value="{{.button.login}}" aria-label="{{.button.login}}" onclick="javascript: login();">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</main>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="css/base.css" type="text/css">
|
<link rel="stylesheet" href="css/base.css" type="text/css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class="auth-screen">
|
||||||
|
|
||||||
<div id="header" class="imgCenter"></div>
|
<div id="header" class="imgCenter"></div>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../src/internal/authentication"
|
"xteve/src/internal/authentication"
|
||||||
)
|
)
|
||||||
|
|
||||||
func activatedSystemAuthentication() (err error) {
|
func activatedSystemAuthentication() (err error) {
|
||||||
@@ -16,7 +16,7 @@ func activatedSystemAuthentication() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaults = make(map[string]interface{})
|
var defaults = make(map[string]any)
|
||||||
defaults["authentication.web"] = false
|
defaults["authentication.web"] = false
|
||||||
defaults["authentication.pms"] = false
|
defaults["authentication.pms"] = false
|
||||||
defaults["authentication.xml"] = false
|
defaults["authentication.xml"] = false
|
||||||
@@ -43,7 +43,7 @@ func createFirstUserForAuthentication(username, password string) (token string,
|
|||||||
token, err = authentication.CheckTheValidityOfTheToken(token)
|
token, err = authentication.CheckTheValidityOfTheToken(token)
|
||||||
authenticationErr(err)
|
authenticationErr(err)
|
||||||
|
|
||||||
var userData = make(map[string]interface{})
|
var userData = make(map[string]any)
|
||||||
userData["username"] = username
|
userData["username"] = username
|
||||||
userData["authentication.web"] = true
|
userData["authentication.web"] = true
|
||||||
userData["authentication.pms"] = true
|
userData["authentication.pms"] = true
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package src
|
package src
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Tuner-Limit Bild als Video rendern [ffmpeg]
|
Tuner-Limit Bild als Video rendern [ffmpeg]
|
||||||
-loop 1 -i stream-limit.jpg -c:v libx264 -t 1 -pix_fmt yuv420p -vf scale=1920:1080 stream-limit.ts
|
-loop 1 -i stream-limit.jpg -c:v libx264 -t 1 -pix_fmt yuv420p -vf scale=1920:1080 stream-limit.ts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -228,7 +228,7 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
|
|
||||||
for { // Loop 1: Warten bis das erste Segment durch den Buffer heruntergeladen wurde
|
for { // Loop 1: Warten bis das erste Segment durch den Buffer heruntergeladen wurde
|
||||||
|
|
||||||
@@ -332,23 +332,22 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
|
|||||||
|
|
||||||
if streaming == false {
|
if streaming == false {
|
||||||
|
|
||||||
contentType := http.DetectContentType(buffer) + "; name=stream.ts"
|
contentType := http.DetectContentType(buffer)
|
||||||
//_ = contentType
|
_ = contentType
|
||||||
//w.Header().Set("Content-type", "video/mpeg")
|
//w.Header().Set("Content-type", "video/mpeg")
|
||||||
w.Header().Add("Content-type", contentType)
|
w.Header().Set("Content-type", contentType)
|
||||||
w.Header().Set("Content-Length", "0")
|
w.Header().Set("Content-Length", "0")
|
||||||
w.Header().Set("Connection", "close")
|
w.Header().Set("Connection", "close")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// HDHR Header
|
// HDHR Header
|
||||||
w.Header().Set("Cache-Control", "no-cache")
|
w.Header().Set("Cache-Control", "no-cache")
|
||||||
w.Header().Set("Pragma", "no-cache")
|
w.Header().Set("Pragma", "no-cache")
|
||||||
w.Header().Set("transferMode.dlna.org", "Streaming")
|
w.Header().Set("transferMode.dlna.org", "Streaming")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
w.WriteHeader(200)
|
|
||||||
_, err := w.Write(buffer)
|
_, err := w.Write(buffer)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -658,7 +657,7 @@ func connectToStreamingServer(streamID int, playlistID string) {
|
|||||||
Redirect:
|
Redirect:
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", currentURL, nil)
|
req, err := http.NewRequest("GET", currentURL, nil)
|
||||||
req.Header.Set("User-Agent", Settings.UserAgent)
|
req.Header.Set("User-Agent", getUserAgent())
|
||||||
req.Header.Set("Connection", "close")
|
req.Header.Set("Connection", "close")
|
||||||
//req.Header.Set("Range", "bytes=0-")
|
//req.Header.Set("Range", "bytes=0-")
|
||||||
req.Header.Set("Accept", "*/*")
|
req.Header.Set("Accept", "*/*")
|
||||||
@@ -825,7 +824,7 @@ func connectToStreamingServer(streamID int, playlistID string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Video Stream (TS)
|
// Video Stream (TS)
|
||||||
case "video/mpeg", "video/mp4", "video/mp2t", "video/m2ts", "application/octet-stream", "binary/octet-stream", "application/mp2t":
|
case "video/mpeg", "video/mp4", "video/mp2t", "video/m2ts", "application/octet-stream", "binary/octet-stream", "application/mp2t", "video/x-matroska":
|
||||||
|
|
||||||
var fileSize int
|
var fileSize int
|
||||||
|
|
||||||
@@ -1424,13 +1423,17 @@ func thirdPartyBuffer(streamID int, playlistID string) {
|
|||||||
// User-Agent setzen
|
// User-Agent setzen
|
||||||
var args []string
|
var args []string
|
||||||
|
|
||||||
|
var userAgent = getUserAgent()
|
||||||
|
|
||||||
for i, a := range strings.Split(options, " ") {
|
for i, a := range strings.Split(options, " ") {
|
||||||
|
|
||||||
switch bufferType {
|
switch bufferType {
|
||||||
case "FFMPEG":
|
case "FFMPEG":
|
||||||
a = strings.Replace(a, "[URL]", url, -1)
|
a = strings.Replace(a, "[URL]", url, -1)
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
args = []string{"-user-agent", Settings.UserAgent}
|
if len(userAgent) != 0 {
|
||||||
|
args = []string{"-user_agent", userAgent}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append(args, a)
|
args = append(args, a)
|
||||||
@@ -1439,7 +1442,10 @@ func thirdPartyBuffer(streamID int, playlistID string) {
|
|||||||
if a == "[URL]" {
|
if a == "[URL]" {
|
||||||
a = strings.Replace(a, "[URL]", url, -1)
|
a = strings.Replace(a, "[URL]", url, -1)
|
||||||
args = append(args, a)
|
args = append(args, a)
|
||||||
args = append(args, fmt.Sprintf(":http-user-agent=%s", Settings.UserAgent))
|
|
||||||
|
if len(userAgent) != 0 {
|
||||||
|
args = append(args, fmt.Sprintf(":http-user-agent=%s", userAgent))
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
args = append(args, a)
|
args = append(args, a)
|
||||||
|
|||||||
@@ -146,3 +146,20 @@ func extractGZIP(gzipBody []byte, fileSource string) (body []byte, err error) {
|
|||||||
body = resB.Bytes()
|
body = resB.Bytes()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func compressGZIP(data *[]byte, file string) (err error) {
|
||||||
|
|
||||||
|
if len(file) != 0 {
|
||||||
|
|
||||||
|
f, err := os.Create(file)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w := gzip.NewWriter(f)
|
||||||
|
w.Write(*data)
|
||||||
|
w.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ var System SystemStruct
|
|||||||
var WebScreenLog WebScreenLogStruct
|
var WebScreenLog WebScreenLogStruct
|
||||||
|
|
||||||
// Settings : Inhalt der settings.json
|
// Settings : Inhalt der settings.json
|
||||||
var Settings SettingsStrcut
|
var Settings SettingsStruct
|
||||||
|
|
||||||
// Data : Alle Daten werden hier abgelegt. (Lineup, XMLTV)
|
// Data : Alle Daten werden hier abgelegt. (Lineup, XMLTV)
|
||||||
var Data DataStruct
|
var Data DataStruct
|
||||||
@@ -46,7 +46,8 @@ func Init() (err error) {
|
|||||||
System.ServerProtocol.M3U = "http"
|
System.ServerProtocol.M3U = "http"
|
||||||
System.ServerProtocol.WEB = "http"
|
System.ServerProtocol.WEB = "http"
|
||||||
System.ServerProtocol.XML = "http"
|
System.ServerProtocol.XML = "http"
|
||||||
System.DVRLimit = 480
|
System.PlexChannelLimit = 480
|
||||||
|
System.UnfilteredChannelLimit = 480
|
||||||
System.Compatibility = "1.4.4"
|
System.Compatibility = "1.4.4"
|
||||||
|
|
||||||
// FFmpeg Default Einstellungen
|
// FFmpeg Default Einstellungen
|
||||||
@@ -98,6 +99,8 @@ func Init() (err error) {
|
|||||||
System.File.XML = getPlatformFile(fmt.Sprintf("%s%s.xml", System.Folder.Data, System.AppName))
|
System.File.XML = getPlatformFile(fmt.Sprintf("%s%s.xml", System.Folder.Data, System.AppName))
|
||||||
System.File.M3U = getPlatformFile(fmt.Sprintf("%s%s.m3u", System.Folder.Data, System.AppName))
|
System.File.M3U = getPlatformFile(fmt.Sprintf("%s%s.m3u", System.Folder.Data, System.AppName))
|
||||||
|
|
||||||
|
System.Compressed.GZxml = getPlatformFile(fmt.Sprintf("%s%s.xml.gz", System.Folder.Data, System.AppName))
|
||||||
|
|
||||||
err = activatedSystemAuthentication()
|
err = activatedSystemAuthentication()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -223,13 +226,12 @@ func StartSystem(updateProviderFiles bool) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setURLScheme()
|
|
||||||
|
|
||||||
// Systeminformationen in der Konsole ausgeben
|
// Systeminformationen in der Konsole ausgeben
|
||||||
showInfo(fmt.Sprintf("UUID:%s", Settings.UUID))
|
showInfo(fmt.Sprintf("UUID:%s", Settings.UUID))
|
||||||
showInfo(fmt.Sprintf("Tuner (Plex / Emby):%d", Settings.Tuner))
|
showInfo(fmt.Sprintf("Tuner (Plex / Emby):%d", Settings.Tuner))
|
||||||
showInfo(fmt.Sprintf("EPG Source:%s", Settings.EpgSource))
|
showInfo(fmt.Sprintf("EPG Source:%s", Settings.EpgSource))
|
||||||
showInfo(fmt.Sprintf("Plex Channel Limit:%d", System.DVRLimit))
|
showInfo(fmt.Sprintf("Plex Channel Limit:%d", System.PlexChannelLimit))
|
||||||
|
showInfo(fmt.Sprintf("Unfiltered Chan. Limit:%d", System.UnfilteredChannelLimit))
|
||||||
|
|
||||||
// Providerdaten aktualisieren
|
// Providerdaten aktualisieren
|
||||||
if len(Settings.Files.M3U) > 0 && Settings.FilesUpdate == true || updateProviderFiles == true {
|
if len(Settings.Files.M3U) > 0 && Settings.FilesUpdate == true || updateProviderFiles == true {
|
||||||
|
|||||||
218
src/data.go
218
src/data.go
@@ -11,17 +11,19 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"../src/internal/authentication"
|
"xteve/src/internal/authentication"
|
||||||
|
"xteve/src/internal/imgcache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Einstellungen ändern (WebUI)
|
// Einstellungen ändern (WebUI)
|
||||||
func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err error) {
|
func updateServerSettings(request RequestStruct) (settings SettingsStruct, err error) {
|
||||||
|
|
||||||
var oldSettings = jsonToMap(mapToJSON(Settings))
|
var oldSettings = jsonToMap(mapToJSON(Settings))
|
||||||
var newSettings = jsonToMap(mapToJSON(request.Settings))
|
var newSettings = jsonToMap(mapToJSON(request.Settings))
|
||||||
var reloadData = false
|
var reloadData = false
|
||||||
var cacheImages = false
|
var cacheImages = false
|
||||||
var createXEPGFiles = false
|
var createXEPGFiles = false
|
||||||
|
var triggerPlexGuideReload = false
|
||||||
var debug string
|
var debug string
|
||||||
|
|
||||||
// -vvv [URL] --sout '#transcode{vcodec=mp4v, acodec=mpga} :standard{access=http, mux=ogg}'
|
// -vvv [URL] --sout '#transcode{vcodec=mp4v, acodec=mpga} :standard{access=http, mux=ogg}'
|
||||||
@@ -35,14 +37,29 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
case "tuner":
|
case "tuner":
|
||||||
showWarning(2105)
|
showWarning(2105)
|
||||||
|
|
||||||
|
case "use_plexAPI":
|
||||||
|
triggerPlexGuideReload = true
|
||||||
|
|
||||||
|
case "plex.url":
|
||||||
|
if v, ok := value.(string); ok {
|
||||||
|
value = strings.TrimRight(strings.TrimSpace(v), "/")
|
||||||
|
}
|
||||||
|
triggerPlexGuideReload = true
|
||||||
|
|
||||||
|
case "plex.token":
|
||||||
|
if v, ok := value.(string); ok {
|
||||||
|
value = strings.TrimSpace(v)
|
||||||
|
}
|
||||||
|
triggerPlexGuideReload = true
|
||||||
|
|
||||||
case "epgSource":
|
case "epgSource":
|
||||||
reloadData = true
|
reloadData = true
|
||||||
|
|
||||||
case "update":
|
case "update":
|
||||||
// Leerzeichen aus den Werten entfernen und Formatierung der Uhrzeit überprüfen (0000 - 2359)
|
// Leerzeichen aus den Werten entfernen und Formatierung der Uhrzeit überprüfen (0000 - 2359)
|
||||||
var newUpdateTimes []string
|
var newUpdateTimes = make([]string, 0)
|
||||||
|
|
||||||
for _, v := range value.([]interface{}) {
|
for _, v := range value.([]any) {
|
||||||
|
|
||||||
v = strings.Replace(v.(string), " ", "", -1)
|
v = strings.Replace(v.(string), " ", "", -1)
|
||||||
|
|
||||||
@@ -56,6 +73,10 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(newUpdateTimes) == 0 {
|
||||||
|
//newUpdateTimes = append(newUpdateTimes, "0000")
|
||||||
|
}
|
||||||
|
|
||||||
value = newUpdateTimes
|
value = newUpdateTimes
|
||||||
|
|
||||||
case "cache.images":
|
case "cache.images":
|
||||||
@@ -64,6 +85,16 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
case "xepg.replace.missing.images":
|
case "xepg.replace.missing.images":
|
||||||
createXEPGFiles = true
|
createXEPGFiles = true
|
||||||
|
|
||||||
|
case "xepg.missing.epg.mode":
|
||||||
|
if v, ok := value.(string); ok {
|
||||||
|
mode := strings.ToLower(strings.TrimSpace(v))
|
||||||
|
if mode != "relaxed" {
|
||||||
|
mode = "strict"
|
||||||
|
}
|
||||||
|
value = mode
|
||||||
|
}
|
||||||
|
reloadData = true
|
||||||
|
|
||||||
case "backup.path":
|
case "backup.path":
|
||||||
value = strings.TrimRight(value.(string), string(os.PathSeparator)) + string(os.PathSeparator)
|
value = strings.TrimRight(value.(string), string(os.PathSeparator)) + string(os.PathSeparator)
|
||||||
err = checkFolder(value.(string))
|
err = checkFolder(value.(string))
|
||||||
@@ -114,22 +145,26 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
|
|
||||||
oldSettings[key] = value
|
oldSettings[key] = value
|
||||||
|
|
||||||
switch fmt.Sprintf("%T", value) {
|
if key == "plex.token" {
|
||||||
|
debug = fmt.Sprintf("Save Setting:Key: %s | Value: ******** (%T)", key, value)
|
||||||
|
} else {
|
||||||
|
switch fmt.Sprintf("%T", value) {
|
||||||
|
|
||||||
case "bool":
|
case "bool":
|
||||||
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %t (%T)", key, value, value)
|
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %t (%T)", key, value, value)
|
||||||
|
|
||||||
case "string":
|
case "string":
|
||||||
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %s (%T)", key, value, value)
|
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %s (%T)", key, value, value)
|
||||||
|
|
||||||
case "[]interface {}":
|
case "[]interface {}":
|
||||||
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %v (%T)", key, value, value)
|
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %v (%T)", key, value, value)
|
||||||
|
|
||||||
case "float64":
|
case "float64":
|
||||||
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %d (%T)", key, int(value.(float64)), value)
|
debug = fmt.Sprintf("Save Setting:Key: %s | Value: %d (%T)", key, int(value.(float64)), value)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
debug = fmt.Sprintf("%T", value)
|
debug = fmt.Sprintf("%T", value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showDebug(debug, 1)
|
showDebug(debug, 1)
|
||||||
@@ -144,8 +179,6 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setURLScheme()
|
|
||||||
|
|
||||||
if Settings.AuthenticationWEB == false {
|
if Settings.AuthenticationWEB == false {
|
||||||
|
|
||||||
Settings.AuthenticationAPI = false
|
Settings.AuthenticationAPI = false
|
||||||
@@ -201,25 +234,38 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
|
|
||||||
if cacheImages == true {
|
if cacheImages == true {
|
||||||
|
|
||||||
if Settings.EpgSource == "XEPG" {
|
if Settings.EpgSource == "XEPG" && System.ImageCachingInProgress == 0 {
|
||||||
|
|
||||||
go func() {
|
Data.Cache.Images, err = imgcache.New(System.Folder.ImagesCache, fmt.Sprintf("%s://%s/images/", System.ServerProtocol.WEB, System.Domain), Settings.CacheImages)
|
||||||
|
if err != nil {
|
||||||
|
ShowError(err, 0)
|
||||||
|
}
|
||||||
|
|
||||||
if Settings.CacheImages == true {
|
switch Settings.CacheImages {
|
||||||
|
|
||||||
createXMLTVFile()
|
case false:
|
||||||
cachingImages()
|
createXMLTVFile()
|
||||||
createXMLTVFile()
|
createM3UFile()
|
||||||
createM3UFile()
|
|
||||||
|
|
||||||
} else {
|
case true:
|
||||||
|
go func() {
|
||||||
|
|
||||||
createXMLTVFile()
|
createXMLTVFile()
|
||||||
createM3UFile()
|
createM3UFile()
|
||||||
|
|
||||||
}
|
System.ImageCachingInProgress = 1
|
||||||
|
showInfo("Image Caching:Images are cached")
|
||||||
|
|
||||||
}()
|
Data.Cache.Images.Image.Caching()
|
||||||
|
showInfo("Image Caching:Done")
|
||||||
|
|
||||||
|
System.ImageCachingInProgress = 0
|
||||||
|
|
||||||
|
buildXEPG(false)
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,6 +280,10 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if triggerPlexGuideReload == true {
|
||||||
|
queuePlexGuideRefresh("settings change")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -242,8 +292,8 @@ func updateServerSettings(request RequestStruct) (settings SettingsStrcut, err e
|
|||||||
// Providerdaten speichern (WebUI)
|
// Providerdaten speichern (WebUI)
|
||||||
func saveFiles(request RequestStruct, fileType string) (err error) {
|
func saveFiles(request RequestStruct, fileType string) (err error) {
|
||||||
|
|
||||||
var filesMap = make(map[string]interface{})
|
var filesMap = make(map[string]any)
|
||||||
var newData = make(map[string]interface{})
|
var newData = make(map[string]any)
|
||||||
var indicator string
|
var indicator string
|
||||||
var reloadData = false
|
var reloadData = false
|
||||||
|
|
||||||
@@ -265,7 +315,7 @@ func saveFiles(request RequestStruct, fileType string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(filesMap) == 0 {
|
if len(filesMap) == 0 {
|
||||||
filesMap = make(map[string]interface{})
|
filesMap = make(map[string]any)
|
||||||
}
|
}
|
||||||
|
|
||||||
for dataID, data := range newData {
|
for dataID, data := range newData {
|
||||||
@@ -274,15 +324,15 @@ func saveFiles(request RequestStruct, fileType string) (err error) {
|
|||||||
|
|
||||||
// Neue Providerdatei
|
// Neue Providerdatei
|
||||||
dataID = indicator + randomString(19)
|
dataID = indicator + randomString(19)
|
||||||
data.(map[string]interface{})["new"] = true
|
data.(map[string]any)["new"] = true
|
||||||
filesMap[dataID] = data
|
filesMap[dataID] = data
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Bereits vorhandene Providerdatei
|
// Bereits vorhandene Providerdatei
|
||||||
for key, value := range data.(map[string]interface{}) {
|
for key, value := range data.(map[string]any) {
|
||||||
|
|
||||||
var oldData = filesMap[dataID].(map[string]interface{})
|
var oldData = filesMap[dataID].(map[string]any)
|
||||||
oldData[key] = value
|
oldData[key] = value
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -303,11 +353,11 @@ func saveFiles(request RequestStruct, fileType string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Neue Providerdatei
|
// Neue Providerdatei
|
||||||
if _, ok := data.(map[string]interface{})["new"]; ok {
|
if _, ok := data.(map[string]any)["new"]; ok {
|
||||||
|
|
||||||
reloadData = true
|
reloadData = true
|
||||||
err = getProviderData(fileType, dataID)
|
err = getProviderData(fileType, dataID)
|
||||||
delete(data.(map[string]interface{}), "new")
|
delete(data.(map[string]any), "new")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
delete(filesMap, dataID)
|
delete(filesMap, dataID)
|
||||||
@@ -316,7 +366,7 @@ func saveFiles(request RequestStruct, fileType string) (err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := data.(map[string]interface{})["delete"]; ok {
|
if _, ok := data.(map[string]any)["delete"]; ok {
|
||||||
|
|
||||||
deleteLocalProviderFiles(dataID, fileType)
|
deleteLocalProviderFiles(dataID, fileType)
|
||||||
reloadData = true
|
reloadData = true
|
||||||
@@ -349,7 +399,7 @@ func saveFiles(request RequestStruct, fileType string) (err error) {
|
|||||||
// Providerdaten manuell aktualisieren (WebUI)
|
// Providerdaten manuell aktualisieren (WebUI)
|
||||||
func updateFile(request RequestStruct, fileType string) (err error) {
|
func updateFile(request RequestStruct, fileType string) (err error) {
|
||||||
|
|
||||||
var updateData = make(map[string]interface{})
|
var updateData = make(map[string]any)
|
||||||
|
|
||||||
switch fileType {
|
switch fileType {
|
||||||
|
|
||||||
@@ -379,7 +429,7 @@ func updateFile(request RequestStruct, fileType string) (err error) {
|
|||||||
// Providerdaten löschen (WebUI)
|
// Providerdaten löschen (WebUI)
|
||||||
func deleteLocalProviderFiles(dataID, fileType string) {
|
func deleteLocalProviderFiles(dataID, fileType string) {
|
||||||
|
|
||||||
var removeData = make(map[string]interface{})
|
var removeData = make(map[string]any)
|
||||||
var fileExtension string
|
var fileExtension string
|
||||||
|
|
||||||
switch fileType {
|
switch fileType {
|
||||||
@@ -406,10 +456,10 @@ func deleteLocalProviderFiles(dataID, fileType string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filtereinstellungen speichern (WebUI)
|
// Filtereinstellungen speichern (WebUI)
|
||||||
func saveFilter(request RequestStruct) (settings SettingsStrcut, err error) {
|
func saveFilter(request RequestStruct) (settings SettingsStruct, err error) {
|
||||||
|
|
||||||
var filterMap = make(map[int64]interface{})
|
var filterMap = make(map[int64]any)
|
||||||
var newData = make(map[int64]interface{})
|
var newData = make(map[int64]any)
|
||||||
var defaultFilter FilterStruct
|
var defaultFilter FilterStruct
|
||||||
var newFilter = false
|
var newFilter = false
|
||||||
|
|
||||||
@@ -442,15 +492,15 @@ func saveFilter(request RequestStruct) (settings SettingsStrcut, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter aktualisieren / löschen
|
// Filter aktualisieren / löschen
|
||||||
for key, value := range data.(map[string]interface{}) {
|
for key, value := range data.(map[string]any) {
|
||||||
|
|
||||||
// Filter löschen
|
// Filter löschen
|
||||||
if _, ok := data.(map[string]interface{})["delete"]; ok {
|
if _, ok := data.(map[string]any)["delete"]; ok {
|
||||||
delete(filterMap, dataID)
|
delete(filterMap, dataID)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if filter, ok := data.(map[string]interface{})["filter"].(string); ok {
|
if filter, ok := data.(map[string]any)["filter"].(string); ok {
|
||||||
|
|
||||||
if len(filter) == 0 {
|
if len(filter) == 0 {
|
||||||
|
|
||||||
@@ -464,7 +514,7 @@ func saveFilter(request RequestStruct) (settings SettingsStrcut, err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if oldData, ok := filterMap[dataID].(map[string]interface{}); ok {
|
if oldData, ok := filterMap[dataID].(map[string]any); ok {
|
||||||
oldData[key] = value
|
oldData[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,6 +544,11 @@ func saveXEpgMapping(request RequestStruct) (err error) {
|
|||||||
|
|
||||||
var tmp = Data.XEPG
|
var tmp = Data.XEPG
|
||||||
|
|
||||||
|
Data.Cache.Images, err = imgcache.New(System.Folder.ImagesCache, fmt.Sprintf("%s://%s/images/", System.ServerProtocol.WEB, System.Domain), Settings.CacheImages)
|
||||||
|
if err != nil {
|
||||||
|
ShowError(err, 0)
|
||||||
|
}
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(mapToJSON(request.EpgMapping)), &tmp)
|
err = json.Unmarshal([]byte(mapToJSON(request.EpgMapping)), &tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -510,19 +565,9 @@ func saveXEpgMapping(request RequestStruct) (err error) {
|
|||||||
|
|
||||||
System.ScanInProgress = 1
|
System.ScanInProgress = 1
|
||||||
cleanupXEPG()
|
cleanupXEPG()
|
||||||
|
System.ScanInProgress = 0
|
||||||
buildXEPG(true)
|
buildXEPG(true)
|
||||||
|
|
||||||
go func() {
|
|
||||||
|
|
||||||
createXMLTVFile()
|
|
||||||
createM3UFile()
|
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
|
||||||
go cachingImages()
|
|
||||||
|
|
||||||
System.ScanInProgress = 0
|
|
||||||
|
|
||||||
}()
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Wenn während des erstellen der Datanbank das Mapping erneut gespeichert wird, wird die Datenbank erst später erneut aktualisiert.
|
// Wenn während des erstellen der Datanbank das Mapping erneut gespeichert wird, wird die Datenbank erst später erneut aktualisiert.
|
||||||
@@ -543,15 +588,10 @@ func saveXEpgMapping(request RequestStruct) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.ScanInProgress = 1
|
System.ScanInProgress = 1
|
||||||
|
|
||||||
cleanupXEPG()
|
cleanupXEPG()
|
||||||
buildXEPG(false)
|
|
||||||
createXMLTVFile()
|
|
||||||
createM3UFile()
|
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
|
||||||
go cachingImages()
|
|
||||||
|
|
||||||
System.ScanInProgress = 0
|
System.ScanInProgress = 0
|
||||||
|
buildXEPG(false)
|
||||||
|
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
||||||
|
|
||||||
System.BackgroundProcess = false
|
System.BackgroundProcess = false
|
||||||
|
|
||||||
@@ -567,7 +607,7 @@ func saveUserData(request RequestStruct) (err error) {
|
|||||||
|
|
||||||
var userData = request.UserData
|
var userData = request.UserData
|
||||||
|
|
||||||
var newCredentials = func(userID string, newUserData map[string]interface{}) (err error) {
|
var newCredentials = func(userID string, newUserData map[string]any) (err error) {
|
||||||
|
|
||||||
var newUsername, newPassword string
|
var newUsername, newPassword string
|
||||||
if username, ok := newUserData["username"].(string); ok {
|
if username, ok := newUserData["username"].(string); ok {
|
||||||
@@ -587,7 +627,7 @@ func saveUserData(request RequestStruct) (err error) {
|
|||||||
|
|
||||||
for userID, newUserData := range userData {
|
for userID, newUserData := range userData {
|
||||||
|
|
||||||
err = newCredentials(userID, newUserData.(map[string]interface{}))
|
err = newCredentials(userID, newUserData.(map[string]any))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -597,16 +637,16 @@ func saveUserData(request RequestStruct) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(newUserData.(map[string]interface{}), "password")
|
delete(newUserData.(map[string]any), "password")
|
||||||
delete(newUserData.(map[string]interface{}), "confirm")
|
delete(newUserData.(map[string]any), "confirm")
|
||||||
|
|
||||||
if _, ok := newUserData.(map[string]interface{})["delete"]; ok {
|
if _, ok := newUserData.(map[string]any)["delete"]; ok {
|
||||||
|
|
||||||
authentication.RemoveUser(userID)
|
authentication.RemoveUser(userID)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
err = authentication.WriteUserData(userID, newUserData.(map[string]interface{}))
|
err = authentication.WriteUserData(userID, newUserData.(map[string]any))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -656,11 +696,11 @@ func saveWizard(request RequestStruct) (nextStep int, err error) {
|
|||||||
|
|
||||||
case "m3u", "xmltv":
|
case "m3u", "xmltv":
|
||||||
|
|
||||||
var filesMap = make(map[string]interface{})
|
var filesMap = make(map[string]any)
|
||||||
var data = make(map[string]interface{})
|
var data = make(map[string]any)
|
||||||
var indicator, dataID string
|
var indicator, dataID string
|
||||||
|
|
||||||
filesMap = make(map[string]interface{})
|
filesMap = make(map[string]any)
|
||||||
|
|
||||||
data["type"] = key
|
data["type"] = key
|
||||||
data["new"] = true
|
data["new"] = true
|
||||||
@@ -731,6 +771,10 @@ func saveWizard(request RequestStruct) (nextStep int, err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nextStep == 10 {
|
||||||
|
Settings.WizardCompleted = true
|
||||||
|
}
|
||||||
|
|
||||||
err = saveSettings(Settings)
|
err = saveSettings(Settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -791,9 +835,9 @@ func buildDatabaseDVR() (err error) {
|
|||||||
|
|
||||||
System.ScanInProgress = 1
|
System.ScanInProgress = 1
|
||||||
|
|
||||||
Data.Streams.All = make([]interface{}, 0)
|
Data.Streams.All = make([]any, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Streams.Active = make([]interface{}, 0)
|
Data.Streams.Active = make([]any, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Streams.Inactive = make([]interface{}, 0)
|
Data.Streams.Inactive = make([]any, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Playlist.M3U.Groups.Text = []string{}
|
Data.Playlist.M3U.Groups.Text = []string{}
|
||||||
Data.Playlist.M3U.Groups.Value = []string{}
|
Data.Playlist.M3U.Groups.Value = []string{}
|
||||||
Data.StreamPreviewUI.Active = []string{}
|
Data.StreamPreviewUI.Active = []string{}
|
||||||
@@ -814,7 +858,7 @@ func buildDatabaseDVR() (err error) {
|
|||||||
|
|
||||||
for n, i := range playlistFile {
|
for n, i := range playlistFile {
|
||||||
|
|
||||||
var channels []interface{}
|
var channels []any
|
||||||
var groupTitle, tvgID, uuid int = 0, 0, 0
|
var groupTitle, tvgID, uuid int = 0, 0, 0
|
||||||
var keys = []string{"group-title", "tvg-id", "uuid"}
|
var keys = []string{"group-title", "tvg-id", "uuid"}
|
||||||
var compatibility = make(map[string]int)
|
var compatibility = make(map[string]int)
|
||||||
@@ -949,20 +993,20 @@ func buildDatabaseDVR() (err error) {
|
|||||||
sort.Strings(Data.Playlist.M3U.Groups.Text)
|
sort.Strings(Data.Playlist.M3U.Groups.Text)
|
||||||
sort.Strings(Data.Playlist.M3U.Groups.Value)
|
sort.Strings(Data.Playlist.M3U.Groups.Value)
|
||||||
|
|
||||||
if len(Data.Streams.Active) == 0 && len(Data.Streams.All) <= System.DVRLimit && len(Settings.Filter) == 0 {
|
if len(Data.Streams.Active) == 0 && len(Data.Streams.All) <= System.UnfilteredChannelLimit && len(Settings.Filter) == 0 {
|
||||||
Data.Streams.Active = Data.Streams.All
|
Data.Streams.Active = Data.Streams.All
|
||||||
Data.Streams.Inactive = make([]interface{}, 0)
|
Data.Streams.Inactive = make([]any, 0)
|
||||||
|
|
||||||
Data.StreamPreviewUI.Active = Data.StreamPreviewUI.Inactive
|
Data.StreamPreviewUI.Active = Data.StreamPreviewUI.Inactive
|
||||||
Data.StreamPreviewUI.Inactive = []string{}
|
Data.StreamPreviewUI.Inactive = []string{}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(Data.Streams.Active) > System.DVRLimit {
|
if len(Data.Streams.Active) > System.PlexChannelLimit {
|
||||||
showWarning(2000)
|
showWarning(2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(Settings.Filter) == 0 && len(Data.Streams.All) > System.DVRLimit {
|
if len(Settings.Filter) == 0 && len(Data.Streams.All) > System.UnfilteredChannelLimit {
|
||||||
showWarning(2001)
|
showWarning(2001)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,6 +1018,10 @@ func buildDatabaseDVR() (err error) {
|
|||||||
sort.Strings(Data.StreamPreviewUI.Active)
|
sort.Strings(Data.StreamPreviewUI.Active)
|
||||||
sort.Strings(Data.StreamPreviewUI.Inactive)
|
sort.Strings(Data.StreamPreviewUI.Inactive)
|
||||||
|
|
||||||
|
if Settings.EpgSource != "XEPG" {
|
||||||
|
queuePlexGuideRefresh("lineup update")
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -981,7 +1029,7 @@ func buildDatabaseDVR() (err error) {
|
|||||||
func getLocalProviderFiles(fileType string) (localFiles []string) {
|
func getLocalProviderFiles(fileType string) (localFiles []string) {
|
||||||
|
|
||||||
var fileExtension string
|
var fileExtension string
|
||||||
var dataMap = make(map[string]interface{})
|
var dataMap = make(map[string]any)
|
||||||
|
|
||||||
switch fileType {
|
switch fileType {
|
||||||
|
|
||||||
@@ -1009,7 +1057,7 @@ func getLocalProviderFiles(fileType string) (localFiles []string) {
|
|||||||
// Providerparameter anhand von dem Key ausgeben
|
// Providerparameter anhand von dem Key ausgeben
|
||||||
func getProviderParameter(id, fileType, key string) (s string) {
|
func getProviderParameter(id, fileType, key string) (s string) {
|
||||||
|
|
||||||
var dataMap = make(map[string]interface{})
|
var dataMap = make(map[string]any)
|
||||||
|
|
||||||
switch fileType {
|
switch fileType {
|
||||||
case "m3u":
|
case "m3u":
|
||||||
@@ -1022,7 +1070,7 @@ func getProviderParameter(id, fileType, key string) (s string) {
|
|||||||
dataMap = Settings.Files.XMLTV
|
dataMap = Settings.Files.XMLTV
|
||||||
}
|
}
|
||||||
|
|
||||||
if data, ok := dataMap[id].(map[string]interface{}); ok {
|
if data, ok := dataMap[id].(map[string]any); ok {
|
||||||
|
|
||||||
if v, ok := data[key].(string); ok {
|
if v, ok := data[key].(string); ok {
|
||||||
s = v
|
s = v
|
||||||
@@ -1040,7 +1088,7 @@ func getProviderParameter(id, fileType, key string) (s string) {
|
|||||||
// Provider Statistiken Kompatibilität aktualisieren
|
// Provider Statistiken Kompatibilität aktualisieren
|
||||||
func setProviderCompatibility(id, fileType string, compatibility map[string]int) {
|
func setProviderCompatibility(id, fileType string, compatibility map[string]int) {
|
||||||
|
|
||||||
var dataMap = make(map[string]interface{})
|
var dataMap = make(map[string]any)
|
||||||
|
|
||||||
switch fileType {
|
switch fileType {
|
||||||
case "m3u":
|
case "m3u":
|
||||||
@@ -1053,7 +1101,7 @@ func setProviderCompatibility(id, fileType string, compatibility map[string]int)
|
|||||||
dataMap = Settings.Files.XMLTV
|
dataMap = Settings.Files.XMLTV
|
||||||
}
|
}
|
||||||
|
|
||||||
if data, ok := dataMap[id].(map[string]interface{}); ok {
|
if data, ok := dataMap[id].(map[string]any); ok {
|
||||||
|
|
||||||
data["compatibility"] = compatibility
|
data["compatibility"] = compatibility
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeInteraceFromHDHR(content []byte, playlistName, id string) (channels []interface{}, err error) {
|
func makeInteraceFromHDHR(content []byte, playlistName, id string) (channels []any, err error) {
|
||||||
|
|
||||||
var hdhrData []interface{}
|
var hdhrData []any
|
||||||
|
|
||||||
err = json.Unmarshal(content, &hdhrData)
|
err = json.Unmarshal(content, &hdhrData)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -17,7 +17,7 @@ func makeInteraceFromHDHR(content []byte, playlistName, id string) (channels []i
|
|||||||
for _, d := range hdhrData {
|
for _, d := range hdhrData {
|
||||||
|
|
||||||
var channel = make(map[string]string)
|
var channel = make(map[string]string)
|
||||||
var data = d.(map[string]interface{})
|
var data = d.(map[string]any)
|
||||||
|
|
||||||
channel["group-title"] = playlistName
|
channel["group-title"] = playlistName
|
||||||
channel["name"] = data["GuideName"].(string)
|
channel["name"] = data["GuideName"].(string)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var htmlFolder string
|
var htmlFolder string
|
||||||
@@ -16,7 +17,7 @@ var goFile string
|
|||||||
var mapName string
|
var mapName string
|
||||||
var packageName string
|
var packageName string
|
||||||
|
|
||||||
var blankMap = make(map[string]interface{})
|
var blankMap = make(map[string]any)
|
||||||
|
|
||||||
// HTMLInit : Dateipfade festlegen
|
// HTMLInit : Dateipfade festlegen
|
||||||
// mapName = Name der zu erstellenden map
|
// mapName = Name der zu erstellenden map
|
||||||
@@ -68,14 +69,14 @@ func createMapFromFiles(folder string) string {
|
|||||||
checkErr(err)
|
checkErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var content string
|
var content strings.Builder
|
||||||
|
|
||||||
for key := range blankMap {
|
for key := range blankMap {
|
||||||
var newKey = key
|
var newKey = key
|
||||||
content += ` ` + mapName + `["` + newKey + `"` + `] = "` + blankMap[key].(string) + `"` + "\n"
|
content.WriteString(` ` + mapName + `["` + newKey + `"` + `] = "` + blankMap[key].(string) + `"` + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
return content
|
return content.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFilesToMap(path string, info os.FileInfo, err error) error {
|
func readFilesToMap(path string, info os.FileInfo, err error) error {
|
||||||
|
|||||||
140
src/images.go
140
src/images.go
@@ -3,155 +3,15 @@ package src
|
|||||||
import (
|
import (
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCacheImageURL(imageURL string) (cacheImageURL string) {
|
|
||||||
|
|
||||||
if Settings.CacheImages == false {
|
|
||||||
return imageURL
|
|
||||||
}
|
|
||||||
|
|
||||||
imageURL = strings.Trim(imageURL, "\r\n")
|
|
||||||
|
|
||||||
p, err := url.Parse(imageURL)
|
|
||||||
if err != nil {
|
|
||||||
// URL konnte nicht geparst werden, die ursprüngliche image url wird zurückgegeben
|
|
||||||
showInfo(fmt.Sprintf("Image Caching:Image URL: %s", imageURL))
|
|
||||||
showWarning(4101)
|
|
||||||
return imageURL
|
|
||||||
}
|
|
||||||
var urlMD5 = getMD5(imageURL)
|
|
||||||
var fileExtension = filepath.Ext(p.Path)
|
|
||||||
|
|
||||||
if len(fileExtension) == 0 {
|
|
||||||
// Keine Dateierweiterung vorhanden, die ursprüngliche image url wird zurückgegeben
|
|
||||||
return imageURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesFiles) == -1 {
|
|
||||||
Data.Cache.ImagesFiles = append(Data.Cache.ImagesFiles, urlMD5+fileExtension)
|
|
||||||
}
|
|
||||||
|
|
||||||
if System.ImageCachingInProgress == 1 {
|
|
||||||
return imageURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if indexOfString(urlMD5+fileExtension, Data.Cache.ImagesCache) != -1 {
|
|
||||||
|
|
||||||
cacheImageURL = fmt.Sprintf("%s://%s/images/%s%s", System.ServerProtocol.XML, System.Domain, urlMD5, fileExtension)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if strings.Contains(imageURL, System.Domain+"/images/") == false {
|
|
||||||
|
|
||||||
if indexOfString(imageURL, Data.Cache.ImagesURLS) == -1 {
|
|
||||||
Data.Cache.ImagesURLS = append(Data.Cache.ImagesURLS, imageURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
cacheImageURL = imageURL
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func cachingImages() {
|
|
||||||
|
|
||||||
if Settings.CacheImages == false || System.ImageCachingInProgress == 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
System.ImageCachingInProgress = 1
|
|
||||||
|
|
||||||
showInfo("Image Caching:Images are cached")
|
|
||||||
|
|
||||||
for _, imageURL := range Data.Cache.ImagesURLS {
|
|
||||||
|
|
||||||
if len(imageURL) > 0 {
|
|
||||||
cacheImage(imageURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
showInfo("Image Caching:Done")
|
|
||||||
|
|
||||||
// Bilder die nicht mehr verwendet werden, werden gelöscht
|
|
||||||
files, err := ioutil.ReadDir(System.Folder.ImagesCache)
|
|
||||||
if err != nil {
|
|
||||||
ShowError(err, 0)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, file := range files {
|
|
||||||
|
|
||||||
if indexOfString(file.Name(), Data.Cache.ImagesFiles) == -1 {
|
|
||||||
|
|
||||||
var debug = fmt.Sprintf("Image Caching:Remove file: %s %s %d", System.Folder.ImagesCache+file.Name(), file.Name(), len(file.Name()))
|
|
||||||
showDebug(debug, 1)
|
|
||||||
err := os.RemoveAll(System.Folder.ImagesCache + file.Name())
|
|
||||||
if err != nil {
|
|
||||||
ShowError(err, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
System.ImageCachingInProgress = 0
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func cacheImage(imageURL string) {
|
|
||||||
|
|
||||||
var debug string
|
|
||||||
var urlMD5 = getMD5(imageURL)
|
|
||||||
var fileExtension = filepath.Ext(imageURL)
|
|
||||||
|
|
||||||
debug = fmt.Sprintf("Image Caching:File: %s Download: %s", urlMD5+fileExtension, imageURL)
|
|
||||||
showDebug(debug, 1)
|
|
||||||
|
|
||||||
resp, err := http.Get(imageURL)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var filePath = System.Folder.ImagesCache + urlMD5 + fileExtension
|
|
||||||
|
|
||||||
// Datei speichern
|
|
||||||
file, err := os.Create(filePath)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
_, err = io.Copy(file, resp.Body)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func uploadLogo(input, filename string) (logoURL string, err error) {
|
func uploadLogo(input, filename string) (logoURL string, err error) {
|
||||||
|
|
||||||
b64data := input[strings.IndexByte(input, ',')+1:]
|
b64data := input[strings.IndexByte(input, ',')+1:]
|
||||||
|
|
||||||
// BAse64 in bytes umwandeln un speichern
|
// BAse64 in bytes umwandeln un speichern
|
||||||
sDec, err := b64.StdEncoding.DecodeString(b64data)
|
sDec, err := b64.StdEncoding.DecodeString(b64data)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
132
src/info.go
132
src/info.go
@@ -1,99 +1,101 @@
|
|||||||
package src
|
package src
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShowSystemInfo : Systeminformationen anzeigen
|
// ShowSystemInfo : Systeminformationen anzeigen
|
||||||
func ShowSystemInfo() {
|
func ShowSystemInfo() {
|
||||||
|
|
||||||
fmt.Print("Creating the information takes a moment...")
|
fmt.Print("Creating the information takes a moment...")
|
||||||
err := buildDatabaseDVR()
|
err := buildDatabaseDVR()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ShowError(err, 0)
|
ShowError(err, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buildXEPG(false)
|
buildXEPG(false)
|
||||||
|
|
||||||
fmt.Println("OK")
|
fmt.Println("OK")
|
||||||
println()
|
println()
|
||||||
|
|
||||||
fmt.Println(fmt.Sprintf("Version: %s %s.%s", System.Name, System.Version, System.Build))
|
fmt.Println(fmt.Sprintf("Version: %s %s.%s", System.Name, System.Version, System.Build))
|
||||||
fmt.Println(fmt.Sprintf("Branch: %s", System.Branch))
|
fmt.Println(fmt.Sprintf("Branch: %s", System.Branch))
|
||||||
fmt.Println(fmt.Sprintf("GitHub: %s/%s | Git update = %t", System.GitHub.User, System.GitHub.Repo, System.GitHub.Update))
|
fmt.Println(fmt.Sprintf("GitHub: %s/%s | Git update = %t", System.GitHub.User, System.GitHub.Repo, System.GitHub.Update))
|
||||||
fmt.Println(fmt.Sprintf("Folder (config): %s", System.Folder.Config))
|
fmt.Println(fmt.Sprintf("Folder (config): %s", System.Folder.Config))
|
||||||
|
|
||||||
fmt.Println(fmt.Sprintf("Streams: %d / %d", len(Data.Streams.Active), len(Data.Streams.All)))
|
fmt.Println(fmt.Sprintf("Streams: %d / %d", len(Data.Streams.Active), len(Data.Streams.All)))
|
||||||
fmt.Println(fmt.Sprintf("Filter: %d", len(Data.Filter)))
|
fmt.Println(fmt.Sprintf("Filter: %d", len(Data.Filter)))
|
||||||
fmt.Println(fmt.Sprintf("XEPG Chanels: %d", int(Data.XEPG.XEPGCount)))
|
fmt.Println(fmt.Sprintf("XEPG Chanels: %d", int(Data.XEPG.XEPGCount)))
|
||||||
|
|
||||||
println()
|
println()
|
||||||
fmt.Println(fmt.Sprintf("IPv4 Addresses:"))
|
fmt.Println(fmt.Sprintf("IPv4 Addresses:"))
|
||||||
|
|
||||||
for i, ipv4 := range System.IPAddressesV4 {
|
for i, ipv4 := range System.IPAddressesV4 {
|
||||||
|
|
||||||
switch count := i; {
|
switch count := i; {
|
||||||
|
|
||||||
case count < 10:
|
case count < 10:
|
||||||
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
||||||
break
|
break
|
||||||
case count < 100:
|
case count < 100:
|
||||||
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println()
|
println()
|
||||||
fmt.Println(fmt.Sprintf("IPv6 Addresses:"))
|
fmt.Println(fmt.Sprintf("IPv6 Addresses:"))
|
||||||
|
|
||||||
for i, ipv4 := range System.IPAddressesV6 {
|
for i, ipv4 := range System.IPAddressesV6 {
|
||||||
|
|
||||||
switch count := i; {
|
switch count := i; {
|
||||||
|
|
||||||
case count < 10:
|
case count < 10:
|
||||||
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
||||||
break
|
break
|
||||||
case count < 100:
|
case count < 100:
|
||||||
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
fmt.Println(fmt.Sprintf(" %d. %s", count, ipv4))
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println("---")
|
println("---")
|
||||||
|
|
||||||
fmt.Println("Settings [General]")
|
fmt.Println("Settings [General]")
|
||||||
fmt.Println(fmt.Sprintf("xTeVe Update: %t", Settings.XteveAutoUpdate))
|
fmt.Println(fmt.Sprintf("xTeVe Update: %t", Settings.XteveAutoUpdate))
|
||||||
fmt.Println(fmt.Sprintf("UUID: %s", Settings.UUID))
|
fmt.Println(fmt.Sprintf("UUID: %s", Settings.UUID))
|
||||||
fmt.Println(fmt.Sprintf("Tuner (Plex / Emby): %d", Settings.Tuner))
|
fmt.Println(fmt.Sprintf("Tuner (Plex / Emby): %d", Settings.Tuner))
|
||||||
fmt.Println(fmt.Sprintf("EPG Source: %s", Settings.EpgSource))
|
fmt.Println(fmt.Sprintf("EPG Source: %s", Settings.EpgSource))
|
||||||
|
|
||||||
println("---")
|
println("---")
|
||||||
|
|
||||||
fmt.Println("Settings [Files]")
|
fmt.Println("Settings [Files]")
|
||||||
fmt.Println(fmt.Sprintf("Schedule: %s", strings.Join(Settings.Update, ",")))
|
fmt.Println(fmt.Sprintf("Schedule: %s", strings.Join(Settings.Update, ",")))
|
||||||
fmt.Println(fmt.Sprintf("Files Update: %t", Settings.FilesUpdate))
|
fmt.Println(fmt.Sprintf("Files Update: %t", Settings.FilesUpdate))
|
||||||
fmt.Println(fmt.Sprintf("Folder (tmp): %s", Settings.TempPath))
|
fmt.Println(fmt.Sprintf("Folder (tmp): %s", Settings.TempPath))
|
||||||
fmt.Println(fmt.Sprintf("Image Chaching: %t", Settings.CacheImages))
|
fmt.Println(fmt.Sprintf("Image Chaching: %t", Settings.CacheImages))
|
||||||
fmt.Println(fmt.Sprintf("Replace EPG Image: %t", Settings.XepgReplaceMissingImages))
|
fmt.Println(fmt.Sprintf("Missing EPG Mode: %s", Settings.XepgMissingEPGMode))
|
||||||
|
fmt.Println(fmt.Sprintf("Replace EPG Image: %t", Settings.XepgReplaceMissingImages))
|
||||||
|
|
||||||
println("---")
|
println("---")
|
||||||
|
|
||||||
fmt.Println("Settings [Streaming]")
|
fmt.Println("Settings [Streaming]")
|
||||||
fmt.Println(fmt.Sprintf("Buffer: %s", Settings.Buffer))
|
fmt.Println(fmt.Sprintf("Buffer: %s", Settings.Buffer))
|
||||||
fmt.Println(fmt.Sprintf("Buffer Size: %d KB", Settings.BufferSize))
|
fmt.Println(fmt.Sprintf("UDPxy: %s", Settings.UDPxy))
|
||||||
fmt.Println(fmt.Sprintf("Timeout: %d ms", int(Settings.BufferTimeout)))
|
fmt.Println(fmt.Sprintf("Buffer Size: %d KB", Settings.BufferSize))
|
||||||
fmt.Println(fmt.Sprintf("User Agent: %s", Settings.UserAgent))
|
fmt.Println(fmt.Sprintf("Timeout: %d ms", int(Settings.BufferTimeout)))
|
||||||
|
fmt.Println(fmt.Sprintf("User Agent: %s", Settings.UserAgent))
|
||||||
|
|
||||||
println("---")
|
println("---")
|
||||||
|
|
||||||
fmt.Println("Settings [Backup]")
|
fmt.Println("Settings [Backup]")
|
||||||
fmt.Println(fmt.Sprintf("Folder (backup): %s", Settings.BackupPath))
|
fmt.Println(fmt.Sprintf("Folder (backup): %s", Settings.BackupPath))
|
||||||
fmt.Println(fmt.Sprintf("Backup Keep: %d", Settings.BackupKeep))
|
fmt.Println(fmt.Sprintf("Backup Keep: %d", Settings.BackupKeep))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
package authentication
|
package authentication
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
//"fmt"
|
//"fmt"
|
||||||
//"log"
|
//"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const tokenLength = 40
|
const tokenLength = 40
|
||||||
@@ -27,19 +28,20 @@ var database string
|
|||||||
|
|
||||||
var databaseFile = "authentication.json"
|
var databaseFile = "authentication.json"
|
||||||
|
|
||||||
var data = make(map[string]interface{})
|
var data = make(map[string]any)
|
||||||
var tokens = make(map[string]interface{})
|
var tokens = make(map[string]any)
|
||||||
|
var tokensMu sync.RWMutex
|
||||||
|
|
||||||
var initAuthentication = false
|
var initAuthentication = false
|
||||||
|
|
||||||
// Cookie : cookie
|
// Cookie : cookie
|
||||||
type Cookie struct {
|
type Cookie struct {
|
||||||
Name string
|
Name string
|
||||||
Value string
|
Value string
|
||||||
Path string
|
Path string
|
||||||
Domain string
|
Domain string
|
||||||
Expires time.Time
|
Expires time.Time
|
||||||
RawExpires string
|
RawExpires string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Framework examples
|
// Framework examples
|
||||||
@@ -128,465 +130,475 @@ func main() {
|
|||||||
|
|
||||||
// Init : databasePath = Path to authentication.json
|
// Init : databasePath = Path to authentication.json
|
||||||
func Init(databasePath string, validity int) (err error) {
|
func Init(databasePath string, validity int) (err error) {
|
||||||
database = filepath.Dir(databasePath) + string(os.PathSeparator) + databaseFile
|
database = filepath.Dir(databasePath) + string(os.PathSeparator) + databaseFile
|
||||||
|
|
||||||
// Check if the database already exists
|
// Check if the database already exists
|
||||||
if _, err = os.Stat(database); os.IsNotExist(err) {
|
if _, err = os.Stat(database); os.IsNotExist(err) {
|
||||||
// Create an empty database
|
// Create an empty database
|
||||||
var defaults = make(map[string]interface{})
|
var defaults = make(map[string]any)
|
||||||
defaults["dbVersion"] = "1.0"
|
defaults["dbVersion"] = "1.0"
|
||||||
defaults["hash"] = "sha256"
|
defaults["hash"] = "sha256"
|
||||||
defaults["users"] = make(map[string]interface{})
|
defaults["users"] = make(map[string]any)
|
||||||
|
|
||||||
if saveDatabase(defaults) != nil {
|
if saveDatabase(defaults) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading the database
|
// Loading the database
|
||||||
err = loadDatabase()
|
err = loadDatabase()
|
||||||
|
|
||||||
// Set Token Validity
|
// Set Token Validity
|
||||||
tokenValidity = validity
|
tokenValidity = validity
|
||||||
initAuthentication = true
|
initAuthentication = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateDefaultUser = created efault user
|
// CreateDefaultUser = created efault user
|
||||||
func CreateDefaultUser(username, password string) (err error) {
|
func CreateDefaultUser(username, password string) (err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = data["users"].(map[string]interface{})
|
var users = data["users"].(map[string]any)
|
||||||
// Check if the default user exists
|
// Check if the default user exists
|
||||||
if len(users) > 0 {
|
if len(users) > 0 {
|
||||||
err = createError(001)
|
err = createError(001)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaults = defaultsForNewUser(username, password)
|
var defaults = defaultsForNewUser(username, password)
|
||||||
users[defaults["_id"].(string)] = defaults
|
users[defaults["_id"].(string)] = defaults
|
||||||
saveDatabase(data)
|
saveDatabase(data)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateNewUser : create new user
|
// CreateNewUser : create new user
|
||||||
func CreateNewUser(username, password string) (userID string, err error) {
|
func CreateNewUser(username, password string) (userID string, err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var checkIfTheUserAlreadyExists = func(username string, userData map[string]interface{}) (err error) {
|
var checkIfTheUserAlreadyExists = func(username string, userData map[string]any) (err error) {
|
||||||
var salt = userData["_salt"].(string)
|
var salt = userData["_salt"].(string)
|
||||||
var loginUsername = userData["_username"].(string)
|
var loginUsername = userData["_username"].(string)
|
||||||
|
|
||||||
if SHA256(username, salt) == loginUsername {
|
if SHA256(username, salt) == loginUsername {
|
||||||
err = createError(020)
|
err = createError(020)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = data["users"].(map[string]interface{})
|
var users = data["users"].(map[string]any)
|
||||||
for _, userData := range users {
|
for _, userData := range users {
|
||||||
err = checkIfTheUserAlreadyExists(username, userData.(map[string]interface{}))
|
err = checkIfTheUserAlreadyExists(username, userData.(map[string]any))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaults = defaultsForNewUser(username, password)
|
var defaults = defaultsForNewUser(username, password)
|
||||||
userID = defaults["_id"].(string)
|
userID = defaults["_id"].(string)
|
||||||
users[userID] = defaults
|
users[userID] = defaults
|
||||||
|
|
||||||
saveDatabase(data)
|
saveDatabase(data)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserAuthentication : user authentication
|
// UserAuthentication : user authentication
|
||||||
func UserAuthentication(username, password string) (token string, err error) {
|
func UserAuthentication(username, password string) (token string, err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var login = func(username, password string, loginData map[string]interface{}) (err error) {
|
var login = func(username, password string, loginData map[string]any) (err error) {
|
||||||
err = createError(010)
|
err = createError(010)
|
||||||
|
|
||||||
var salt = loginData["_salt"].(string)
|
var salt = loginData["_salt"].(string)
|
||||||
var loginUsername = loginData["_username"].(string)
|
var loginUsername = loginData["_username"].(string)
|
||||||
var loginPassword = loginData["_password"].(string)
|
var loginPassword = loginData["_password"].(string)
|
||||||
|
|
||||||
if SHA256(username, salt) == loginUsername {
|
if SHA256(username, salt) == loginUsername {
|
||||||
if SHA256(password, salt) == loginPassword {
|
if SHA256(password, salt) == loginPassword {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = data["users"].(map[string]interface{})
|
var users = data["users"].(map[string]any)
|
||||||
for id, loginData := range users {
|
for id, loginData := range users {
|
||||||
err = login(username, password, loginData.(map[string]interface{}))
|
err = login(username, password, loginData.(map[string]any))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
token = setToken(id, "-")
|
token = setToken(id, "-")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckTheValidityOfTheToken : check token
|
// CheckTheValidityOfTheToken : check token
|
||||||
func CheckTheValidityOfTheToken(token string) (newToken string, err error) {
|
func CheckTheValidityOfTheToken(token string) (newToken string, err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createError(011)
|
err = createError(011)
|
||||||
|
|
||||||
if v, ok := tokens[token]; ok {
|
tokensMu.Lock()
|
||||||
var expires = v.(map[string]interface{})["expires"].(time.Time)
|
defer tokensMu.Unlock()
|
||||||
var userID = v.(map[string]interface{})["id"].(string)
|
|
||||||
|
|
||||||
if expires.Sub(time.Now().Local()) < 0 {
|
if v, ok := tokens[token]; ok {
|
||||||
return
|
expires := v.(map[string]any)["expires"].(time.Time)
|
||||||
}
|
|
||||||
|
|
||||||
newToken = setToken(userID, token)
|
if expires.Sub(time.Now().Local()) < 0 {
|
||||||
|
delete(tokens, token)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = nil
|
// Keep a stable token per session and only refresh expiration.
|
||||||
|
v.(map[string]any)["expires"] = time.Now().Local().Add(time.Minute * time.Duration(tokenValidity))
|
||||||
|
newToken = token
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserID : get user ID
|
// GetUserID : get user ID
|
||||||
func GetUserID(token string) (userID string, err error) {
|
func GetUserID(token string) (userID string, err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createError(002)
|
err = createError(002)
|
||||||
|
|
||||||
if v, ok := tokens[token]; ok {
|
tokensMu.Lock()
|
||||||
var expires = v.(map[string]interface{})["expires"].(time.Time)
|
defer tokensMu.Unlock()
|
||||||
userID = v.(map[string]interface{})["id"].(string)
|
|
||||||
|
|
||||||
if expires.Sub(time.Now().Local()) < 0 {
|
if v, ok := tokens[token]; ok {
|
||||||
return
|
expires := v.(map[string]any)["expires"].(time.Time)
|
||||||
}
|
userID = v.(map[string]any)["id"].(string)
|
||||||
|
|
||||||
err = nil
|
if expires.Sub(time.Now().Local()) < 0 {
|
||||||
}
|
delete(tokens, token)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteUserData : save user date
|
// WriteUserData : save user date
|
||||||
func WriteUserData(userID string, userData map[string]interface{}) (err error) {
|
func WriteUserData(userID string, userData map[string]any) (err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createError(030)
|
err = createError(030)
|
||||||
|
|
||||||
if v, ok := data["users"].(map[string]interface{})[userID].(map[string]interface{}); ok {
|
if v, ok := data["users"].(map[string]any)[userID].(map[string]any); ok {
|
||||||
|
|
||||||
v["data"] = userData
|
v["data"] = userData
|
||||||
err = saveDatabase(data)
|
err = saveDatabase(data)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadUserData : load user date
|
// ReadUserData : load user date
|
||||||
func ReadUserData(userID string) (userData map[string]interface{}, err error) {
|
func ReadUserData(userID string) (userData map[string]any, err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createError(031)
|
err = createError(031)
|
||||||
|
|
||||||
if v, ok := data["users"].(map[string]interface{})[userID].(map[string]interface{}); ok {
|
if v, ok := data["users"].(map[string]any)[userID].(map[string]any); ok {
|
||||||
userData = v["data"].(map[string]interface{})
|
userData = v["data"].(map[string]any)
|
||||||
err = nil
|
err = nil
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveUser : remove user
|
// RemoveUser : remove user
|
||||||
func RemoveUser(userID string) (err error) {
|
func RemoveUser(userID string) (err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createError(032)
|
err = createError(032)
|
||||||
|
|
||||||
if _, ok := data["users"].(map[string]interface{})[userID]; ok {
|
if _, ok := data["users"].(map[string]any)[userID]; ok {
|
||||||
|
|
||||||
delete(data["users"].(map[string]interface{}), userID)
|
delete(data["users"].(map[string]any), userID)
|
||||||
err = saveDatabase(data)
|
err = saveDatabase(data)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultUserData : set default user data
|
// SetDefaultUserData : set default user data
|
||||||
func SetDefaultUserData(defaults map[string]interface{}) (err error) {
|
func SetDefaultUserData(defaults map[string]any) (err error) {
|
||||||
|
|
||||||
allUserData, err := GetAllUserData()
|
allUserData, err := GetAllUserData()
|
||||||
|
|
||||||
for _, d := range allUserData {
|
for _, d := range allUserData {
|
||||||
var data = d.(map[string]interface{})["data"].(map[string]interface{})
|
var data = d.(map[string]any)["data"].(map[string]any)
|
||||||
var userID = d.(map[string]interface{})["_id"].(string)
|
var userID = d.(map[string]any)["_id"].(string)
|
||||||
|
|
||||||
for k, v := range defaults {
|
for k, v := range defaults {
|
||||||
if _, ok := data[k]; ok {
|
if _, ok := data[k]; ok {
|
||||||
// Key exist
|
// Key exist
|
||||||
} else {
|
} else {
|
||||||
data[k] = v
|
data[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = WriteUserData(userID, data)
|
err = WriteUserData(userID, data)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeCredentials : change credentials
|
// ChangeCredentials : change credentials
|
||||||
func ChangeCredentials(userID, username, password string) (err error) {
|
func ChangeCredentials(userID, username, password string) (err error) {
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createError(032)
|
err = createError(032)
|
||||||
|
|
||||||
if userData, ok := data["users"].(map[string]interface{})[userID]; ok {
|
if userData, ok := data["users"].(map[string]any)[userID]; ok {
|
||||||
//var userData = tmp.(map[string]interface{})
|
//var userData = tmp.(map[string]interface{})
|
||||||
var salt = userData.(map[string]interface{})["_salt"].(string)
|
var salt = userData.(map[string]any)["_salt"].(string)
|
||||||
|
|
||||||
if len(username) > 0 {
|
if len(username) > 0 {
|
||||||
userData.(map[string]interface{})["_username"] = SHA256(username, salt)
|
userData.(map[string]any)["_username"] = SHA256(username, salt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(password) > 0 {
|
if len(password) > 0 {
|
||||||
userData.(map[string]interface{})["_password"] = SHA256(password, salt)
|
userData.(map[string]any)["_password"] = SHA256(password, salt)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = saveDatabase(data)
|
err = saveDatabase(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAllUserData : get all user data
|
// GetAllUserData : get all user data
|
||||||
func GetAllUserData() (allUserData map[string]interface{}, err error) {
|
func GetAllUserData() (allUserData map[string]any, err error) {
|
||||||
|
|
||||||
err = checkInit()
|
err = checkInit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
var defaults = make(map[string]interface{})
|
var defaults = make(map[string]any)
|
||||||
defaults["dbVersion"] = "1.0"
|
defaults["dbVersion"] = "1.0"
|
||||||
defaults["hash"] = "sha256"
|
defaults["hash"] = "sha256"
|
||||||
defaults["users"] = make(map[string]interface{})
|
defaults["users"] = make(map[string]any)
|
||||||
saveDatabase(defaults)
|
saveDatabase(defaults)
|
||||||
data = defaults
|
data = defaults
|
||||||
}
|
}
|
||||||
|
|
||||||
allUserData = data["users"].(map[string]interface{})
|
allUserData = data["users"].(map[string]any)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckTheValidityOfTheTokenFromHTTPHeader : get token from HTTP header
|
// CheckTheValidityOfTheTokenFromHTTPHeader : get token from HTTP header
|
||||||
func CheckTheValidityOfTheTokenFromHTTPHeader(w http.ResponseWriter, r *http.Request) (writer http.ResponseWriter, newToken string, err error) {
|
func CheckTheValidityOfTheTokenFromHTTPHeader(w http.ResponseWriter, r *http.Request) (writer http.ResponseWriter, newToken string, err error) {
|
||||||
err = createError(011)
|
err = createError(011)
|
||||||
for _, cookie := range r.Cookies() {
|
for _, cookie := range r.Cookies() {
|
||||||
if cookie.Name == "Token" {
|
if cookie.Name == "Token" {
|
||||||
var token string
|
var token string
|
||||||
token, err = CheckTheValidityOfTheToken(cookie.Value)
|
token, err = CheckTheValidityOfTheToken(cookie.Value)
|
||||||
//fmt.Println("T", token, err)
|
//fmt.Println("T", token, err)
|
||||||
writer = SetCookieToken(w, token)
|
writer = SetCookieToken(w, token)
|
||||||
newToken = token
|
newToken = token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fmt.Println(err)
|
//fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Framework tools
|
// Framework tools
|
||||||
|
|
||||||
func checkInit() (err error) {
|
func checkInit() (err error) {
|
||||||
if initAuthentication == false {
|
if initAuthentication == false {
|
||||||
err = createError(000)
|
err = createError(000)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveDatabase(tmpMap interface{}) (err error) {
|
func saveDatabase(tmpMap any) (err error) {
|
||||||
|
|
||||||
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(database, []byte(jsonString), 0600)
|
err = ioutil.WriteFile(database, []byte(jsonString), 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadDatabase() (err error) {
|
func loadDatabase() (err error) {
|
||||||
jsonString, err := ioutil.ReadFile(database)
|
jsonString, err := ioutil.ReadFile(database)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(jsonString), &data)
|
err = json.Unmarshal([]byte(jsonString), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHA256 : password + salt = sha256 string
|
// SHA256 : password + salt = sha256 string
|
||||||
func SHA256(secret, salt string) string {
|
func SHA256(secret, salt string) string {
|
||||||
key := []byte(secret)
|
key := []byte(secret)
|
||||||
h := hmac.New(sha256.New, key)
|
h := hmac.New(sha256.New, key)
|
||||||
h.Write([]byte("_remote_db"))
|
h.Write([]byte("_remote_db"))
|
||||||
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func randomString(n int) string {
|
func randomString(n int) string {
|
||||||
const alphanum = "-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ_"
|
const alphanum = "-AbCdEfGhIjKlMnOpQrStUvWxYz0123456789aBcDeFgHiJkLmNoPqRsTuVwXyZ_"
|
||||||
|
|
||||||
var bytes = make([]byte, n)
|
var bytes = make([]byte, n)
|
||||||
rand.Read(bytes)
|
rand.Read(bytes)
|
||||||
for i, b := range bytes {
|
for i, b := range bytes {
|
||||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
bytes[i] = alphanum[b%byte(len(alphanum))]
|
||||||
}
|
}
|
||||||
return string(bytes)
|
return string(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func randomID(n int) string {
|
func randomID(n int) string {
|
||||||
const alphanum = "ABCDEFGHJKLMNOPQRSTUVWXYZ0123456789"
|
const alphanum = "ABCDEFGHJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
|
|
||||||
var bytes = make([]byte, n)
|
var bytes = make([]byte, n)
|
||||||
rand.Read(bytes)
|
rand.Read(bytes)
|
||||||
for i, b := range bytes {
|
for i, b := range bytes {
|
||||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
bytes[i] = alphanum[b%byte(len(alphanum))]
|
||||||
}
|
}
|
||||||
return string(bytes)
|
return string(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createError(errCode int) (err error) {
|
func createError(errCode int) (err error) {
|
||||||
var errMsg string
|
var errMsg string
|
||||||
switch errCode {
|
switch errCode {
|
||||||
case 000:
|
case 000:
|
||||||
errMsg = "Authentication has not yet been initialized"
|
errMsg = "Authentication has not yet been initialized"
|
||||||
case 001:
|
case 001:
|
||||||
errMsg = "Default user already exists"
|
errMsg = "Default user already exists"
|
||||||
case 002:
|
case 002:
|
||||||
errMsg = "No user id found for this token"
|
errMsg = "No user id found for this token"
|
||||||
case 010:
|
case 010:
|
||||||
errMsg = "User authentication failed"
|
errMsg = "User authentication failed"
|
||||||
case 011:
|
case 011:
|
||||||
errMsg = "Session has expired"
|
errMsg = "Session has expired"
|
||||||
case 020:
|
case 020:
|
||||||
errMsg = "User already exists"
|
errMsg = "User already exists"
|
||||||
case 030:
|
case 030:
|
||||||
errMsg = "User data could not be saved"
|
errMsg = "User data could not be saved"
|
||||||
case 031:
|
case 031:
|
||||||
errMsg = "User data could not be read"
|
errMsg = "User data could not be read"
|
||||||
case 032:
|
case 032:
|
||||||
errMsg = "User ID was not found"
|
errMsg = "User ID was not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
err = errors.New(errMsg)
|
err = errors.New(errMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultsForNewUser(username, password string) map[string]interface{} {
|
func defaultsForNewUser(username, password string) map[string]any {
|
||||||
var defaults = make(map[string]interface{})
|
var defaults = make(map[string]any)
|
||||||
var salt = randomString(saltLength)
|
var salt = randomString(saltLength)
|
||||||
defaults["_username"] = SHA256(username, salt)
|
defaults["_username"] = SHA256(username, salt)
|
||||||
defaults["_password"] = SHA256(password, salt)
|
defaults["_password"] = SHA256(password, salt)
|
||||||
defaults["_salt"] = salt
|
defaults["_salt"] = salt
|
||||||
defaults["_id"] = "id-" + randomID(idLength)
|
defaults["_id"] = "id-" + randomID(idLength)
|
||||||
//defaults["_one.time.token"] = randomString(tokenLength)
|
//defaults["_one.time.token"] = randomString(tokenLength)
|
||||||
defaults["data"] = make(map[string]interface{})
|
defaults["data"] = make(map[string]any)
|
||||||
|
|
||||||
return defaults
|
return defaults
|
||||||
}
|
}
|
||||||
|
|
||||||
func setToken(id, oldToken string) (newToken string) {
|
func setToken(id, oldToken string) (newToken string) {
|
||||||
delete(tokens, oldToken)
|
tokensMu.Lock()
|
||||||
|
defer tokensMu.Unlock()
|
||||||
|
|
||||||
|
if oldToken != "-" {
|
||||||
|
delete(tokens, oldToken)
|
||||||
|
}
|
||||||
|
|
||||||
loopToken:
|
loopToken:
|
||||||
newToken = randomString(tokenLength)
|
newToken = randomString(tokenLength)
|
||||||
if _, ok := tokens[newToken]; ok {
|
if _, ok := tokens[newToken]; ok {
|
||||||
goto loopToken
|
goto loopToken
|
||||||
}
|
}
|
||||||
|
|
||||||
var tmp = make(map[string]interface{})
|
var tmp = make(map[string]any)
|
||||||
tmp["id"] = id
|
tmp["id"] = id
|
||||||
tmp["expires"] = time.Now().Local().Add(time.Minute * time.Duration(tokenValidity))
|
tmp["expires"] = time.Now().Local().Add(time.Minute * time.Duration(tokenValidity))
|
||||||
|
|
||||||
tokens[newToken] = tmp
|
tokens[newToken] = tmp
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func mapToJSON(tmpMap interface{}) string {
|
func mapToJSON(tmpMap any) string {
|
||||||
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "{}"
|
return "{}"
|
||||||
}
|
}
|
||||||
return string(jsonString)
|
return string(jsonString)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCookieToken : set cookie
|
// SetCookieToken : set cookie
|
||||||
func SetCookieToken(w http.ResponseWriter, token string) http.ResponseWriter {
|
func SetCookieToken(w http.ResponseWriter, token string) http.ResponseWriter {
|
||||||
expiration := time.Now().Add(time.Minute * time.Duration(tokenValidity))
|
expiration := time.Now().Add(time.Minute * time.Duration(tokenValidity))
|
||||||
cookie := http.Cookie{Name: "Token", Value: token, Expires: expiration}
|
cookie := http.Cookie{Name: "Token", Value: token, Expires: expiration}
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|||||||
178
src/internal/imgcache/cache.go
Normal file
178
src/internal/imgcache/cache.go
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
package imgcache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Cache : Cache strcut
|
||||||
|
type Cache struct {
|
||||||
|
path string
|
||||||
|
cacheURL string
|
||||||
|
caching bool
|
||||||
|
images map[string]string
|
||||||
|
Queue []string
|
||||||
|
Cache []string
|
||||||
|
Image imageFunc
|
||||||
|
sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
type imageFunc struct {
|
||||||
|
GetURL func(string) string
|
||||||
|
Caching func()
|
||||||
|
Remove func()
|
||||||
|
}
|
||||||
|
|
||||||
|
// New : New cahce
|
||||||
|
func New(path, chacheURL string, caching bool) (c *Cache, err error) {
|
||||||
|
|
||||||
|
c = &Cache{}
|
||||||
|
|
||||||
|
c.images = make(map[string]string)
|
||||||
|
c.path = path
|
||||||
|
c.cacheURL = chacheURL
|
||||||
|
c.caching = caching
|
||||||
|
c.Queue = []string{}
|
||||||
|
c.Cache = []string{}
|
||||||
|
|
||||||
|
var queue []string
|
||||||
|
|
||||||
|
c.Image.GetURL = func(src string) (cacheURL string) {
|
||||||
|
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
|
||||||
|
src = strings.Trim(src, "\r\n")
|
||||||
|
|
||||||
|
if c.caching == false {
|
||||||
|
return src
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := url.Parse(src)
|
||||||
|
if err != nil || len(filepath.Ext(u.Path)) == 0 {
|
||||||
|
return src
|
||||||
|
}
|
||||||
|
|
||||||
|
var filename = fmt.Sprintf("%s%s", strToMD5(src), filepath.Ext(u.Path))
|
||||||
|
if cacheURL, ok := c.images[fmt.Sprintf("%s%s", strToMD5(src), filepath.Ext(u.Path))]; ok {
|
||||||
|
return cacheURL
|
||||||
|
}
|
||||||
|
|
||||||
|
if indexOfString(filename, c.Cache) == -1 {
|
||||||
|
|
||||||
|
if indexOfString(src, c.Queue) == -1 {
|
||||||
|
c.Queue = append(c.Queue, src)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
c.images[filename] = c.cacheURL + filename
|
||||||
|
src = c.cacheURL + filename
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if _, err := os.Stat(c.path + filename); err != nil {
|
||||||
|
//c.images[filename] = c.cacheURL + filename
|
||||||
|
if indexOfString(src, c.Queue) == -1 {
|
||||||
|
c.Queue = append(c.Queue, src)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c.images[filename] = c.cacheURL + filename
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return src
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Image.Caching = func() {
|
||||||
|
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
|
||||||
|
var filename string
|
||||||
|
|
||||||
|
for _, src := range c.Queue {
|
||||||
|
|
||||||
|
resp, err := http.Get(src)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = fmt.Sprintf("%s%s%s%s", c.path, string(os.PathSeparator), strToMD5(src), filepath.Ext(src))
|
||||||
|
|
||||||
|
file, err := os.Create(filename)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
_, err = io.Copy(file, resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := url.Parse(src)
|
||||||
|
if err == nil {
|
||||||
|
c.images[fmt.Sprintf("%s%s", strToMD5(src), filepath.Ext(u.Path))] = c.cacheURL + filename
|
||||||
|
}
|
||||||
|
|
||||||
|
queue = append(queue, src)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, q := range queue {
|
||||||
|
c.Queue = removeStringFromSlice(q, c.Queue)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Image.Remove = func() {
|
||||||
|
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
|
||||||
|
files, err := ioutil.ReadDir(c.path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
|
||||||
|
switch c.caching {
|
||||||
|
|
||||||
|
case true:
|
||||||
|
if _, ok := c.images[file.Name()]; !ok {
|
||||||
|
os.RemoveAll(c.path + file.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
case false:
|
||||||
|
os.RemoveAll(c.path + file.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
files, err := ioutil.ReadDir(c.path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
c.Cache = append(c.Cache, file.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
34
src/internal/imgcache/tools.go
Normal file
34
src/internal/imgcache/tools.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package imgcache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
)
|
||||||
|
|
||||||
|
func strToMD5(str string) string {
|
||||||
|
md5Hasher := md5.New()
|
||||||
|
md5Hasher.Write([]byte(str))
|
||||||
|
return hex.EncodeToString(md5Hasher.Sum(nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
func indexOfString(str string, slice []string) int {
|
||||||
|
|
||||||
|
for i, v := range slice {
|
||||||
|
if str == v {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeStringFromSlice(str string, slice []string) []string {
|
||||||
|
|
||||||
|
var i = indexOfString(str, slice)
|
||||||
|
|
||||||
|
if i != -1 {
|
||||||
|
slice = append(slice[:i], slice[i+1:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return slice
|
||||||
|
}
|
||||||
@@ -1,84 +1,84 @@
|
|||||||
package m3u
|
package m3u
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type M3UStream struct {
|
type M3UStream struct {
|
||||||
GroupTitle string `json:"group-title,required"`
|
GroupTitle string `json:"group-title,required"`
|
||||||
Name string `json:"name,required"`
|
Name string `json:"name,required"`
|
||||||
TvgID string `json:"tvg-id,required"`
|
TvgID string `json:"tvg-id,required"`
|
||||||
TvgLogo string `json:"tvg-logo,required"`
|
TvgLogo string `json:"tvg-logo,required"`
|
||||||
TvgName string `json:"tvg-name,required"`
|
TvgName string `json:"tvg-name,required"`
|
||||||
URL string `json:"url,required"`
|
URL string `json:"url,required"`
|
||||||
UUIDKey string `json:"_uuid.key,omitempty"`
|
UUIDKey string `json:"_uuid.key,omitempty"`
|
||||||
UUIDValue string `json:"_uuid.value,omitempty"`
|
UUIDValue string `json:"_uuid.value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStream1(t *testing.T) {
|
func TestStream1(t *testing.T) {
|
||||||
|
|
||||||
var file = "test_list_1.m3u"
|
var file = "test_list_1.m3u"
|
||||||
var content, err = ioutil.ReadFile(file)
|
var content, err = ioutil.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
streams, err := MakeInterfaceFromM3U(content)
|
streams, err := MakeInterfaceFromM3U(content)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = checkStream(streams)
|
err = checkStream(streams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Streams:", len(streams))
|
fmt.Println("Streams:", len(streams))
|
||||||
t.Log(streams)
|
t.Log(streams)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkStream(streamInterface []interface{}) (err error) {
|
func checkStream(streamInterface []any) (err error) {
|
||||||
|
|
||||||
for i, s := range streamInterface {
|
for i, s := range streamInterface {
|
||||||
|
|
||||||
var stream = s.(map[string]string)
|
var stream = s.(map[string]string)
|
||||||
var m3uStream M3UStream
|
var m3uStream M3UStream
|
||||||
|
|
||||||
jsonString, err := json.MarshalIndent(stream, "", " ")
|
jsonString, err := json.MarshalIndent(stream, "", " ")
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
err = json.Unmarshal(jsonString, &m3uStream)
|
err = json.Unmarshal(jsonString, &m3uStream)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
log.Print(fmt.Sprintf("Stream: %d", i))
|
log.Print(fmt.Sprintf("Stream: %d", i))
|
||||||
log.Print(fmt.Sprintf("Name*: %s", m3uStream.Name))
|
log.Print(fmt.Sprintf("Name*: %s", m3uStream.Name))
|
||||||
log.Print(fmt.Sprintf("URL*: %s", m3uStream.URL))
|
log.Print(fmt.Sprintf("URL*: %s", m3uStream.URL))
|
||||||
log.Print(fmt.Sprintf("tvg-name: %s", m3uStream.TvgName))
|
log.Print(fmt.Sprintf("tvg-name: %s", m3uStream.TvgName))
|
||||||
log.Print(fmt.Sprintf("tvg-id**: %s", m3uStream.TvgID))
|
log.Print(fmt.Sprintf("tvg-id**: %s", m3uStream.TvgID))
|
||||||
log.Print(fmt.Sprintf("tvg-logo: %s", m3uStream.TvgLogo))
|
log.Print(fmt.Sprintf("tvg-logo: %s", m3uStream.TvgLogo))
|
||||||
log.Print(fmt.Sprintf("group-title**: %s", m3uStream.GroupTitle))
|
log.Print(fmt.Sprintf("group-title**: %s", m3uStream.GroupTitle))
|
||||||
|
|
||||||
if len(m3uStream.UUIDKey) > 0 {
|
if len(m3uStream.UUIDKey) > 0 {
|
||||||
log.Print(fmt.Sprintf("UUID key***: %s", m3uStream.UUIDKey))
|
log.Print(fmt.Sprintf("UUID key***: %s", m3uStream.UUIDKey))
|
||||||
log.Print(fmt.Sprintf("UUID value: %s", m3uStream.UUIDValue))
|
log.Print(fmt.Sprintf("UUID value: %s", m3uStream.UUIDValue))
|
||||||
} else {
|
} else {
|
||||||
log.Print(fmt.Sprintf("UUID key: false"))
|
log.Print(fmt.Sprintf("UUID key: false"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(fmt.Sprintf("- - - - - (*: Required) | (**: Nice to have) | (***: Love it) - - - - -"))
|
log.Println(fmt.Sprintf("- - - - - (*: Required) | (**: Nice to have) | (***: Love it) - - - - -"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
#EXTM3U url-tvg="http://example.com/file.xml" x-tvg-url="http://example.com/xteve.xml"
|
#EXTM3U url-tvg="http://example.com/file.xml" x-tvg-url="http://example.com/xteve.xml"
|
||||||
#EXTINF:0 channelID="1" tvg-chno="1" tvg-name="Channel.1" tvg-id="tvg.id.1" tvg-logo="https://example/logo.png" group-title="Group 1",Channel 1
|
#EXTINF:0 channelID="1" tvg-chno="1" tvg-name="Channel.1" tvg-id="tvg.id.1" tvg-logo="https://example/logo.png" group-title="Group 1", Channel 1
|
||||||
http://example.com/stream/1
|
http://example.com/stream/1
|
||||||
|
|
||||||
#EXTINF:0 channelID="2" tvg-chno="2" tvg-name="Channel.2" tvg-id="tvg.id.2" tvg-logo="https://example/logo.png" group-title="Group 2",Channel 2
|
#EXTINF:0 channelID="2" tvg-chno="2" tvg-name="Channel.2" tvg-id="tvg.id.2" tvg-logo="https://example/logo.png" group-title="Group 2",Channel 2
|
||||||
#123
|
#123
|
||||||
http://example.com/stream/2
|
http://example.com/stream/2
|
||||||
|
|
||||||
|
#EXTINF:123, Sample artist - Sample title
|
||||||
|
http://example.com/stream/3
|
||||||
|
|
||||||
|
#EXTINF:321,Example Artist - Example title
|
||||||
|
http://example.com/stream/4
|
||||||
|
|||||||
@@ -1,182 +1,186 @@
|
|||||||
package m3u
|
package m3u
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MakeInterfaceFromM3U :
|
// MakeInterfaceFromM3U :
|
||||||
func MakeInterfaceFromM3U(byteStream []byte) (allChannels []interface{}, err error) {
|
func MakeInterfaceFromM3U(byteStream []byte) (allChannels []any, err error) {
|
||||||
|
|
||||||
var content = string(byteStream)
|
var content = string(byteStream)
|
||||||
var channelName string
|
var channelName string
|
||||||
var uuids []string
|
var uuids []string
|
||||||
|
|
||||||
var parseMetaData = func(channel string) (stream map[string]string) {
|
var parseMetaData = func(channel string) (stream map[string]string) {
|
||||||
|
|
||||||
stream = make(map[string]string)
|
stream = make(map[string]string)
|
||||||
var exceptForParameter = `[a-z-A-Z=]*(".*?")`
|
var exceptForParameter = `[a-z-A-Z=]*(".*?")`
|
||||||
var exceptForChannelName = `,([^\n]*|,[^\r]*)`
|
var exceptForChannelName = `,([^\n]*|,[^\r]*)`
|
||||||
|
|
||||||
var lines = strings.Split(strings.Replace(channel, "\r\n", "\n", -1), "\n")
|
var lines = strings.Split(strings.Replace(channel, "\r\n", "\n", -1), "\n")
|
||||||
|
|
||||||
// Zeilen mit # und leerer Zeilen entfernen
|
// Zeilen mit # und leerer Zeilen entfernen
|
||||||
for i := len(lines) - 1; i >= 0; i-- {
|
for i := len(lines) - 1; i >= 0; i-- {
|
||||||
|
|
||||||
if len(lines[i]) == 0 || lines[i][0:1] == "#" {
|
if len(lines[i]) == 0 || lines[i][0:1] == "#" {
|
||||||
lines = append(lines[:i], lines[i+1:]...)
|
lines = append(lines[:i], lines[i+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(lines) >= 2 {
|
if len(lines) >= 2 {
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
|
|
||||||
_, err := url.ParseRequestURI(line)
|
_, err := url.ParseRequestURI(line)
|
||||||
|
|
||||||
switch err {
|
switch err {
|
||||||
|
|
||||||
case nil:
|
case nil:
|
||||||
stream["url"] = strings.Trim(line, "\r\n")
|
stream["url"] = strings.Trim(line, "\r\n")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
var value string
|
var value string
|
||||||
// Alle Parameter parsen
|
// Alle Parameter parsen
|
||||||
var p = regexp.MustCompile(exceptForParameter)
|
var p = regexp.MustCompile(exceptForParameter)
|
||||||
var streamParameter = p.FindAllString(line, -1)
|
var streamParameter = p.FindAllString(line, -1)
|
||||||
|
|
||||||
for _, p := range streamParameter {
|
for _, p := range streamParameter {
|
||||||
|
|
||||||
line = strings.Replace(line, p, "", 1)
|
line = strings.Replace(line, p, "", 1)
|
||||||
|
|
||||||
p = strings.Replace(p, `"`, "", -1)
|
p = strings.Replace(p, `"`, "", -1)
|
||||||
var parameter = strings.SplitN(p, "=", 2)
|
var parameter = strings.SplitN(p, "=", 2)
|
||||||
|
|
||||||
if len(parameter) == 2 {
|
if len(parameter) == 2 {
|
||||||
|
|
||||||
// TVG Key als Kleinbuchstaben speichern
|
// TVG Key als Kleinbuchstaben speichern
|
||||||
switch strings.Contains(parameter[0], "tvg") {
|
switch strings.Contains(parameter[0], "tvg") {
|
||||||
|
|
||||||
case true:
|
case true:
|
||||||
stream[strings.ToLower(parameter[0])] = parameter[1]
|
stream[strings.ToLower(parameter[0])] = parameter[1]
|
||||||
case false:
|
case false:
|
||||||
stream[parameter[0]] = parameter[1]
|
stream[parameter[0]] = parameter[1]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// URL's nicht an die Filterfunktion übergeben
|
// URL's nicht an die Filterfunktion übergeben
|
||||||
if !strings.Contains(parameter[1], "://") && len(parameter[1]) > 0 {
|
if !strings.Contains(parameter[1], "://") && len(parameter[1]) > 0 {
|
||||||
value = value + parameter[1] + " "
|
value = value + parameter[1] + " "
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kanalnamen parsen
|
// Kanalnamen parsen
|
||||||
n := regexp.MustCompile(exceptForChannelName)
|
n := regexp.MustCompile(exceptForChannelName)
|
||||||
var name = n.FindAllString(line, 1)
|
var name = n.FindAllString(line, 1)
|
||||||
|
|
||||||
if len(name) > 0 {
|
if len(name) > 0 {
|
||||||
channelName = name[0]
|
channelName = name[0]
|
||||||
channelName = strings.Replace(channelName, `,`, "", 1)
|
channelName = strings.Replace(channelName, `,`, "", 1)
|
||||||
channelName = strings.TrimRight(channelName, "\r\n")
|
channelName = strings.TrimRight(channelName, "\r\n")
|
||||||
channelName = strings.TrimRight(channelName, " ")
|
channelName = strings.TrimRight(channelName, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(channelName) == 0 {
|
if len(channelName) == 0 {
|
||||||
|
|
||||||
if v, ok := stream["tvg-name"]; ok {
|
if v, ok := stream["tvg-name"]; ok {
|
||||||
channelName = v
|
channelName = v
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channelName = strings.TrimRight(channelName, " ")
|
channelName = strings.TrimRight(channelName, " ")
|
||||||
|
|
||||||
// Kanäle ohne Namen werden augelassen
|
// Kanäle ohne Namen werden augelassen
|
||||||
if len(channelName) == 0 {
|
if len(channelName) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stream["name"] = channelName
|
stream["name"] = channelName
|
||||||
value = value + channelName
|
value = value + channelName
|
||||||
|
|
||||||
stream["_values"] = value
|
stream["_values"] = value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nach eindeutiger ID im Stream suchen
|
// Nach eindeutiger ID im Stream suchen
|
||||||
for key, value := range stream {
|
for key, value := range stream {
|
||||||
|
|
||||||
if !strings.Contains(strings.ToLower(key), "tvg-id") {
|
if !strings.Contains(strings.ToLower(key), "tvg-id") {
|
||||||
|
|
||||||
if strings.Contains(strings.ToLower(key), "id") {
|
if strings.Contains(strings.ToLower(key), "id") {
|
||||||
|
|
||||||
if indexOfString(value, uuids) != -1 {
|
if indexOfString(value, uuids) != -1 {
|
||||||
log.Println(fmt.Sprintf("Channel: %s - %s = %s ", stream["name"], key, value))
|
log.Println(fmt.Sprintf("Channel: %s - %s = %s ", stream["name"], key, value))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
uuids = append(uuids, value)
|
uuids = append(uuids, value)
|
||||||
|
|
||||||
stream["_uuid.key"] = key
|
stream["_uuid.key"] = key
|
||||||
stream["_uuid.value"] = value
|
stream["_uuid.value"] = value
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//fmt.Println(content)
|
//fmt.Println(content)
|
||||||
|
if strings.Contains(content, "#EXT-X-TARGETDURATION") || strings.Contains(content, "#EXT-X-MEDIA-SEQUENCE") {
|
||||||
|
err = errors.New("Invalid M3U file, an extended M3U file is required.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if strings.Contains(content, "#EXTM3U") {
|
if strings.Contains(content, "#EXTM3U") {
|
||||||
|
|
||||||
var channels = strings.Split(content, "#EXTINF")
|
var channels = strings.Split(content, "#EXTINF")
|
||||||
|
|
||||||
channels = append(channels[:0], channels[1:]...)
|
channels = append(channels[:0], channels[1:]...)
|
||||||
|
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
|
|
||||||
var stream = parseMetaData(channel)
|
var stream = parseMetaData(channel)
|
||||||
|
|
||||||
if len(stream) > 0 && stream != nil {
|
if len(stream) > 0 && stream != nil {
|
||||||
allChannels = append(allChannels, stream)
|
allChannels = append(allChannels, stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
err = errors.New("No valid m3u file")
|
err = errors.New("Invalid M3U file, an extended M3U file is required.")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func indexOfString(element string, data []string) int {
|
func indexOfString(element string, data []string) int {
|
||||||
|
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
if element == v {
|
if element == v {
|
||||||
return k
|
return k
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ type ClientInfo struct {
|
|||||||
OS string `json:"os,required"`
|
OS string `json:"os,required"`
|
||||||
URL string `json:"url,required"`
|
URL string `json:"url,required"`
|
||||||
|
|
||||||
Response ServerResponse `json:"response,omitempty"`
|
Response ServerResponse `json:"response"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//ServerResponse : Response from server after client request
|
// ServerResponse : Response from server after client request
|
||||||
type ServerResponse struct {
|
type ServerResponse struct {
|
||||||
Status bool `json:"status,omitempty"`
|
Status bool `json:"status,omitempty"`
|
||||||
Reason string `json:"reason,omitempty"`
|
Reason string `json:"reason,omitempty"`
|
||||||
@@ -106,7 +106,7 @@ func serverRequest() (err error) {
|
|||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
//fmt.Println(resp.StatusCode, Updater.URL, Updater.CMD)
|
//fmt.Println(resp.StatusCode, Updater.URL, Updater.CMD)
|
||||||
err = fmt.Errorf(fmt.Sprintf("%d: %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), Updater.URL))
|
err = fmt.Errorf("%d: %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), Updater.URL)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/m3u.go
10
src/m3u.go
@@ -9,11 +9,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
m3u "../src/internal/m3u-parser"
|
m3u "xteve/src/internal/m3u-parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Playlisten parsen
|
// Playlisten parsen
|
||||||
func parsePlaylist(filename, fileType string) (channels []interface{}, err error) {
|
func parsePlaylist(filename, fileType string) (channels []any, err error) {
|
||||||
|
|
||||||
content, err := readByteFromFile(filename)
|
content, err := readByteFromFile(filename)
|
||||||
var id = strings.TrimSuffix(getFilenameFromPath(filename), path.Ext(getFilenameFromPath(filename)))
|
var id = strings.TrimSuffix(getFilenameFromPath(filename), path.Ext(getFilenameFromPath(filename)))
|
||||||
@@ -34,7 +34,7 @@ func parsePlaylist(filename, fileType string) (channels []interface{}, err error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Streams filtern
|
// Streams filtern
|
||||||
func filterThisStream(s interface{}) (status bool) {
|
func filterThisStream(s any) (status bool) {
|
||||||
|
|
||||||
status = false
|
status = false
|
||||||
var stream = s.(map[string]string)
|
var stream = s.(map[string]string)
|
||||||
@@ -181,6 +181,7 @@ func checkConditions(streamValues, conditions, coType string) (status bool) {
|
|||||||
// xTeVe M3U Datei erstellen
|
// xTeVe M3U Datei erstellen
|
||||||
func buildM3U(groups []string) (m3u string, err error) {
|
func buildM3U(groups []string) (m3u string, err error) {
|
||||||
|
|
||||||
|
var imgc = Data.Cache.Images
|
||||||
var m3uChannels = make(map[float64]XEPGChannelStruct)
|
var m3uChannels = make(map[float64]XEPGChannelStruct)
|
||||||
var channelNumbers []float64
|
var channelNumbers []float64
|
||||||
|
|
||||||
@@ -223,7 +224,8 @@ func buildM3U(groups []string) (m3u string, err error) {
|
|||||||
for _, channelNumber := range channelNumbers {
|
for _, channelNumber := range channelNumbers {
|
||||||
|
|
||||||
var channel = m3uChannels[channelNumber]
|
var channel = m3uChannels[channelNumber]
|
||||||
var parameter = fmt.Sprintf(`#EXTINF:0 channelID="%s" tvg-chno="%s" tvg-name="%s" tvg-id="%s" tvg-logo="%s" group-title="%s",%s`+"\n", channel.XEPG, channel.XChannelID, channel.XName, channel.XChannelID, getCacheImageURL(channel.TvgLogo), channel.XGroupTitle, channel.XName)
|
|
||||||
|
var parameter = fmt.Sprintf(`#EXTINF:0 channelID="%s" tvg-chno="%s" tvg-name="%s" tvg-id="%s" tvg-logo="%s" group-title="%s",%s`+"\n", channel.XEPG, channel.XChannelID, channel.XName, channel.XChannelID, imgc.Image.GetURL(channel.TvgLogo), channel.XGroupTitle, channel.XName)
|
||||||
var stream, err = createStreamingURL("M3U", channel.FileM3UID, channel.XChannelID, channel.XName, channel.URL)
|
var stream, err = createStreamingURL("M3U", channel.FileM3UID, channel.XChannelID, channel.XName, channel.URL)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m3u = m3u + parameter + stream + "\n"
|
m3u = m3u + parameter + stream + "\n"
|
||||||
|
|||||||
363
src/plex_api.go
Normal file
363
src/plex_api.go
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
package src
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var plexRefreshState = struct {
|
||||||
|
sync.Mutex
|
||||||
|
lastRun time.Time
|
||||||
|
scheduled bool
|
||||||
|
inProgress bool
|
||||||
|
queued bool
|
||||||
|
reason string
|
||||||
|
missingConfigLogged bool
|
||||||
|
}{}
|
||||||
|
|
||||||
|
// queuePlexGuideRefresh schedules a debounced Plex DVR guide refresh.
|
||||||
|
func queuePlexGuideRefresh(reason string) {
|
||||||
|
|
||||||
|
if Settings.UsePlexAPI == false {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
plexRefreshState.Lock()
|
||||||
|
|
||||||
|
if len(strings.TrimSpace(reason)) > 0 {
|
||||||
|
plexRefreshState.reason = reason
|
||||||
|
}
|
||||||
|
|
||||||
|
if plexRefreshState.scheduled == true || plexRefreshState.inProgress == true {
|
||||||
|
plexRefreshState.queued = true
|
||||||
|
plexRefreshState.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
plexRefreshState.scheduled = true
|
||||||
|
delay := plexRefreshDelayLocked()
|
||||||
|
plexRefreshState.Unlock()
|
||||||
|
|
||||||
|
go runPlexGuideRefresh(delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runPlexGuideRefresh(initialDelay time.Duration) {
|
||||||
|
|
||||||
|
if initialDelay > 0 {
|
||||||
|
time.Sleep(initialDelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
|
||||||
|
plexRefreshState.Lock()
|
||||||
|
reason := strings.TrimSpace(plexRefreshState.reason)
|
||||||
|
if len(reason) == 0 {
|
||||||
|
reason = "update"
|
||||||
|
}
|
||||||
|
plexRefreshState.scheduled = false
|
||||||
|
plexRefreshState.inProgress = true
|
||||||
|
plexRefreshState.queued = false
|
||||||
|
plexRefreshState.Unlock()
|
||||||
|
|
||||||
|
err := refreshPlexGuide(reason)
|
||||||
|
if err != nil {
|
||||||
|
ShowError(err, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
plexRefreshState.Lock()
|
||||||
|
plexRefreshState.lastRun = time.Now()
|
||||||
|
runAgain := plexRefreshState.queued
|
||||||
|
plexRefreshState.inProgress = false
|
||||||
|
nextDelay := time.Duration(0)
|
||||||
|
|
||||||
|
if runAgain == true && Settings.UsePlexAPI == true {
|
||||||
|
plexRefreshState.scheduled = true
|
||||||
|
nextDelay = plexRefreshDelayLocked()
|
||||||
|
}
|
||||||
|
plexRefreshState.Unlock()
|
||||||
|
|
||||||
|
if runAgain == false || Settings.UsePlexAPI == false {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(nextDelay)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func plexRefreshDelayLocked() (delay time.Duration) {
|
||||||
|
|
||||||
|
const minDelay = 2 * time.Second
|
||||||
|
const cooldown = 20 * time.Second
|
||||||
|
|
||||||
|
if plexRefreshState.lastRun.IsZero() == true {
|
||||||
|
return minDelay
|
||||||
|
}
|
||||||
|
|
||||||
|
since := time.Since(plexRefreshState.lastRun)
|
||||||
|
if since >= cooldown {
|
||||||
|
return minDelay
|
||||||
|
}
|
||||||
|
|
||||||
|
return cooldown - since
|
||||||
|
}
|
||||||
|
|
||||||
|
func refreshPlexGuide(reason string) (err error) {
|
||||||
|
|
||||||
|
baseURL, token, ready := getPlexConfig()
|
||||||
|
if ready == false {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
dvrs, err := discoverPlexDVRs(baseURL, token)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var refreshed int
|
||||||
|
var failed int
|
||||||
|
|
||||||
|
for _, dvr := range dvrs {
|
||||||
|
|
||||||
|
endpoints := getPlexReloadEndpoints(dvr)
|
||||||
|
if len(endpoints) == 0 {
|
||||||
|
failed++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var endpointErr error
|
||||||
|
for _, endpoint := range endpoints {
|
||||||
|
|
||||||
|
status, _, requestErr := doPlexRequest("POST", baseURL, endpoint, token)
|
||||||
|
if requestErr != nil {
|
||||||
|
endpointErr = requestErr
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if status >= 200 && status < 300 {
|
||||||
|
refreshed++
|
||||||
|
endpointErr = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
endpointErr = fmt.Errorf("Plex API returned HTTP %d for %s", status, endpoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
if endpointErr != nil {
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if refreshed == 0 {
|
||||||
|
if failed == 0 {
|
||||||
|
return errors.New("Plex API guide refresh failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("Plex API guide refresh failed for %d DVR(s)", failed)
|
||||||
|
}
|
||||||
|
|
||||||
|
showInfo(fmt.Sprintf("Plex API:Guide reload requested for %d DVR(s) (%s)", refreshed, reason))
|
||||||
|
if failed > 0 {
|
||||||
|
showInfo(fmt.Sprintf("Plex API:Guide reload failed for %d DVR(s)", failed))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPlexConfig() (baseURL, token string, ready bool) {
|
||||||
|
|
||||||
|
baseURL = strings.TrimSpace(Settings.PlexURL)
|
||||||
|
token = strings.TrimSpace(Settings.PlexToken)
|
||||||
|
|
||||||
|
if strings.HasPrefix(baseURL, "http://") == false && strings.HasPrefix(baseURL, "https://") == false && len(baseURL) > 0 {
|
||||||
|
baseURL = "http://" + baseURL
|
||||||
|
}
|
||||||
|
|
||||||
|
baseURL = strings.TrimRight(baseURL, "/")
|
||||||
|
|
||||||
|
plexRefreshState.Lock()
|
||||||
|
defer plexRefreshState.Unlock()
|
||||||
|
|
||||||
|
if len(baseURL) == 0 || len(token) == 0 {
|
||||||
|
|
||||||
|
if plexRefreshState.missingConfigLogged == false {
|
||||||
|
showInfo("Plex API:Skipped refresh because plex.url or plex.token is empty")
|
||||||
|
plexRefreshState.missingConfigLogged = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
plexRefreshState.missingConfigLogged = false
|
||||||
|
|
||||||
|
return baseURL, token, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func discoverPlexDVRs(baseURL, token string) (dvrs []map[string]any, err error) {
|
||||||
|
|
||||||
|
status, body, err := doPlexRequest("GET", baseURL, "/livetv/dvrs", token)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if status < 200 || status >= 300 {
|
||||||
|
err = fmt.Errorf("Plex API returned HTTP %d for /livetv/dvrs", status)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var payload = make(map[string]any)
|
||||||
|
err = json.Unmarshal(body, &payload)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaContainer, ok := payload["MediaContainer"].(map[string]any)
|
||||||
|
if ok == false {
|
||||||
|
err = errors.New("Plex API response missing MediaContainer")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, key := range []string{"Dvr", "DVR", "Directory", "Metadata"} {
|
||||||
|
if raw, found := mediaContainer[key]; found == true {
|
||||||
|
if list, ok := raw.([]any); ok == true {
|
||||||
|
dvrs = convertToPlexMapSlice(list)
|
||||||
|
if len(dvrs) > 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = errors.New("Plex API returned no DVR entries")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertToPlexMapSlice(list []any) (dvrs []map[string]any) {
|
||||||
|
|
||||||
|
dvrs = make([]map[string]any, 0, len(list))
|
||||||
|
|
||||||
|
for _, item := range list {
|
||||||
|
if dvr, ok := item.(map[string]any); ok == true {
|
||||||
|
dvrs = append(dvrs, dvr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPlexReloadEndpoints(dvr map[string]any) (endpoints []string) {
|
||||||
|
|
||||||
|
endpoints = make([]string, 0, 6)
|
||||||
|
added := make(map[string]bool)
|
||||||
|
|
||||||
|
add := func(endpoint string) {
|
||||||
|
endpoint = strings.TrimSpace(endpoint)
|
||||||
|
if len(endpoint) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(endpoint, "/") == false {
|
||||||
|
endpoint = "/" + endpoint
|
||||||
|
}
|
||||||
|
if added[endpoint] == true {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
added[endpoint] = true
|
||||||
|
endpoints = append(endpoints, endpoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
if key := getPlexMapString(dvr, "key"); len(key) > 0 {
|
||||||
|
if strings.HasPrefix(key, "/") == true {
|
||||||
|
add(strings.TrimRight(key, "/") + "/reloadGuide")
|
||||||
|
} else {
|
||||||
|
add("/livetv/dvrs/" + url.PathEscape(key) + "/reloadGuide")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, field := range []string{"uuid", "identifier", "machineIdentifier", "clientIdentifier", "id"} {
|
||||||
|
if value := getPlexMapString(dvr, field); len(value) > 0 {
|
||||||
|
add("/livetv/dvrs/" + url.PathEscape(value) + "/reloadGuide")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPlexMapString(data map[string]any, field string) string {
|
||||||
|
|
||||||
|
for key, value := range data {
|
||||||
|
if strings.EqualFold(key, field) == false {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
switch v := value.(type) {
|
||||||
|
|
||||||
|
case string:
|
||||||
|
return strings.TrimSpace(v)
|
||||||
|
|
||||||
|
case float64:
|
||||||
|
return strconv.FormatInt(int64(v), 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func doPlexRequest(method, baseURL, endpoint, token string) (status int, body []byte, err error) {
|
||||||
|
|
||||||
|
requestURL := strings.TrimRight(baseURL, "/") + "/" + strings.TrimLeft(endpoint, "/")
|
||||||
|
|
||||||
|
req, err := http.NewRequest(method, requestURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
query := req.URL.Query()
|
||||||
|
if len(token) > 0 {
|
||||||
|
query.Set("X-Plex-Token", token)
|
||||||
|
req.URL.RawQuery = query.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", "application/json")
|
||||||
|
req.Header.Set("X-Plex-Token", token)
|
||||||
|
|
||||||
|
if len(System.DeviceID) > 0 {
|
||||||
|
req.Header.Set("X-Plex-Client-Identifier", System.DeviceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(System.Name) > 0 {
|
||||||
|
req.Header.Set("X-Plex-Product", System.Name)
|
||||||
|
req.Header.Set("X-Plex-Device-Name", System.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(System.Version) > 0 {
|
||||||
|
req.Header.Set("X-Plex-Version", System.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
client := &http.Client{
|
||||||
|
Timeout: 10 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
status = resp.StatusCode
|
||||||
|
body, err = ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
m3u "../src/internal/m3u-parser"
|
m3u "xteve/src/internal/m3u-parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fileType: Welcher Dateityp soll aktualisiert werden (m3u, hdhr, xml) | fileID: Update einer bestimmten Datei (Provider ID)
|
// fileType: Welcher Dateityp soll aktualisiert werden (m3u, hdhr, xml) | fileID: Update einer bestimmten Datei (Provider ID)
|
||||||
@@ -17,13 +17,13 @@ func getProviderData(fileType, fileID string) (err error) {
|
|||||||
var fileExtension, serverFileName string
|
var fileExtension, serverFileName string
|
||||||
var body = make([]byte, 0)
|
var body = make([]byte, 0)
|
||||||
var newProvider = false
|
var newProvider = false
|
||||||
var dataMap = make(map[string]interface{})
|
var dataMap = make(map[string]any)
|
||||||
|
|
||||||
var saveDateFromProvider = func(fileSource, serverFileName, id string, body []byte) (err error) {
|
var saveDateFromProvider = func(fileSource, serverFileName, id string, body []byte) (err error) {
|
||||||
|
|
||||||
var data = make(map[string]interface{})
|
var data = make(map[string]any)
|
||||||
|
|
||||||
if value, ok := dataMap[id].(map[string]interface{}); ok {
|
if value, ok := dataMap[id].(map[string]any); ok {
|
||||||
data = value
|
data = value
|
||||||
} else {
|
} else {
|
||||||
data["id.provider"] = id
|
data["id.provider"] = id
|
||||||
@@ -65,7 +65,7 @@ func getProviderData(fileType, fileID string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "compatibility":
|
case "compatibility":
|
||||||
data[key] = make(map[string]interface{})
|
data[key] = make(map[string]any)
|
||||||
|
|
||||||
case "counter.download":
|
case "counter.download":
|
||||||
data[key] = 0.0
|
data[key] = 0.0
|
||||||
@@ -142,7 +142,7 @@ func getProviderData(fileType, fileID string) (err error) {
|
|||||||
|
|
||||||
for dataID, d := range dataMap {
|
for dataID, d := range dataMap {
|
||||||
|
|
||||||
var data = d.(map[string]interface{})
|
var data = d.(map[string]any)
|
||||||
var fileSource = data["file.source"].(string)
|
var fileSource = data["file.source"].(string)
|
||||||
newProvider = false
|
newProvider = false
|
||||||
|
|
||||||
@@ -220,8 +220,8 @@ func getProviderData(fileType, fileID string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fehler Counter um 1 erhöhen
|
// Fehler Counter um 1 erhöhen
|
||||||
var data = make(map[string]interface{})
|
var data = make(map[string]any)
|
||||||
if value, ok := dataMap[dataID].(map[string]interface{}); ok {
|
if value, ok := dataMap[dataID].(map[string]any); ok {
|
||||||
|
|
||||||
data = value
|
data = value
|
||||||
data["counter.error"] = data["counter.error"].(float64) + 1
|
data["counter.error"] = data["counter.error"].(float64) + 1
|
||||||
@@ -238,9 +238,9 @@ func getProviderData(fileType, fileID string) (err error) {
|
|||||||
// Berechnen der Fehlerquote
|
// Berechnen der Fehlerquote
|
||||||
if newProvider == false {
|
if newProvider == false {
|
||||||
|
|
||||||
if value, ok := dataMap[dataID].(map[string]interface{}); ok {
|
if value, ok := dataMap[dataID].(map[string]any); ok {
|
||||||
|
|
||||||
var data = make(map[string]interface{})
|
var data = make(map[string]any)
|
||||||
data = value
|
data = value
|
||||||
|
|
||||||
if data["counter.error"].(float64) == 0 {
|
if data["counter.error"].(float64) == 0 {
|
||||||
@@ -282,15 +282,23 @@ func downloadFileFromServer(providerURL string) (filename string, body []byte, e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := http.Get(providerURL)
|
req, err := http.NewRequest(http.MethodGet, providerURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Header.Set("User-Agent", Settings.UserAgent)
|
req.Header.Set("User-Agent", getUserAgent())
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
err = fmt.Errorf(fmt.Sprintf("%d: %s "+http.StatusText(resp.StatusCode), resp.StatusCode, providerURL))
|
err = fmt.Errorf("%d: %s %s", resp.StatusCode, providerURL, http.StatusText(resp.StatusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func showInfo(str string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var max = 22
|
var max = 23
|
||||||
var msg = strings.SplitN(str, ":", 2)
|
var msg = strings.SplitN(str, ":", 2)
|
||||||
var length = len(msg[0])
|
var length = len(msg[0])
|
||||||
var space string
|
var space string
|
||||||
@@ -48,7 +48,7 @@ func showDebug(str string, level int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var max = 22
|
var max = 23
|
||||||
var msg = strings.SplitN(str, ":", 2)
|
var msg = strings.SplitN(str, ":", 2)
|
||||||
var length = len(msg[0])
|
var length = len(msg[0])
|
||||||
var space string
|
var space string
|
||||||
@@ -78,7 +78,7 @@ func showDebug(str string, level int) {
|
|||||||
|
|
||||||
func showHighlight(str string) {
|
func showHighlight(str string) {
|
||||||
|
|
||||||
var max = 22
|
var max = 23
|
||||||
var msg = strings.SplitN(str, ":", 2)
|
var msg = strings.SplitN(str, ":", 2)
|
||||||
var length = len(msg[0])
|
var length = len(msg[0])
|
||||||
var space string
|
var space string
|
||||||
@@ -232,7 +232,7 @@ func getErrMsg(errCode int) (errMsg string) {
|
|||||||
case 1004:
|
case 1004:
|
||||||
errMsg = fmt.Sprintf("File not found")
|
errMsg = fmt.Sprintf("File not found")
|
||||||
case 1005:
|
case 1005:
|
||||||
errMsg = fmt.Sprintf("Invalide m3u")
|
errMsg = fmt.Sprintf("Invalid M3U file, an extended M3U file is required.")
|
||||||
case 1006:
|
case 1006:
|
||||||
errMsg = fmt.Sprintf("No playlist!")
|
errMsg = fmt.Sprintf("No playlist!")
|
||||||
case 1007:
|
case 1007:
|
||||||
@@ -300,9 +300,9 @@ func getErrMsg(errCode int) (errMsg string) {
|
|||||||
|
|
||||||
// Warnings
|
// Warnings
|
||||||
case 2000:
|
case 2000:
|
||||||
errMsg = fmt.Sprintf("Plex can not handle more than %d streams. If you do not use Plex, you can ignore this warning.", System.DVRLimit)
|
errMsg = fmt.Sprintf("Plex can not handle more than %d streams. If you do not use Plex, you can ignore this warning.", System.PlexChannelLimit)
|
||||||
case 2001:
|
case 2001:
|
||||||
errMsg = fmt.Sprintf("%s has loaded more than %d streams. Use the filter to reduce the number of streams.", System.Name, System.DVRLimit)
|
errMsg = fmt.Sprintf("%s has loaded more than %d streams. Use the filter to reduce the number of streams.", System.Name, System.UnfilteredChannelLimit)
|
||||||
case 2002:
|
case 2002:
|
||||||
errMsg = fmt.Sprintf("PMS can not play m3u8 streams")
|
errMsg = fmt.Sprintf("PMS can not play m3u8 streams")
|
||||||
case 2003:
|
case 2003:
|
||||||
@@ -323,7 +323,7 @@ func getErrMsg(errCode int) (errMsg string) {
|
|||||||
|
|
||||||
// Tuner
|
// Tuner
|
||||||
case 2105:
|
case 2105:
|
||||||
errMsg = fmt.Sprintf("The number of tuners has changed, you have to delete " + System.Name + " in Plex / Emby HDHR and set it up again.")
|
errMsg = "The number of tuners has changed, you have to delete " + System.Name + " in Plex / Emby HDHR and set it up again."
|
||||||
case 2106:
|
case 2106:
|
||||||
errMsg = fmt.Sprintf("This function is only available with XEPG as EPG source")
|
errMsg = fmt.Sprintf("This function is only available with XEPG as EPG source")
|
||||||
|
|
||||||
|
|||||||
@@ -47,11 +47,7 @@ type LineupStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lineup : HDHR Lineup /lineup.json
|
// Lineup : HDHR Lineup /lineup.json
|
||||||
type Lineup []interface {
|
type Lineup []any
|
||||||
//GuideName string `json:"GuideName"`
|
|
||||||
//GuideNumber string `json:"GuideNumber"`
|
|
||||||
//URL string `json:"URL"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// LineupStream : HDHR einzelner Stream im Lineup
|
// LineupStream : HDHR einzelner Stream im Lineup
|
||||||
type LineupStream struct {
|
type LineupStream struct {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package src
|
package src
|
||||||
|
|
||||||
|
import "xteve/src/internal/imgcache"
|
||||||
|
|
||||||
// SystemStruct : Beinhaltet alle Systeminformationen
|
// SystemStruct : Beinhaltet alle Systeminformationen
|
||||||
type SystemStruct struct {
|
type SystemStruct struct {
|
||||||
Addresses struct {
|
Addresses struct {
|
||||||
@@ -8,19 +10,20 @@ type SystemStruct struct {
|
|||||||
XML string
|
XML string
|
||||||
}
|
}
|
||||||
|
|
||||||
APIVersion string
|
APIVersion string
|
||||||
AppName string
|
AppName string
|
||||||
ARCH string
|
ARCH string
|
||||||
BackgroundProcess bool
|
BackgroundProcess bool
|
||||||
Branch string
|
Branch string
|
||||||
Build string
|
Build string
|
||||||
Compatibility string
|
Compatibility string
|
||||||
ConfigurationWizard bool
|
ConfigurationWizard bool
|
||||||
DBVersion string
|
DBVersion string
|
||||||
Dev bool
|
Dev bool
|
||||||
DeviceID string
|
DeviceID string
|
||||||
Domain string
|
Domain string
|
||||||
DVRLimit int
|
PlexChannelLimit int
|
||||||
|
UnfilteredChannelLimit int
|
||||||
|
|
||||||
FFmpeg struct {
|
FFmpeg struct {
|
||||||
DefaultOptions string
|
DefaultOptions string
|
||||||
@@ -42,6 +45,10 @@ type SystemStruct struct {
|
|||||||
XML string
|
XML string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Compressed struct {
|
||||||
|
GZxml string
|
||||||
|
}
|
||||||
|
|
||||||
Flag struct {
|
Flag struct {
|
||||||
Branch string
|
Branch string
|
||||||
Debug int
|
Debug int
|
||||||
@@ -95,6 +102,7 @@ type SystemStruct struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
URLBase string
|
URLBase string
|
||||||
|
UDPxy string
|
||||||
Version string
|
Version string
|
||||||
WEB struct {
|
WEB struct {
|
||||||
Menu []string
|
Menu []string
|
||||||
@@ -110,6 +118,7 @@ type GitStruct struct {
|
|||||||
// DataStruct : Alle Daten werden hier abgelegt. (Lineup, XMLTV)
|
// DataStruct : Alle Daten werden hier abgelegt. (Lineup, XMLTV)
|
||||||
type DataStruct struct {
|
type DataStruct struct {
|
||||||
Cache struct {
|
Cache struct {
|
||||||
|
Images *imgcache.Cache
|
||||||
ImagesCache []string
|
ImagesCache []string
|
||||||
ImagesFiles []string
|
ImagesFiles []string
|
||||||
ImagesURLS []string
|
ImagesURLS []string
|
||||||
@@ -140,18 +149,18 @@ type DataStruct struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Streams struct {
|
Streams struct {
|
||||||
Active []interface{}
|
Active []any
|
||||||
All []interface{}
|
All []any
|
||||||
Inactive []interface{}
|
Inactive []any
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLTV struct {
|
XMLTV struct {
|
||||||
Files []string
|
Files []string
|
||||||
Mapping map[string]interface{}
|
Mapping map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
XEPG struct {
|
XEPG struct {
|
||||||
Channels map[string]interface{}
|
Channels map[string]any
|
||||||
XEPGCount int64
|
XEPGCount int64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,9 +251,12 @@ type Notification struct {
|
|||||||
Type string `json:"type,required"`
|
Type string `json:"type,required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SettingsStrcut : Inhalt der settings.json
|
// SettingsStruct : Inhalt der settings.json
|
||||||
type SettingsStrcut struct {
|
type SettingsStruct struct {
|
||||||
API bool `json:"api"`
|
API bool `json:"api"`
|
||||||
|
UsePlexAPI bool `json:"use_plexAPI"`
|
||||||
|
PlexURL string `json:"plex.url"`
|
||||||
|
PlexToken string `json:"plex.token"`
|
||||||
AuthenticationAPI bool `json:"authentication.api"`
|
AuthenticationAPI bool `json:"authentication.api"`
|
||||||
AuthenticationM3U bool `json:"authentication.m3u"`
|
AuthenticationM3U bool `json:"authentication.m3u"`
|
||||||
AuthenticationPMS bool `json:"authentication.pms"`
|
AuthenticationPMS bool `json:"authentication.pms"`
|
||||||
@@ -266,31 +278,32 @@ type SettingsStrcut struct {
|
|||||||
FileXMLTV []string `json:"xmltv,omitempty"` // Altes Speichersystem der Provider XML Datei Slice (Wird für die Umwandlung auf das neue benötigt)
|
FileXMLTV []string `json:"xmltv,omitempty"` // Altes Speichersystem der Provider XML Datei Slice (Wird für die Umwandlung auf das neue benötigt)
|
||||||
|
|
||||||
Files struct {
|
Files struct {
|
||||||
HDHR map[string]interface{} `json:"hdhr"`
|
HDHR map[string]any `json:"hdhr"`
|
||||||
M3U map[string]interface{} `json:"m3u"`
|
M3U map[string]any `json:"m3u"`
|
||||||
XMLTV map[string]interface{} `json:"xmltv"`
|
XMLTV map[string]any `json:"xmltv"`
|
||||||
} `json:"files"`
|
} `json:"files"`
|
||||||
|
|
||||||
FilesUpdate bool `json:"files.update"`
|
FilesUpdate bool `json:"files.update"`
|
||||||
Filter map[int64]interface{} `json:"filter"`
|
Filter map[int64]any `json:"filter"`
|
||||||
Key string `json:"key,omitempty"`
|
Key string `json:"key,omitempty"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
LogEntriesRAM int `json:"log.entries.ram"`
|
LogEntriesRAM int `json:"log.entries.ram"`
|
||||||
M3U8AdaptiveBandwidthMBPS int `json:"m3u8.adaptive.bandwidth.mbps"`
|
M3U8AdaptiveBandwidthMBPS int `json:"m3u8.adaptive.bandwidth.mbps"`
|
||||||
MappingFirstChannel float64 `json:"mapping.first.channel"`
|
MappingFirstChannel float64 `json:"mapping.first.channel"`
|
||||||
Port string `json:"port"`
|
Port string `json:"port"`
|
||||||
SSDP bool `json:"ssdp"`
|
SSDP bool `json:"ssdp"`
|
||||||
SchemeM3U string `json:"scheme.m3u"`
|
TempPath string `json:"temp.path"`
|
||||||
SchemeXML string `json:"scheme.xml"`
|
Tuner int `json:"tuner"`
|
||||||
TempPath string `json:"temp.path"`
|
Update []string `json:"update"`
|
||||||
Tuner int `json:"tuner"`
|
UpdateURL string `json:"update.url,omitempty"`
|
||||||
Update []string `json:"update"`
|
UserAgent string `json:"user.agent"`
|
||||||
UpdateURL string `json:"update.url,omitempty"`
|
UUID string `json:"uuid"`
|
||||||
UserAgent string `json:"user.agent"`
|
UDPxy string `json:"udpxy"`
|
||||||
UUID string `json:"uuid"`
|
Version string `json:"version"`
|
||||||
Version string `json:"version"`
|
XepgMissingEPGMode string `json:"xepg.missing.epg.mode"`
|
||||||
XepgReplaceMissingImages bool `json:"xepg.replace.missing.images"`
|
XepgReplaceMissingImages bool `json:"xepg.replace.missing.images"`
|
||||||
XteveAutoUpdate bool `json:"xteveAutoUpdate"`
|
XteveAutoUpdate bool `json:"xteveAutoUpdate"`
|
||||||
|
WizardCompleted bool `json:"wizard.completed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LanguageUI : Sprache für das WebUI
|
// LanguageUI : Sprache für das WebUI
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ type RequestStruct struct {
|
|||||||
Cmd string `json:"cmd,required"`
|
Cmd string `json:"cmd,required"`
|
||||||
|
|
||||||
// Benutzer
|
// Benutzer
|
||||||
DeleteUser bool `json:"deleteUser,omitempty"`
|
DeleteUser bool `json:"deleteUser,omitempty"`
|
||||||
UserData map[string]interface{} `json:"userData,omitempty"`
|
UserData map[string]any `json:"userData,omitempty"`
|
||||||
|
|
||||||
// Mapping
|
// Mapping
|
||||||
EpgMapping map[string]interface{} `json:"epgMapping,omitempty"`
|
EpgMapping map[string]any `json:"epgMapping,omitempty"`
|
||||||
|
|
||||||
// Restore
|
// Restore
|
||||||
Base64 string `json:"base64,omitempty"`
|
Base64 string `json:"base64,omitempty"`
|
||||||
@@ -18,6 +18,9 @@ type RequestStruct struct {
|
|||||||
// Neue Werte für die Einstellungen (settings.json)
|
// Neue Werte für die Einstellungen (settings.json)
|
||||||
Settings struct {
|
Settings struct {
|
||||||
API *bool `json:"api,omitempty"`
|
API *bool `json:"api,omitempty"`
|
||||||
|
UsePlexAPI *bool `json:"use_plexAPI,omitempty"`
|
||||||
|
PlexURL *string `json:"plex.url,omitempty"`
|
||||||
|
PlexToken *string `json:"plex.token,omitempty"`
|
||||||
AuthenticationAPI *bool `json:"authentication.api,omitempty"`
|
AuthenticationAPI *bool `json:"authentication.api,omitempty"`
|
||||||
AuthenticationM3U *bool `json:"authentication.m3u,omitempty"`
|
AuthenticationM3U *bool `json:"authentication.m3u,omitempty"`
|
||||||
AuthenticationPMS *bool `json:"authentication.pms,omitempty"`
|
AuthenticationPMS *bool `json:"authentication.pms,omitempty"`
|
||||||
@@ -26,7 +29,7 @@ type RequestStruct struct {
|
|||||||
BackupKeep *int `json:"backup.keep,omitempty"`
|
BackupKeep *int `json:"backup.keep,omitempty"`
|
||||||
BackupPath *string `json:"backup.path,omitempty"`
|
BackupPath *string `json:"backup.path,omitempty"`
|
||||||
Buffer *string `json:"buffer,omitempty"`
|
Buffer *string `json:"buffer,omitempty"`
|
||||||
BufferSize *int `json:"buffer.size.kb, omitempty"`
|
BufferSize *int `json:"buffer.size.kb,omitempty"`
|
||||||
BufferTimeout *float64 `json:"buffer.timeout,omitempty"`
|
BufferTimeout *float64 `json:"buffer.timeout,omitempty"`
|
||||||
CacheImages *bool `json:"cache.images,omitempty"`
|
CacheImages *bool `json:"cache.images,omitempty"`
|
||||||
EpgSource *string `json:"epgSource,omitempty"`
|
EpgSource *string `json:"epgSource,omitempty"`
|
||||||
@@ -37,26 +40,28 @@ type RequestStruct struct {
|
|||||||
FilesUpdate *bool `json:"files.update,omitempty"`
|
FilesUpdate *bool `json:"files.update,omitempty"`
|
||||||
TempPath *string `json:"temp.path,omitempty"`
|
TempPath *string `json:"temp.path,omitempty"`
|
||||||
Tuner *int `json:"tuner,omitempty"`
|
Tuner *int `json:"tuner,omitempty"`
|
||||||
|
UDPxy *string `json:"udpxy,omitempty"`
|
||||||
Update *[]string `json:"update,omitempty"`
|
Update *[]string `json:"update,omitempty"`
|
||||||
UserAgent *string `json:"user.agent,omitempty"`
|
UserAgent *string `json:"user.agent,omitempty"`
|
||||||
|
XepgMissingEPGMode *string `json:"xepg.missing.epg.mode,omitempty"`
|
||||||
XepgReplaceMissingImages *bool `json:"xepg.replace.missing.images,omitempty"`
|
XepgReplaceMissingImages *bool `json:"xepg.replace.missing.images,omitempty"`
|
||||||
XteveAutoUpdate *bool `json:"xteveAutoUpdate,omitempty"`
|
XteveAutoUpdate *bool `json:"xteveAutoUpdate,omitempty"`
|
||||||
SchemeM3U *string `json:"scheme.m3u,omitempty"`
|
SchemeM3U *string `json:"scheme.m3u,omitempty"`
|
||||||
SchemeXML *string `json:"scheme.xml,omitempty"`
|
SchemeXML *string `json:"scheme.xml,omitempty"`
|
||||||
} `json:"settings,omitempty"`
|
} `json:"settings"`
|
||||||
|
|
||||||
// Upload Logo
|
// Upload Logo
|
||||||
Filename string `json:"filename,omitempty"`
|
Filename string `json:"filename,omitempty"`
|
||||||
|
|
||||||
// Filter
|
// Filter
|
||||||
Filter map[int64]interface{} `json:"filter,omitempty"`
|
Filter map[int64]any `json:"filter,omitempty"`
|
||||||
|
|
||||||
// Dateien (M3U, HDHR, XMLTV)
|
// Dateien (M3U, HDHR, XMLTV)
|
||||||
Files struct {
|
Files struct {
|
||||||
HDHR map[string]interface{} `json:"hdhr,omitempty"`
|
HDHR map[string]any `json:"hdhr,omitempty"`
|
||||||
M3U map[string]interface{} `json:"m3u,omitempty"`
|
M3U map[string]any `json:"m3u,omitempty"`
|
||||||
XMLTV map[string]interface{} `json:"xmltv,omitempty"`
|
XMLTV map[string]any `json:"xmltv,omitempty"`
|
||||||
} `json:"files,omitempty"`
|
} `json:"files"`
|
||||||
|
|
||||||
// Wizard
|
// Wizard
|
||||||
Wizard struct {
|
Wizard struct {
|
||||||
@@ -64,7 +69,7 @@ type RequestStruct struct {
|
|||||||
M3U *string `json:"m3u,omitempty"`
|
M3U *string `json:"m3u,omitempty"`
|
||||||
Tuner *int `json:"tuner,omitempty"`
|
Tuner *int `json:"tuner,omitempty"`
|
||||||
XMLTV *string `json:"xmltv,omitempty"`
|
XMLTV *string `json:"xmltv,omitempty"`
|
||||||
} `json:"wizard,omitempty"`
|
} `json:"wizard"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResponseStruct : Antworten an den Client (WEB)
|
// ResponseStruct : Antworten an den Client (WEB)
|
||||||
@@ -83,7 +88,7 @@ type ResponseStruct struct {
|
|||||||
Warnings int `json:"warnings"`
|
Warnings int `json:"warnings"`
|
||||||
XEPGCount int64 `json:"xepg"`
|
XEPGCount int64 `json:"xepg"`
|
||||||
XML string `json:"xepg-url,required"`
|
XML string `json:"xepg-url,required"`
|
||||||
} `json:"clientInfo,omitempty"`
|
} `json:"clientInfo"`
|
||||||
|
|
||||||
Data struct {
|
Data struct {
|
||||||
Playlist struct {
|
Playlist struct {
|
||||||
@@ -101,20 +106,20 @@ type ResponseStruct struct {
|
|||||||
}
|
}
|
||||||
} `json:"data,required"`
|
} `json:"data,required"`
|
||||||
|
|
||||||
Alert string `json:"alert,omitempty"`
|
Alert string `json:"alert,omitempty"`
|
||||||
ConfigurationWizard bool `json:"configurationWizard,required"`
|
ConfigurationWizard bool `json:"configurationWizard,required"`
|
||||||
Error string `json:"err,omitempty"`
|
Error string `json:"err,omitempty"`
|
||||||
Log WebScreenLogStruct `json:"log,required"`
|
Log WebScreenLogStruct `json:"log,required"`
|
||||||
LogoURL string `json:"logoURL,omitempty"`
|
LogoURL string `json:"logoURL,omitempty"`
|
||||||
OpenLink string `json:"openLink,omitempty"`
|
OpenLink string `json:"openLink,omitempty"`
|
||||||
OpenMenu string `json:"openMenu,omitempty"`
|
OpenMenu string `json:"openMenu,omitempty"`
|
||||||
Reload bool `json:"reload,omitempty"`
|
Reload bool `json:"reload,omitempty"`
|
||||||
Settings SettingsStrcut `json:"settings,required"`
|
Settings SettingsStruct `json:"settings,required"`
|
||||||
Status bool `json:"status,required"`
|
Status bool `json:"status,required"`
|
||||||
Token string `json:"token,omitempty"`
|
Token string `json:"token,omitempty"`
|
||||||
Users map[string]interface{} `json:"users,omitempty"`
|
Users map[string]any `json:"users,omitempty"`
|
||||||
Wizard int `json:"wizard,omitempty"`
|
Wizard int `json:"wizard,omitempty"`
|
||||||
XEPG map[string]interface{} `json:"xepg,required"`
|
XEPG map[string]any `json:"xepg,required"`
|
||||||
|
|
||||||
Notification map[string]Notification `json:"notification,omitempty"`
|
Notification map[string]Notification `json:"notification,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ type Program struct {
|
|||||||
Country []*Country `xml:"country"`
|
Country []*Country `xml:"country"`
|
||||||
EpisodeNum []*EpisodeNum `xml:"episode-num"`
|
EpisodeNum []*EpisodeNum `xml:"episode-num"`
|
||||||
Poster []Poster `xml:"icon"`
|
Poster []Poster `xml:"icon"`
|
||||||
|
Credits Credits `xml:"credits,omitempty"` //`xml:",innerxml,omitempty"`
|
||||||
|
Rating []Rating `xml:"rating"`
|
||||||
|
StarRating []StarRating `xml:"star-rating"`
|
||||||
Language []*Language `xml:"language"`
|
Language []*Language `xml:"language"`
|
||||||
Video Video `xml:"video"`
|
Video Video `xml:"video"`
|
||||||
Date string `xml:"date"`
|
Date string `xml:"date"`
|
||||||
@@ -75,6 +78,19 @@ type Category struct {
|
|||||||
Value string `xml:",chardata"`
|
Value string `xml:",chardata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rating : Bewertung
|
||||||
|
type Rating struct {
|
||||||
|
System string `xml:"system,attr"`
|
||||||
|
Value string `xml:"value"`
|
||||||
|
Icon []Icon `xml:"icon"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StarRating : Bewertung / Kritiken
|
||||||
|
type StarRating struct {
|
||||||
|
Value string `xml:"value"`
|
||||||
|
System string `xml:"system,attr"`
|
||||||
|
}
|
||||||
|
|
||||||
// Language : Sprachen
|
// Language : Sprachen
|
||||||
type Language struct {
|
type Language struct {
|
||||||
Value string `xml:",chardata"`
|
Value string `xml:",chardata"`
|
||||||
@@ -100,6 +116,41 @@ type Poster struct {
|
|||||||
Width string `xml:"width,attr"`
|
Width string `xml:"width,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Credits : Credits
|
||||||
|
type Credits struct {
|
||||||
|
Director []Director `xml:"director,omitempty"`
|
||||||
|
Actor []Actor `xml:"actor,omitempty"`
|
||||||
|
Writer []Writer `xml:"writer,omitempty"`
|
||||||
|
Presenter []Presenter `xml:"presenter,omitempty"`
|
||||||
|
Producer []Producer `xml:"producer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Director : Director
|
||||||
|
type Director struct {
|
||||||
|
Value string `xml:",chardata"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actor : Actor
|
||||||
|
type Actor struct {
|
||||||
|
Value string `xml:",chardata"`
|
||||||
|
Role string `xml:"role,attr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Writer : Writer
|
||||||
|
type Writer struct {
|
||||||
|
Value string `xml:",chardata"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Presenter : Presenter
|
||||||
|
type Presenter struct {
|
||||||
|
Value string `xml:",chardata"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Producer : Producer
|
||||||
|
type Producer struct {
|
||||||
|
Value string `xml:",chardata"`
|
||||||
|
}
|
||||||
|
|
||||||
// Video : Video Metadaten
|
// Video : Video Metadaten
|
||||||
type Video struct {
|
type Video struct {
|
||||||
Aspect string `xml:"aspect,omitempty"`
|
Aspect string `xml:"aspect,omitempty"`
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func createSystemFiles() (err error) {
|
|||||||
err = checkFile(filename)
|
err = checkFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Datei existiert nicht, wird jetzt erstellt
|
// Datei existiert nicht, wird jetzt erstellt
|
||||||
err = saveMapToJSONFile(filename, make(map[string]interface{}))
|
err = saveMapToJSONFile(filename, make(map[string]any))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -90,22 +90,35 @@ func createSystemFiles() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Einstellungen laden und default Werte setzen (xTeVe)
|
// Einstellungen laden und default Werte setzen (xTeVe)
|
||||||
func loadSettings() (settings SettingsStrcut, err error) {
|
func loadSettings() (settings SettingsStruct, err error) {
|
||||||
|
|
||||||
settingsMap, err := loadJSONFileToMap(System.File.Settings)
|
settingsMap, err := loadJSONFileToMap(System.File.Settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deafult Werte setzten
|
var freshInstall = len(settingsMap) == 0
|
||||||
var defaults = make(map[string]interface{})
|
|
||||||
var dataMap = make(map[string]interface{})
|
|
||||||
|
|
||||||
dataMap["xmltv"] = make(map[string]interface{})
|
// Deafult Werte setzten
|
||||||
dataMap["m3u"] = make(map[string]interface{})
|
var defaults = make(map[string]any)
|
||||||
dataMap["hdhr"] = make(map[string]interface{})
|
var dataMap = make(map[string]any)
|
||||||
|
|
||||||
|
dataMap["xmltv"] = make(map[string]any)
|
||||||
|
dataMap["m3u"] = make(map[string]any)
|
||||||
|
dataMap["hdhr"] = make(map[string]any)
|
||||||
|
|
||||||
|
defaultFFmpegPath := ""
|
||||||
|
if len(os.Getenv("XTEVE_CONFIG")) > 0 {
|
||||||
|
containerFFmpegPath := "/usr/local/bin/ffmpeg"
|
||||||
|
if checkFile(containerFFmpegPath) == nil {
|
||||||
|
defaultFFmpegPath = containerFFmpegPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defaults["api"] = false
|
defaults["api"] = false
|
||||||
|
defaults["use_plexAPI"] = false
|
||||||
|
defaults["plex.url"] = ""
|
||||||
|
defaults["plex.token"] = ""
|
||||||
defaults["authentication.api"] = false
|
defaults["authentication.api"] = false
|
||||||
defaults["authentication.m3u"] = false
|
defaults["authentication.m3u"] = false
|
||||||
defaults["authentication.pms"] = false
|
defaults["authentication.pms"] = false
|
||||||
@@ -118,28 +131,34 @@ func loadSettings() (settings SettingsStrcut, err error) {
|
|||||||
defaults["buffer.timeout"] = 500
|
defaults["buffer.timeout"] = 500
|
||||||
defaults["cache.images"] = false
|
defaults["cache.images"] = false
|
||||||
defaults["epgSource"] = "PMS"
|
defaults["epgSource"] = "PMS"
|
||||||
|
defaults["ffmpeg.path"] = defaultFFmpegPath
|
||||||
defaults["ffmpeg.options"] = System.FFmpeg.DefaultOptions
|
defaults["ffmpeg.options"] = System.FFmpeg.DefaultOptions
|
||||||
defaults["vlc.options"] = System.VLC.DefaultOptions
|
defaults["vlc.options"] = System.VLC.DefaultOptions
|
||||||
defaults["files"] = dataMap
|
defaults["files"] = dataMap
|
||||||
defaults["files.update"] = true
|
defaults["files.update"] = true
|
||||||
defaults["filter"] = make(map[string]interface{})
|
defaults["filter"] = make(map[string]any)
|
||||||
defaults["git.branch"] = System.Branch
|
defaults["git.branch"] = System.Branch
|
||||||
defaults["language"] = "en"
|
defaults["language"] = "en"
|
||||||
defaults["log.entries.ram"] = 500
|
defaults["log.entries.ram"] = 500
|
||||||
defaults["mapping.first.channel"] = 1000
|
defaults["mapping.first.channel"] = 1000
|
||||||
|
defaults["xepg.missing.epg.mode"] = "strict"
|
||||||
defaults["xepg.replace.missing.images"] = true
|
defaults["xepg.replace.missing.images"] = true
|
||||||
defaults["m3u8.adaptive.bandwidth.mbps"] = 10
|
defaults["m3u8.adaptive.bandwidth.mbps"] = 10
|
||||||
defaults["port"] = "34400"
|
defaults["port"] = "34400"
|
||||||
defaults["ssdp"] = true
|
defaults["ssdp"] = true
|
||||||
defaults["tuner"] = 1
|
defaults["tuner"] = 1
|
||||||
defaults["update"] = []string{"0000"}
|
defaults["update"] = []string{"0000"}
|
||||||
defaults["user.agent"] = System.Name
|
defaults["user.agent"] = defaultUserAgent
|
||||||
defaults["uuid"] = createUUID()
|
defaults["uuid"] = createUUID()
|
||||||
|
defaults["udpxy"] = ""
|
||||||
defaults["version"] = System.DBVersion
|
defaults["version"] = System.DBVersion
|
||||||
defaults["xteveAutoUpdate"] = true
|
defaults["xteveAutoUpdate"] = true
|
||||||
defaults["temp.path"] = System.Folder.Temp
|
defaults["wizard.completed"] = !freshInstall
|
||||||
defaults["scheme.M3U"] = "HTTP"
|
var defaultTempPath = System.Folder.Temp
|
||||||
defaults["scheme.XML"] = "HTTP"
|
if len(os.Getenv("XTEVE_CONFIG")) > 0 {
|
||||||
|
defaultTempPath = System.Folder.Config + "tmp" + string(os.PathSeparator)
|
||||||
|
}
|
||||||
|
defaults["temp.path"] = defaultTempPath
|
||||||
|
|
||||||
// Default Werte setzen
|
// Default Werte setzen
|
||||||
for key, value := range defaults {
|
for key, value := range defaults {
|
||||||
@@ -164,7 +183,12 @@ func loadSettings() (settings SettingsStrcut, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(settings.FFmpegPath) == 0 {
|
if len(settings.FFmpegPath) == 0 {
|
||||||
settings.FFmpegPath = searchFileInOS("ffmpeg")
|
containerFFmpegPath := "/usr/local/bin/ffmpeg"
|
||||||
|
if len(os.Getenv("XTEVE_CONFIG")) > 0 && checkFile(containerFFmpegPath) == nil {
|
||||||
|
settings.FFmpegPath = containerFFmpegPath
|
||||||
|
} else {
|
||||||
|
settings.FFmpegPath = searchFileInOS("ffmpeg")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(settings.VLCPath) == 0 {
|
if len(settings.VLCPath) == 0 {
|
||||||
@@ -188,7 +212,7 @@ func loadSettings() (settings SettingsStrcut, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Einstellungen speichern (xTeVe)
|
// Einstellungen speichern (xTeVe)
|
||||||
func saveSettings(settings SettingsStrcut) (err error) {
|
func saveSettings(settings SettingsStruct) (err error) {
|
||||||
|
|
||||||
if settings.BackupKeep == 0 {
|
if settings.BackupKeep == 0 {
|
||||||
settings.BackupKeep = 10
|
settings.BackupKeep = 10
|
||||||
@@ -202,8 +226,36 @@ func saveSettings(settings SettingsStrcut) (err error) {
|
|||||||
settings.BufferTimeout = 0
|
settings.BufferTimeout = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var userAgent = strings.TrimSpace(settings.UserAgent)
|
||||||
|
if len(userAgent) == 0 || userAgent == System.Name {
|
||||||
|
settings.UserAgent = defaultUserAgent
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.XepgMissingEPGMode = strings.ToLower(strings.TrimSpace(settings.XepgMissingEPGMode))
|
||||||
|
if settings.XepgMissingEPGMode != "relaxed" {
|
||||||
|
settings.XepgMissingEPGMode = "strict"
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.TempPath = strings.TrimRight(settings.TempPath, string(os.PathSeparator)) + string(os.PathSeparator)
|
||||||
System.Folder.Temp = settings.TempPath + settings.UUID + string(os.PathSeparator)
|
System.Folder.Temp = settings.TempPath + settings.UUID + string(os.PathSeparator)
|
||||||
|
|
||||||
|
err = checkFolder(System.Folder.Temp)
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
fallbackTempPath := System.Folder.Config + "tmp" + string(os.PathSeparator)
|
||||||
|
fallbackTempFolder := fallbackTempPath + settings.UUID + string(os.PathSeparator)
|
||||||
|
fallbackErr := checkFolder(fallbackTempFolder)
|
||||||
|
|
||||||
|
if fallbackErr != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.TempPath = fallbackTempPath
|
||||||
|
System.Folder.Temp = fallbackTempFolder
|
||||||
|
showInfo(fmt.Sprintf("Temporary Folder:Fallback to %s", getPlatformPath(System.Folder.Temp)))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
err = writeByteToFile(System.File.Settings, []byte(mapToJSON(settings)))
|
err = writeByteToFile(System.File.Settings, []byte(mapToJSON(settings)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -254,14 +306,6 @@ func setGlobalDomain(domain string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func setURLScheme() {
|
|
||||||
|
|
||||||
System.ServerProtocol.M3U = strings.ToLower(Settings.SchemeM3U)
|
|
||||||
System.ServerProtocol.XML = strings.ToLower(Settings.SchemeXML)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UUID generieren
|
// UUID generieren
|
||||||
func createUUID() (uuid string) {
|
func createUUID() (uuid string) {
|
||||||
uuid = time.Now().Format("2006-01") + "-" + randomString(4) + "-" + randomString(6)
|
uuid = time.Now().Format("2006-01") + "-" + randomString(4) + "-" + randomString(6)
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ func searchFileInOS(file string) (path string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
func removeChildItems(dir string) error {
|
func removeChildItems(dir string) error {
|
||||||
|
|
||||||
files, err := filepath.Glob(filepath.Join(dir, "*"))
|
files, err := filepath.Glob(filepath.Join(dir, "*"))
|
||||||
@@ -180,7 +179,7 @@ func removeChildItems(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JSON
|
// JSON
|
||||||
func mapToJSON(tmpMap interface{}) string {
|
func mapToJSON(tmpMap any) string {
|
||||||
|
|
||||||
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -190,30 +189,30 @@ func mapToJSON(tmpMap interface{}) string {
|
|||||||
return string(jsonString)
|
return string(jsonString)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonToMap(content string) map[string]interface{} {
|
func jsonToMap(content string) map[string]any {
|
||||||
|
|
||||||
var tmpMap = make(map[string]interface{})
|
var tmpMap = make(map[string]any)
|
||||||
json.Unmarshal([]byte(content), &tmpMap)
|
json.Unmarshal([]byte(content), &tmpMap)
|
||||||
|
|
||||||
return (tmpMap)
|
return (tmpMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonToMapInt64(content string) map[int64]interface{} {
|
func jsonToMapInt64(content string) map[int64]any {
|
||||||
|
|
||||||
var tmpMap = make(map[int64]interface{})
|
var tmpMap = make(map[int64]any)
|
||||||
json.Unmarshal([]byte(content), &tmpMap)
|
json.Unmarshal([]byte(content), &tmpMap)
|
||||||
|
|
||||||
return (tmpMap)
|
return (tmpMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonToInterface(content string) (tmpMap interface{}, err error) {
|
func jsonToInterface(content string) (tmpMap any, err error) {
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(content), &tmpMap)
|
err = json.Unmarshal([]byte(content), &tmpMap)
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveMapToJSONFile(file string, tmpMap interface{}) error {
|
func saveMapToJSONFile(file string, tmpMap any) error {
|
||||||
|
|
||||||
var filename = getPlatformFile(file)
|
var filename = getPlatformFile(file)
|
||||||
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
jsonString, err := json.MarshalIndent(tmpMap, "", " ")
|
||||||
@@ -230,7 +229,7 @@ func saveMapToJSONFile(file string, tmpMap interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadJSONFileToMap(file string) (tmpMap map[string]interface{}, err error) {
|
func loadJSONFileToMap(file string) (tmpMap map[string]any, err error) {
|
||||||
|
|
||||||
f, err := os.Open(getPlatformFile(file))
|
f, err := os.Open(getPlatformFile(file))
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
@@ -360,7 +359,7 @@ func randomString(n int) string {
|
|||||||
return string(bytes)
|
return string(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTemplate(content string, tmpMap map[string]interface{}) (result string) {
|
func parseTemplate(content string, tmpMap map[string]any) (result string) {
|
||||||
|
|
||||||
t := template.Must(template.New("template").Parse(content))
|
t := template.Must(template.New("template").Parse(content))
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
up2date "../src/internal/up2date/client"
|
up2date "xteve/src/internal/up2date/client"
|
||||||
|
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
@@ -48,12 +48,12 @@ func BinaryUpdate() (err error) {
|
|||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
|
||||||
if resp.StatusCode == 404 {
|
if resp.StatusCode == 404 {
|
||||||
err = fmt.Errorf(fmt.Sprintf("Update Server: %s (%s)", http.StatusText(resp.StatusCode), gitInfo))
|
err = fmt.Errorf("Update Server: %s (%s)", http.StatusText(resp.StatusCode), gitInfo)
|
||||||
ShowError(err, 6003)
|
ShowError(err, 6003)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fmt.Errorf(fmt.Sprintf("%d: %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), gitInfo))
|
err = fmt.Errorf("%d: %s (%s)", resp.StatusCode, http.StatusText(resp.StatusCode), gitInfo)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func BinaryUpdate() (err error) {
|
|||||||
err = up2date.GetVersion()
|
err = up2date.GetVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
debug = fmt.Sprintf(err.Error())
|
debug = err.Error()
|
||||||
showDebug(debug, 1)
|
showDebug(debug, 1)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -95,7 +95,7 @@ func BinaryUpdate() (err error) {
|
|||||||
|
|
||||||
if len(updater.Response.Reason) > 0 {
|
if len(updater.Response.Reason) > 0 {
|
||||||
|
|
||||||
err = fmt.Errorf(fmt.Sprintf("Update Server: %s", updater.Response.Reason))
|
err = fmt.Errorf("Update Server: %s", updater.Response.Reason)
|
||||||
ShowError(err, 6002)
|
ShowError(err, 6002)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -192,7 +192,7 @@ checkVersion:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Neuer Filter (WebUI). Alte Filtereinstellungen werden konvertiert
|
// Neuer Filter (WebUI). Alte Filtereinstellungen werden konvertiert
|
||||||
if oldFilter, ok := settingsMap["filter"].([]interface{}); ok {
|
if oldFilter, ok := settingsMap["filter"].([]any); ok {
|
||||||
var newFilterMap = convertToNewFilter(oldFilter)
|
var newFilterMap = convertToNewFilter(oldFilter)
|
||||||
settingsMap["filter"] = newFilterMap
|
settingsMap["filter"] = newFilterMap
|
||||||
|
|
||||||
@@ -252,11 +252,11 @@ checkVersion:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertToNewFilter(oldFilter []interface{}) (newFilterMap map[int]interface{}) {
|
func convertToNewFilter(oldFilter []any) (newFilterMap map[int]any) {
|
||||||
|
|
||||||
newFilterMap = make(map[int]interface{})
|
newFilterMap = make(map[int]any)
|
||||||
|
|
||||||
switch reflect.TypeOf(oldFilter).Kind() {
|
switch reflect.TypeFor[[]any]().Kind() {
|
||||||
|
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
s := reflect.ValueOf(oldFilter)
|
s := reflect.ValueOf(oldFilter)
|
||||||
@@ -285,7 +285,7 @@ func setValueForUUID() (err error) {
|
|||||||
|
|
||||||
for _, c := range xepg {
|
for _, c := range xepg {
|
||||||
|
|
||||||
var xepgChannel = c.(map[string]interface{})
|
var xepgChannel = c.(map[string]any)
|
||||||
|
|
||||||
if uuidKey, ok := xepgChannel["_uuid.key"].(string); ok {
|
if uuidKey, ok := xepgChannel["_uuid.key"].(string); ok {
|
||||||
|
|
||||||
|
|||||||
15
src/user_agent.go
Normal file
15
src/user_agent.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package src
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
const defaultUserAgent = "otg/1.5.1 (AppleTv Apple TV 4; tvOS16.0; appletv.client) libcurl/7.58.0 OpenSSL/1.0.2o zlib/1.2.11 clib/1.8.56"
|
||||||
|
|
||||||
|
func getUserAgent() string {
|
||||||
|
|
||||||
|
var userAgent = strings.TrimSpace(Settings.UserAgent)
|
||||||
|
if len(userAgent) == 0 {
|
||||||
|
return defaultUserAgent
|
||||||
|
}
|
||||||
|
|
||||||
|
return userAgent
|
||||||
|
}
|
||||||
86
src/webUI.go
86
src/webUI.go
File diff suppressed because one or more lines are too long
@@ -10,11 +10,19 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"../src/internal/authentication"
|
"xteve/src/internal/authentication"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var wsUpgrader = websocket.Upgrader{
|
||||||
|
ReadBufferSize: 4096,
|
||||||
|
WriteBufferSize: 4096,
|
||||||
|
CheckOrigin: func(r *http.Request) bool {
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// StartWebserver : Startet den Webserver
|
// StartWebserver : Startet den Webserver
|
||||||
func StartWebserver() (err error) {
|
func StartWebserver() (err error) {
|
||||||
|
|
||||||
@@ -30,6 +38,7 @@ func StartWebserver() (err error) {
|
|||||||
http.HandleFunc("/api/", API)
|
http.HandleFunc("/api/", API)
|
||||||
http.HandleFunc("/images/", Images)
|
http.HandleFunc("/images/", Images)
|
||||||
http.HandleFunc("/data_images/", DataImages)
|
http.HandleFunc("/data_images/", DataImages)
|
||||||
|
|
||||||
//http.HandleFunc("/auto/", Auto)
|
//http.HandleFunc("/auto/", Auto)
|
||||||
|
|
||||||
showInfo("DVR IP:" + System.IPAddress + ":" + Settings.Port)
|
showInfo("DVR IP:" + System.IPAddress + ":" + Settings.Port)
|
||||||
@@ -129,6 +138,12 @@ func Stream(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If an UDPxy host is set, and the stream URL is multicast (i.e. starts with 'udp://@'),
|
||||||
|
// then streamInfo.URL needs to be rewritten to point to UDPxy.
|
||||||
|
if Settings.UDPxy != "" && strings.HasPrefix(streamInfo.URL, "udp://@") {
|
||||||
|
streamInfo.URL = fmt.Sprintf("http://%s/udp/%s/", Settings.UDPxy, strings.TrimPrefix(streamInfo.URL, "udp://@"))
|
||||||
|
}
|
||||||
|
|
||||||
switch Settings.Buffer {
|
switch Settings.Buffer {
|
||||||
|
|
||||||
case "-":
|
case "-":
|
||||||
@@ -206,7 +221,7 @@ func Auto(w http.ResponseWriter, r *http.Request) {
|
|||||||
// xTeVe : Web Server /xmltv/ und /m3u/
|
// xTeVe : Web Server /xmltv/ und /m3u/
|
||||||
func xTeVe(w http.ResponseWriter, r *http.Request) {
|
func xTeVe(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
var requestType, groupTitle, file, content string
|
var requestType, groupTitle, file, content, contentType string
|
||||||
var err error
|
var err error
|
||||||
var path = strings.TrimPrefix(r.URL.Path, "/")
|
var path = strings.TrimPrefix(r.URL.Path, "/")
|
||||||
var groups = []string{}
|
var groups = []string{}
|
||||||
@@ -216,7 +231,6 @@ func xTeVe(w http.ResponseWriter, r *http.Request) {
|
|||||||
// XMLTV Datei
|
// XMLTV Datei
|
||||||
if strings.Contains(path, "xmltv/") {
|
if strings.Contains(path, "xmltv/") {
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/xml")
|
|
||||||
requestType = "xml"
|
requestType = "xml"
|
||||||
|
|
||||||
file = System.Folder.Data + getFilenameFromPath(path)
|
file = System.Folder.Data + getFilenameFromPath(path)
|
||||||
@@ -260,6 +274,13 @@ func xTeVe(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contentType = http.DetectContentType([]byte(content))
|
||||||
|
if strings.Contains(strings.ToLower(contentType), "xml") {
|
||||||
|
contentType = "application/xml; charset=utf-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", contentType)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
w.Write([]byte(content))
|
w.Write([]byte(content))
|
||||||
}
|
}
|
||||||
@@ -323,10 +344,11 @@ func WS(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
|
conn, err := wsUpgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ShowError(err, 0)
|
ShowError(err, 0)
|
||||||
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
|
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setGlobalDomain(r.Host)
|
setGlobalDomain(r.Host)
|
||||||
@@ -544,7 +566,7 @@ func WS(w http.ResponseWriter, r *http.Request) {
|
|||||||
default:
|
default:
|
||||||
fmt.Println("+ + + + + + + + + + +", request.Cmd)
|
fmt.Println("+ + + + + + + + + + +", request.Cmd)
|
||||||
|
|
||||||
var requestMap = make(map[string]interface{}) // Debug
|
var requestMap = make(map[string]any) // Debug
|
||||||
_ = requestMap
|
_ = requestMap
|
||||||
if System.Dev == true {
|
if System.Dev == true {
|
||||||
fmt.Println(mapToJSON(requestMap))
|
fmt.Println(mapToJSON(requestMap))
|
||||||
@@ -577,7 +599,7 @@ func WS(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Web : Web Server /web/
|
// Web : Web Server /web/
|
||||||
func Web(w http.ResponseWriter, r *http.Request) {
|
func Web(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
var lang = make(map[string]interface{})
|
var lang = make(map[string]any)
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
var requestFile = strings.Replace(r.URL.Path, "/web", "html", -1)
|
var requestFile = strings.Replace(r.URL.Path, "/web", "html", -1)
|
||||||
@@ -585,6 +607,8 @@ func Web(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var language LanguageUI
|
var language LanguageUI
|
||||||
|
|
||||||
|
setGlobalDomain(r.Host)
|
||||||
|
|
||||||
if System.Dev == true {
|
if System.Dev == true {
|
||||||
|
|
||||||
lang, err = loadJSONFileToMap(fmt.Sprintf("html/lang/%s.json", Settings.Language))
|
lang, err = loadJSONFileToMap(fmt.Sprintf("html/lang/%s.json", Settings.Language))
|
||||||
@@ -613,7 +637,7 @@ func Web(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if System.ScanInProgress == 0 {
|
if System.ScanInProgress == 0 {
|
||||||
|
|
||||||
if len(Settings.Files.M3U) == 0 && len(Settings.Files.HDHR) == 0 {
|
if Settings.WizardCompleted == false && len(Settings.Files.M3U) == 0 && len(Settings.Files.HDHR) == 0 {
|
||||||
System.ConfigurationWizard = true
|
System.ConfigurationWizard = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1012,7 +1036,7 @@ func setDefaultResponseData(response ResponseStruct, data bool) (defaults Respon
|
|||||||
|
|
||||||
defaults.ClientInfo.XEPGCount = Data.XEPG.XEPGCount
|
defaults.ClientInfo.XEPGCount = Data.XEPG.XEPGCount
|
||||||
|
|
||||||
var XEPG = make(map[string]interface{})
|
var XEPG = make(map[string]any)
|
||||||
|
|
||||||
if len(Data.Streams.Active) > 0 {
|
if len(Data.Streams.Active) > 0 {
|
||||||
|
|
||||||
@@ -1021,8 +1045,8 @@ func setDefaultResponseData(response ResponseStruct, data bool) (defaults Respon
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
XEPG["epgMapping"] = make(map[string]interface{})
|
XEPG["epgMapping"] = make(map[string]any)
|
||||||
XEPG["xmltvMap"] = make(map[string]interface{})
|
XEPG["xmltvMap"] = make(map[string]any)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
473
src/xepg.go
473
src/xepg.go
@@ -8,10 +8,16 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"xteve/src/internal/imgcache"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Provider XMLTV Datei überprüfen
|
// Provider XMLTV Datei überprüfen
|
||||||
@@ -42,6 +48,13 @@ func buildXEPG(background bool) {
|
|||||||
|
|
||||||
System.ScanInProgress = 1
|
System.ScanInProgress = 1
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
Data.Cache.Images, err = imgcache.New(System.Folder.ImagesCache, fmt.Sprintf("%s://%s/images/", System.ServerProtocol.WEB, System.Domain), Settings.CacheImages)
|
||||||
|
if err != nil {
|
||||||
|
ShowError(err, 0)
|
||||||
|
}
|
||||||
|
|
||||||
if Settings.EpgSource == "XEPG" {
|
if Settings.EpgSource == "XEPG" {
|
||||||
|
|
||||||
switch background {
|
switch background {
|
||||||
@@ -56,10 +69,31 @@ func buildXEPG(background bool) {
|
|||||||
cleanupXEPG()
|
cleanupXEPG()
|
||||||
createXMLTVFile()
|
createXMLTVFile()
|
||||||
createM3UFile()
|
createM3UFile()
|
||||||
go cachingImages()
|
queuePlexGuideRefresh("xepg rebuild")
|
||||||
|
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
||||||
|
|
||||||
|
if Settings.CacheImages == true && System.ImageCachingInProgress == 0 {
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
|
||||||
|
System.ImageCachingInProgress = 1
|
||||||
|
showInfo(fmt.Sprintf("Image Caching:Images are cached (%d)", len(Data.Cache.Images.Queue)))
|
||||||
|
|
||||||
|
Data.Cache.Images.Image.Caching()
|
||||||
|
Data.Cache.Images.Image.Remove()
|
||||||
|
showInfo("Image Caching:Done")
|
||||||
|
|
||||||
|
createXMLTVFile()
|
||||||
|
createM3UFile()
|
||||||
|
queuePlexGuideRefresh("xepg image cache refresh")
|
||||||
|
|
||||||
|
System.ImageCachingInProgress = 0
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
System.ScanInProgress = 0
|
System.ScanInProgress = 0
|
||||||
|
|
||||||
// Cache löschen
|
// Cache löschen
|
||||||
@@ -82,7 +116,29 @@ func buildXEPG(background bool) {
|
|||||||
|
|
||||||
createXMLTVFile()
|
createXMLTVFile()
|
||||||
createM3UFile()
|
createM3UFile()
|
||||||
go cachingImages()
|
queuePlexGuideRefresh("xepg rebuild")
|
||||||
|
|
||||||
|
if Settings.CacheImages == true && System.ImageCachingInProgress == 0 {
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
|
||||||
|
System.ImageCachingInProgress = 1
|
||||||
|
showInfo(fmt.Sprintf("Image Caching:Images are cached (%d)", len(Data.Cache.Images.Queue)))
|
||||||
|
|
||||||
|
Data.Cache.Images.Image.Caching()
|
||||||
|
Data.Cache.Images.Image.Remove()
|
||||||
|
showInfo("Image Caching:Done")
|
||||||
|
|
||||||
|
createXMLTVFile()
|
||||||
|
createM3UFile()
|
||||||
|
queuePlexGuideRefresh("xepg image cache refresh")
|
||||||
|
|
||||||
|
System.ImageCachingInProgress = 0
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
||||||
|
|
||||||
System.ScanInProgress = 0
|
System.ScanInProgress = 0
|
||||||
@@ -128,6 +184,7 @@ func updateXEPG(background bool) {
|
|||||||
|
|
||||||
createXMLTVFile()
|
createXMLTVFile()
|
||||||
createM3UFile()
|
createM3UFile()
|
||||||
|
queuePlexGuideRefresh("xepg update")
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
|
||||||
|
|
||||||
System.ScanInProgress = 0
|
System.ScanInProgress = 0
|
||||||
@@ -156,9 +213,9 @@ func updateXEPG(background bool) {
|
|||||||
func createXEPGMapping() {
|
func createXEPGMapping() {
|
||||||
|
|
||||||
Data.XMLTV.Files = getLocalProviderFiles("xmltv")
|
Data.XMLTV.Files = getLocalProviderFiles("xmltv")
|
||||||
Data.XMLTV.Mapping = make(map[string]interface{})
|
Data.XMLTV.Mapping = make(map[string]any)
|
||||||
|
|
||||||
var tmpMap = make(map[string]interface{})
|
var tmpMap = make(map[string]any)
|
||||||
|
|
||||||
var friendlyDisplayName = func(channel Channel) (displayName string) {
|
var friendlyDisplayName = func(channel Channel) (displayName string) {
|
||||||
var dn = channel.DisplayName
|
var dn = channel.DisplayName
|
||||||
@@ -199,10 +256,10 @@ func createXEPGMapping() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
// Daten aus der XML Datei in eine temporäre Map schreiben
|
// Daten aus der XML Datei in eine temporäre Map schreiben
|
||||||
var xmltvMap = make(map[string]interface{})
|
var xmltvMap = make(map[string]any)
|
||||||
|
|
||||||
for _, c := range xmltv.Channel {
|
for _, c := range xmltv.Channel {
|
||||||
var channel = make(map[string]interface{})
|
var channel = make(map[string]any)
|
||||||
|
|
||||||
channel["id"] = c.ID
|
channel["id"] = c.ID
|
||||||
channel["display-name"] = friendlyDisplayName(*c)
|
channel["display-name"] = friendlyDisplayName(*c)
|
||||||
@@ -220,7 +277,7 @@ func createXEPGMapping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Data.XMLTV.Mapping = tmpMap
|
Data.XMLTV.Mapping = tmpMap
|
||||||
tmpMap = make(map[string]interface{})
|
tmpMap = make(map[string]any)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -231,8 +288,8 @@ func createXEPGMapping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Auswahl für den Dummy erstellen
|
// Auswahl für den Dummy erstellen
|
||||||
var dummy = make(map[string]interface{})
|
var dummy = make(map[string]any)
|
||||||
var times = []string{"30", "60", "90", "120"}
|
var times = []string{"30", "60", "90", "120", "180", "240", "360"}
|
||||||
|
|
||||||
for _, i := range times {
|
for _, i := range times {
|
||||||
|
|
||||||
@@ -253,8 +310,9 @@ func createXEPGMapping() {
|
|||||||
// XEPG Datenbank erstellen / aktualisieren
|
// XEPG Datenbank erstellen / aktualisieren
|
||||||
func createXEPGDatabase() (err error) {
|
func createXEPGDatabase() (err error) {
|
||||||
|
|
||||||
var allChannelNumbers []float64
|
var allChannelNumbers = make([]float64, 0, System.UnfilteredChannelLimit)
|
||||||
Data.Cache.Streams.Active = []string{}
|
Data.Cache.Streams.Active = make([]string, 0, System.UnfilteredChannelLimit)
|
||||||
|
Data.XEPG.Channels = make(map[string]any, System.UnfilteredChannelLimit)
|
||||||
|
|
||||||
Data.XEPG.Channels, err = loadJSONFileToMap(System.File.XEPG)
|
Data.XEPG.Channels, err = loadJSONFileToMap(System.File.XEPG)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -279,24 +337,33 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
var getFreeChannelNumber = func() (xChannelID string) {
|
var getFreeChannelNumber = func() (xChannelID string) {
|
||||||
|
|
||||||
|
sort.Float64s(allChannelNumbers)
|
||||||
|
|
||||||
var firstFreeNumber float64 = Settings.MappingFirstChannel
|
var firstFreeNumber float64 = Settings.MappingFirstChannel
|
||||||
|
|
||||||
newNumber:
|
for {
|
||||||
|
|
||||||
|
if indexOfFloat64(firstFreeNumber, allChannelNumbers) == -1 {
|
||||||
|
xChannelID = fmt.Sprintf("%g", firstFreeNumber)
|
||||||
|
allChannelNumbers = append(allChannelNumbers, firstFreeNumber)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if indexOfFloat64(firstFreeNumber, allChannelNumbers) == -1 {
|
|
||||||
xChannelID = fmt.Sprintf("%g", firstFreeNumber)
|
|
||||||
allChannelNumbers = append(allChannelNumbers, firstFreeNumber)
|
|
||||||
} else {
|
|
||||||
firstFreeNumber++
|
firstFreeNumber++
|
||||||
goto newNumber
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var generateHashForChannel = func(m3uID string, groupTitle string, tvgID string, tvgName string, uuidKey string, uuidValue string) string {
|
||||||
|
hash := md5.Sum([]byte(m3uID + groupTitle + tvgID + tvgName + uuidKey + uuidValue))
|
||||||
|
return hex.EncodeToString(hash[:])
|
||||||
|
}
|
||||||
|
|
||||||
showInfo("XEPG:" + "Update database")
|
showInfo("XEPG:" + "Update database")
|
||||||
|
|
||||||
// Kanal mit fehlenden Kanalnummern löschen
|
// Kanal mit fehlenden Kanalnummern löschen. Delete channel with missing channel numbers
|
||||||
for id, dxc := range Data.XEPG.Channels {
|
for id, dxc := range Data.XEPG.Channels {
|
||||||
|
|
||||||
var xepgChannel XEPGChannelStruct
|
var xepgChannel XEPGChannelStruct
|
||||||
@@ -315,17 +382,24 @@ func createXEPGDatabase() (err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var xepgChannels = make(map[string]interface{})
|
// Make a map of the db channels based on their previously downloaded attributes -- filename, group, title, etc
|
||||||
|
var xepgChannelsValuesMap = make(map[string]XEPGChannelStruct, System.UnfilteredChannelLimit)
|
||||||
for k, v := range Data.XEPG.Channels {
|
for _, v := range Data.XEPG.Channels {
|
||||||
xepgChannels[k] = v
|
var channel XEPGChannelStruct
|
||||||
|
err = json.Unmarshal([]byte(mapToJSON(v)), &channel)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
channelHash := generateHashForChannel(channel.FileM3UID, channel.GroupTitle, channel.TvgID, channel.TvgName, channel.UUIDKey, channel.UUIDValue)
|
||||||
|
xepgChannelsValuesMap[channelHash] = channel
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dsa := range Data.Streams.Active {
|
for _, dsa := range Data.Streams.Active {
|
||||||
|
|
||||||
var channelExists = false // Entscheidet ob ein Kanal neu zu Datenbank hinzugefügt werden soll.
|
var channelExists = false // Entscheidet ob ein Kanal neu zu Datenbank hinzugefügt werden soll. Decides whether a channel should be added to the database
|
||||||
var channelHasUUID = false // Überprüft, ob der Kanal (Stream) eindeutige ID's besitzt
|
var channelHasUUID = false // Überprüft, ob der Kanal (Stream) eindeutige ID's besitzt. Checks whether the channel (stream) has unique IDs
|
||||||
var currentXEPGID string // Aktuelle Datenbank ID (XEPG). Wird verwendet, um den Kanal in der Datenbank mit dem Stream der M3u zu aktualisieren
|
var currentXEPGID string // Aktuelle Datenbank ID (XEPG). Wird verwendet, um den Kanal in der Datenbank mit dem Stream der M3u zu aktualisieren. Current database ID (XEPG) Used to update the channel in the database with the stream of the M3u
|
||||||
|
|
||||||
var m3uChannel M3UChannelStructXEPG
|
var m3uChannel M3UChannelStructXEPG
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(mapToJSON(dsa)), &m3uChannel)
|
err = json.Unmarshal([]byte(mapToJSON(dsa)), &m3uChannel)
|
||||||
@@ -333,44 +407,53 @@ func createXEPGDatabase() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name)
|
Data.Cache.Streams.Active = append(Data.Cache.Streams.Active, m3uChannel.Name+m3uChannel.FileM3UID)
|
||||||
|
|
||||||
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen.
|
// Try to find the channel based on matching all known values. If that fails, then move to full channel scan
|
||||||
for xepg, dxc := range xepgChannels {
|
m3uChannelHash := generateHashForChannel(m3uChannel.FileM3UID, m3uChannel.GroupTitle, m3uChannel.TvgID, m3uChannel.TvgName, m3uChannel.UUIDKey, m3uChannel.UUIDValue)
|
||||||
|
if val, ok := xepgChannelsValuesMap[m3uChannelHash]; ok {
|
||||||
var xepgChannel XEPGChannelStruct
|
channelExists = true
|
||||||
err = json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
|
currentXEPGID = val.XEPG
|
||||||
if err != nil {
|
if len(m3uChannel.UUIDValue) > 0 {
|
||||||
return
|
channelHasUUID = true
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
// Vergleichen des Streams anhand einer UUID in der M3U mit dem Kanal in der Databank
|
// XEPG Datenbank durchlaufen um nach dem Kanal zu suchen. Run through the XEPG database to search for the channel (full scan)
|
||||||
if len(xepgChannel.UUIDValue) > 0 && len(m3uChannel.UUIDValue) > 0 {
|
for _, dxc := range xepgChannelsValuesMap {
|
||||||
|
|
||||||
if xepgChannel.UUIDValue == m3uChannel.UUIDValue && xepgChannel.UUIDKey == m3uChannel.UUIDKey {
|
if m3uChannel.FileM3UID == dxc.FileM3UID {
|
||||||
|
|
||||||
channelExists = true
|
dxc.FileM3UID = m3uChannel.FileM3UID
|
||||||
channelHasUUID = true
|
dxc.FileM3UName = m3uChannel.FileM3UName
|
||||||
currentXEPGID = xepg
|
|
||||||
break
|
// Vergleichen des Streams anhand einer UUID in der M3U mit dem Kanal in der Databank. Compare the stream using a UUID in the M3U with the channel in the database
|
||||||
|
if len(dxc.UUIDValue) > 0 && len(m3uChannel.UUIDValue) > 0 {
|
||||||
|
|
||||||
|
if dxc.UUIDValue == m3uChannel.UUIDValue && dxc.UUIDKey == m3uChannel.UUIDKey {
|
||||||
|
|
||||||
|
channelExists = true
|
||||||
|
channelHasUUID = true
|
||||||
|
currentXEPGID = dxc.XEPG
|
||||||
|
break
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Vergleichen des Streams mit dem Kanal in der Databank anhand des Kanalnamens. Compare the stream to the channel in the database using the channel name
|
||||||
|
if dxc.Name == m3uChannel.Name {
|
||||||
|
channelExists = true
|
||||||
|
currentXEPGID = dxc.XEPG
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
// Vergleichen des Streams mit dem Kanal in der Databank anhand des Kanalnamens
|
|
||||||
//fmt.Println(xepgChannel.Name, xepgChannel.UUIDKey, xepgChannel.UUIDValue)
|
|
||||||
if xepgChannel.Name == m3uChannel.Name {
|
|
||||||
channelExists = true
|
|
||||||
currentXEPGID = xepg
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//os.Exit(0)
|
|
||||||
|
|
||||||
switch channelExists {
|
switch channelExists {
|
||||||
|
|
||||||
case true:
|
case true:
|
||||||
@@ -435,7 +518,7 @@ func createXEPGDatabase() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
showInfo("XEPG:" + "Save DB file")
|
||||||
err = saveMapToJSONFile(System.File.XEPG, Data.XEPG.Channels)
|
err = saveMapToJSONFile(System.File.XEPG, Data.XEPG.Channels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -444,10 +527,132 @@ func createXEPGDatabase() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeXEPGMatchValue(value string) string {
|
||||||
|
value = strings.TrimSpace(value)
|
||||||
|
if len(value) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Map(func(r rune) rune {
|
||||||
|
switch {
|
||||||
|
case unicode.IsLetter(r):
|
||||||
|
return unicode.ToLower(r)
|
||||||
|
case unicode.IsDigit(r):
|
||||||
|
return r
|
||||||
|
default:
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
}, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendXEPGIssueSample(samples map[string]struct{}, value string) {
|
||||||
|
value = strings.TrimSpace(value)
|
||||||
|
if len(value) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
samples[value] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func xepgIssueSampleText(samples map[string]struct{}, max int) string {
|
||||||
|
if len(samples) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
list := make([]string, 0, len(samples))
|
||||||
|
for name := range samples {
|
||||||
|
list = append(list, name)
|
||||||
|
}
|
||||||
|
sort.Strings(list)
|
||||||
|
|
||||||
|
if len(list) > max {
|
||||||
|
return strings.Join(list[:max], ", ") + ", ..."
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(list, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func findXEPGReplacementChannel(xmltvChannels map[string]any, xepgChannel XEPGChannelStruct) (channelID string, channel map[string]any, ok bool) {
|
||||||
|
var candidateValues = map[string]struct{}{}
|
||||||
|
|
||||||
|
addCandidate := func(value string) {
|
||||||
|
normalized := normalizeXEPGMatchValue(value)
|
||||||
|
if len(normalized) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
candidateValues[normalized] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
addCandidate(xepgChannel.XName)
|
||||||
|
addCandidate(xepgChannel.Name)
|
||||||
|
addCandidate(xepgChannel.TvgName)
|
||||||
|
addCandidate(xepgChannel.TvgID)
|
||||||
|
|
||||||
|
if len(candidateValues) == 0 {
|
||||||
|
return "", nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, exists := candidateValues[normalizeXEPGMatchValue(xepgChannel.TvgID)]; exists {
|
||||||
|
if direct, found := xmltvChannels[xepgChannel.TvgID].(map[string]any); found {
|
||||||
|
return xepgChannel.TvgID, direct, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var matches []struct {
|
||||||
|
id string
|
||||||
|
channel map[string]any
|
||||||
|
}
|
||||||
|
|
||||||
|
for id, data := range xmltvChannels {
|
||||||
|
xmltvChannel, castOK := data.(map[string]any)
|
||||||
|
if castOK == false {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, match := candidateValues[normalizeXEPGMatchValue(id)]; match {
|
||||||
|
matches = append(matches, struct {
|
||||||
|
id string
|
||||||
|
channel map[string]any
|
||||||
|
}{id: id, channel: xmltvChannel})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
displayName, hasDisplayName := xmltvChannel["display-name"].(string)
|
||||||
|
if hasDisplayName == false {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, match := candidateValues[normalizeXEPGMatchValue(displayName)]; match {
|
||||||
|
matches = append(matches, struct {
|
||||||
|
id string
|
||||||
|
channel map[string]any
|
||||||
|
}{id: id, channel: xmltvChannel})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(matches) != 1 {
|
||||||
|
return "", nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches[0].id, matches[0].channel, true
|
||||||
|
}
|
||||||
|
|
||||||
// Kanäle automatisch zuordnen und das Mapping überprüfen
|
// Kanäle automatisch zuordnen und das Mapping überprüfen
|
||||||
func mapping() (err error) {
|
func mapping() (err error) {
|
||||||
showInfo("XEPG:" + "Map channels")
|
showInfo("XEPG:" + "Map channels")
|
||||||
|
|
||||||
|
strictMissingEPGMode := Settings.XepgMissingEPGMode != "relaxed"
|
||||||
|
|
||||||
|
missingEPGCount := 0
|
||||||
|
missingXMLTVCount := 0
|
||||||
|
autoRemapCount := 0
|
||||||
|
relaxedKeepCount := 0
|
||||||
|
relaxedDummyCount := 0
|
||||||
|
missingEPGSamples := map[string]struct{}{}
|
||||||
|
missingXMLTVSamples := map[string]struct{}{}
|
||||||
|
autoRemapSamples := map[string]struct{}{}
|
||||||
|
relaxedKeepSamples := map[string]struct{}{}
|
||||||
|
relaxedDummySamples := map[string]struct{}{}
|
||||||
|
|
||||||
for xepg, dxc := range Data.XEPG.Channels {
|
for xepg, dxc := range Data.XEPG.Channels {
|
||||||
|
|
||||||
var xepgChannel XEPGChannelStruct
|
var xepgChannel XEPGChannelStruct
|
||||||
@@ -460,7 +665,7 @@ func mapping() (err error) {
|
|||||||
if xepgChannel.XActive == false {
|
if xepgChannel.XActive == false {
|
||||||
|
|
||||||
// Werte kann "-" sein, deswegen len < 1
|
// Werte kann "-" sein, deswegen len < 1
|
||||||
if len(xepgChannel.XmltvFile) < 1 && len(xepgChannel.XmltvFile) < 1 {
|
if len(xepgChannel.XmltvFile) < 1 && len(xepgChannel.XMapping) < 1 {
|
||||||
|
|
||||||
var tvgID = xepgChannel.TvgID
|
var tvgID = xepgChannel.TvgID
|
||||||
|
|
||||||
@@ -472,16 +677,16 @@ func mapping() (err error) {
|
|||||||
|
|
||||||
for file, xmltvChannels := range Data.XMLTV.Mapping {
|
for file, xmltvChannels := range Data.XMLTV.Mapping {
|
||||||
|
|
||||||
if channel, ok := xmltvChannels.(map[string]interface{})[tvgID]; ok {
|
if channel, ok := xmltvChannels.(map[string]any)[tvgID]; ok {
|
||||||
|
|
||||||
if channelID, ok := channel.(map[string]interface{})["id"].(string); ok {
|
if channelID, ok := channel.(map[string]any)["id"].(string); ok {
|
||||||
|
|
||||||
xepgChannel.XmltvFile = file
|
xepgChannel.XmltvFile = file
|
||||||
xepgChannel.XMapping = channelID
|
xepgChannel.XMapping = channelID
|
||||||
xepgChannel.XActive = true
|
xepgChannel.XActive = true
|
||||||
|
|
||||||
// Falls in der XMLTV Datei ein Logo existiert, wird dieses verwendet. Falls nicht, dann das Logo aus der M3U Datei
|
// Falls in der XMLTV Datei ein Logo existiert, wird dieses verwendet. Falls nicht, dann das Logo aus der M3U Datei
|
||||||
if icon, ok := channel.(map[string]interface{})["icon"].(string); ok {
|
if icon, ok := channel.(map[string]any)["icon"].(string); ok {
|
||||||
if len(icon) > 0 {
|
if len(icon) > 0 {
|
||||||
xepgChannel.TvgLogo = icon
|
xepgChannel.TvgLogo = icon
|
||||||
}
|
}
|
||||||
@@ -508,9 +713,9 @@ func mapping() (err error) {
|
|||||||
|
|
||||||
if file != "xTeVe Dummy" {
|
if file != "xTeVe Dummy" {
|
||||||
|
|
||||||
if value, ok := Data.XMLTV.Mapping[file].(map[string]interface{}); ok {
|
if value, ok := Data.XMLTV.Mapping[file].(map[string]any); ok {
|
||||||
|
|
||||||
if channel, ok := value[mapping].(map[string]interface{}); ok {
|
if channel, ok := value[mapping].(map[string]any); ok {
|
||||||
|
|
||||||
// Kanallogo aktualisieren
|
// Kanallogo aktualisieren
|
||||||
if logo, ok := channel["icon"].(string); ok {
|
if logo, ok := channel["icon"].(string); ok {
|
||||||
@@ -522,20 +727,68 @@ func mapping() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if channelID, replacementChannel, remapOK := findXEPGReplacementChannel(value, xepgChannel); remapOK {
|
||||||
|
xepgChannel.XMapping = channelID
|
||||||
|
|
||||||
ShowError(fmt.Errorf(fmt.Sprintf("Missing EPG data: %s", xepgChannel.Name)), 0)
|
if logo, ok := replacementChannel["icon"].(string); ok {
|
||||||
showWarning(2302)
|
if xepgChannel.XUpdateChannelIcon == true && len(logo) > 0 {
|
||||||
xepgChannel.XActive = false
|
xepgChannel.TvgLogo = logo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
autoRemapCount++
|
||||||
|
name := strings.TrimSpace(xepgChannel.Name)
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = strings.TrimSpace(xepgChannel.XName)
|
||||||
|
}
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = xepg
|
||||||
|
}
|
||||||
|
appendXEPGIssueSample(autoRemapSamples, name)
|
||||||
|
} else {
|
||||||
|
name := strings.TrimSpace(xepgChannel.Name)
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = strings.TrimSpace(xepgChannel.XName)
|
||||||
|
}
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = xepg
|
||||||
|
}
|
||||||
|
|
||||||
|
if strictMissingEPGMode == true {
|
||||||
|
missingEPGCount++
|
||||||
|
appendXEPGIssueSample(missingEPGSamples, name)
|
||||||
|
xepgChannel.XActive = false
|
||||||
|
} else {
|
||||||
|
relaxedKeepCount++
|
||||||
|
appendXEPGIssueSample(relaxedKeepSamples, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var fileID = strings.TrimSuffix(getFilenameFromPath(file), path.Ext(getFilenameFromPath(file)))
|
var fileID = strings.TrimSuffix(getFilenameFromPath(file), path.Ext(getFilenameFromPath(file)))
|
||||||
|
providerName := getProviderParameter(fileID, "xmltv", "name")
|
||||||
|
if len(strings.TrimSpace(providerName)) == 0 {
|
||||||
|
providerName = file
|
||||||
|
}
|
||||||
|
|
||||||
ShowError(fmt.Errorf("Missing XMLTV file: %s", getProviderParameter(fileID, "xmltv", "name")), 0)
|
if strictMissingEPGMode == true {
|
||||||
showWarning(2301)
|
missingXMLTVCount++
|
||||||
xepgChannel.XActive = false
|
appendXEPGIssueSample(missingXMLTVSamples, providerName)
|
||||||
|
xepgChannel.XActive = false
|
||||||
|
} else {
|
||||||
|
relaxedDummyCount++
|
||||||
|
name := strings.TrimSpace(xepgChannel.Name)
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = strings.TrimSpace(xepgChannel.XName)
|
||||||
|
}
|
||||||
|
if len(name) == 0 {
|
||||||
|
name = xepg
|
||||||
|
}
|
||||||
|
appendXEPGIssueSample(relaxedDummySamples, name)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,6 +810,28 @@ func mapping() (err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if autoRemapCount > 0 {
|
||||||
|
showInfo(fmt.Sprintf("XEPG:%d channel mappings were auto-remapped (examples: %s)", autoRemapCount, xepgIssueSampleText(autoRemapSamples, 8)))
|
||||||
|
}
|
||||||
|
|
||||||
|
if missingEPGCount > 0 {
|
||||||
|
showWarning(2302)
|
||||||
|
showInfo(fmt.Sprintf("XEPG:%d channels have missing EPG mappings and were deactivated (examples: %s)", missingEPGCount, xepgIssueSampleText(missingEPGSamples, 8)))
|
||||||
|
}
|
||||||
|
|
||||||
|
if missingXMLTVCount > 0 {
|
||||||
|
showWarning(2301)
|
||||||
|
showInfo(fmt.Sprintf("XEPG:%d channels reference missing XMLTV files and were deactivated (sources: %s)", missingXMLTVCount, xepgIssueSampleText(missingXMLTVSamples, 5)))
|
||||||
|
}
|
||||||
|
|
||||||
|
if relaxedKeepCount > 0 {
|
||||||
|
showInfo(fmt.Sprintf("XEPG:%d channels kept active in relaxed mode despite missing EPG mappings (examples: %s)", relaxedKeepCount, xepgIssueSampleText(relaxedKeepSamples, 8)))
|
||||||
|
}
|
||||||
|
|
||||||
|
if relaxedDummyCount > 0 {
|
||||||
|
showInfo(fmt.Sprintf("XEPG:%d channels will use xTeVe Dummy guide in relaxed mode because XMLTV sources were unavailable (examples: %s)", relaxedDummyCount, xepgIssueSampleText(relaxedDummySamples, 8)))
|
||||||
|
}
|
||||||
|
|
||||||
err = saveMapToJSONFile(System.File.XEPG, Data.XEPG.Channels)
|
err = saveMapToJSONFile(System.File.XEPG, Data.XEPG.Channels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -568,6 +843,10 @@ func mapping() (err error) {
|
|||||||
// XMLTV Datei erstellen
|
// XMLTV Datei erstellen
|
||||||
func createXMLTVFile() (err error) {
|
func createXMLTVFile() (err error) {
|
||||||
|
|
||||||
|
// Image Cache
|
||||||
|
// 4edd81ab7c368208cc6448b615051b37.jpg
|
||||||
|
var imgc = Data.Cache.Images
|
||||||
|
|
||||||
Data.Cache.ImagesFiles = []string{}
|
Data.Cache.ImagesFiles = []string{}
|
||||||
Data.Cache.ImagesURLS = []string{}
|
Data.Cache.ImagesURLS = []string{}
|
||||||
Data.Cache.ImagesCache = []string{}
|
Data.Cache.ImagesCache = []string{}
|
||||||
@@ -586,7 +865,7 @@ func createXMLTVFile() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(Data.XMLTV.Files) == 0 && len(Data.Streams.Active) == 0 {
|
if len(Data.XMLTV.Files) == 0 && len(Data.Streams.Active) == 0 {
|
||||||
Data.XEPG.Channels = make(map[string]interface{})
|
Data.XEPG.Channels = make(map[string]any)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +894,7 @@ func createXMLTVFile() (err error) {
|
|||||||
// Kanäle
|
// Kanäle
|
||||||
var channel Channel
|
var channel Channel
|
||||||
channel.ID = xepgChannel.XChannelID
|
channel.ID = xepgChannel.XChannelID
|
||||||
channel.Icon = Icon{Src: getCacheImageURL(xepgChannel.TvgLogo)}
|
channel.Icon = Icon{Src: imgc.Image.GetURL(xepgChannel.TvgLogo)}
|
||||||
channel.DisplayName = append(channel.DisplayName, DisplayName{Value: xepgChannel.XName})
|
channel.DisplayName = append(channel.DisplayName, DisplayName{Value: xepgChannel.XName})
|
||||||
|
|
||||||
xepgXML.Channel = append(xepgXML.Channel, &channel)
|
xepgXML.Channel = append(xepgXML.Channel, &channel)
|
||||||
@@ -641,9 +920,10 @@ func createXMLTVFile() (err error) {
|
|||||||
var xmlOutput = []byte(xml.Header + string(content))
|
var xmlOutput = []byte(xml.Header + string(content))
|
||||||
writeByteToFile(System.File.XML, xmlOutput)
|
writeByteToFile(System.File.XML, xmlOutput)
|
||||||
|
|
||||||
xepgXML = XMLTV{}
|
showInfo("XEPG:" + fmt.Sprintf("Compress XMLTV file (%s)", System.Compressed.GZxml))
|
||||||
|
err = compressGZIP(&xmlOutput, System.Compressed.GZxml)
|
||||||
|
|
||||||
//saveMapToJSONFile(System.File.Images, Data.Cache.ImageCache)
|
xepgXML = XMLTV{}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -653,6 +933,13 @@ func getProgramData(xepgChannel XEPGChannelStruct) (xepgXML XMLTV, err error) {
|
|||||||
|
|
||||||
var xmltvFile = System.Folder.Data + xepgChannel.XmltvFile
|
var xmltvFile = System.Folder.Data + xepgChannel.XmltvFile
|
||||||
var channelID = xepgChannel.XMapping
|
var channelID = xepgChannel.XMapping
|
||||||
|
relaxedMissingEPGMode := Settings.XepgMissingEPGMode == "relaxed"
|
||||||
|
fallbackToDummy := func() {
|
||||||
|
dummyChannel := xepgChannel
|
||||||
|
dummyChannel.XmltvFile = "xTeVe Dummy"
|
||||||
|
dummyChannel.XMapping = "240_Minutes"
|
||||||
|
xepgXML = createDummyProgram(dummyChannel)
|
||||||
|
}
|
||||||
|
|
||||||
var xmltv XMLTV
|
var xmltv XMLTV
|
||||||
|
|
||||||
@@ -662,6 +949,10 @@ func getProgramData(xepgChannel XEPGChannelStruct) (xepgXML XMLTV, err error) {
|
|||||||
|
|
||||||
err = getLocalXMLTV(xmltvFile, &xmltv)
|
err = getLocalXMLTV(xmltvFile, &xmltv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if relaxedMissingEPGMode == true {
|
||||||
|
fallbackToDummy()
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,6 +981,15 @@ func getProgramData(xepgChannel XEPGChannelStruct) (xepgXML XMLTV, err error) {
|
|||||||
// Category (Kategorie)
|
// Category (Kategorie)
|
||||||
getCategory(program, xmltvProgram, xepgChannel)
|
getCategory(program, xmltvProgram, xepgChannel)
|
||||||
|
|
||||||
|
// Credits : (Credits)
|
||||||
|
program.Credits = xmltvProgram.Credits
|
||||||
|
|
||||||
|
// Rating (Bewertung)
|
||||||
|
program.Rating = xmltvProgram.Rating
|
||||||
|
|
||||||
|
// StarRating (Bewertung / Kritiken)
|
||||||
|
program.StarRating = xmltvProgram.StarRating
|
||||||
|
|
||||||
// Country (Länder)
|
// Country (Länder)
|
||||||
program.Country = xmltvProgram.Country
|
program.Country = xmltvProgram.Country
|
||||||
|
|
||||||
@@ -726,19 +1026,24 @@ func getProgramData(xepgChannel XEPGChannelStruct) (xepgXML XMLTV, err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(xepgXML.Program) == 0 && relaxedMissingEPGMode == true && xmltvFile != System.Folder.Data+"xTeVe Dummy" {
|
||||||
|
fallbackToDummy()
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dummy Daten erstellen (createXMLTVFile)
|
// Dummy Daten erstellen (createXMLTVFile)
|
||||||
func createDummyProgram(xepgChannel XEPGChannelStruct) (dummyXMLTV XMLTV) {
|
func createDummyProgram(xepgChannel XEPGChannelStruct) (dummyXMLTV XMLTV) {
|
||||||
|
|
||||||
|
var imgc = Data.Cache.Images
|
||||||
var currentTime = time.Now()
|
var currentTime = time.Now()
|
||||||
var dateArray = strings.Fields(currentTime.String())
|
var dateArray = strings.Fields(currentTime.String())
|
||||||
var offset = " " + dateArray[2]
|
var offset = " " + dateArray[2]
|
||||||
var currentDay = currentTime.Format("20060102")
|
var currentDay = currentTime.Format("20060102")
|
||||||
var startTime, _ = time.Parse("20060102150405", currentDay+"000000")
|
var startTime, _ = time.Parse("20060102150405", currentDay+"000000")
|
||||||
|
|
||||||
showInfo("Create Dummy Guide:" + "Time offset" + offset + " - " + xepgChannel.XName)
|
showDebug("Create Dummy Guide:"+"Time offset"+offset+" - "+xepgChannel.XName, 2)
|
||||||
|
|
||||||
var dl = strings.Split(xepgChannel.XMapping, "_")
|
var dl = strings.Split(xepgChannel.XMapping, "_")
|
||||||
dummyLength, err := strconv.Atoi(dl[0])
|
dummyLength, err := strconv.Atoi(dl[0])
|
||||||
@@ -747,7 +1052,7 @@ func createDummyProgram(xepgChannel XEPGChannelStruct) (dummyXMLTV XMLTV) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for d := 0; d < 4; d++ {
|
for d := range 4 {
|
||||||
|
|
||||||
var epgStartTime = startTime.Add(time.Hour * time.Duration(d*24))
|
var epgStartTime = startTime.Add(time.Hour * time.Duration(d*24))
|
||||||
|
|
||||||
@@ -770,7 +1075,7 @@ func createDummyProgram(xepgChannel XEPGChannelStruct) (dummyXMLTV XMLTV) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if Settings.XepgReplaceMissingImages == true {
|
if Settings.XepgReplaceMissingImages == true {
|
||||||
poster.Src = getCacheImageURL(xepgChannel.TvgLogo)
|
poster.Src = imgc.Image.GetURL(xepgChannel.TvgLogo)
|
||||||
epg.Poster = append(epg.Poster, poster)
|
epg.Poster = append(epg.Poster, poster)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,8 +1122,10 @@ func getCategory(program *Program, xmltvProgram *Program, xepgChannel XEPGChanne
|
|||||||
// Programm Poster Cover aus der XMLTV Datei laden
|
// Programm Poster Cover aus der XMLTV Datei laden
|
||||||
func getPoster(program *Program, xmltvProgram *Program, xepgChannel XEPGChannelStruct) {
|
func getPoster(program *Program, xmltvProgram *Program, xepgChannel XEPGChannelStruct) {
|
||||||
|
|
||||||
|
var imgc = Data.Cache.Images
|
||||||
|
|
||||||
for _, poster := range xmltvProgram.Poster {
|
for _, poster := range xmltvProgram.Poster {
|
||||||
poster.Src = getCacheImageURL(poster.Src)
|
poster.Src = imgc.Image.GetURL(poster.Src)
|
||||||
program.Poster = append(program.Poster, poster)
|
program.Poster = append(program.Poster, poster)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,7 +1133,7 @@ func getPoster(program *Program, xmltvProgram *Program, xepgChannel XEPGChannelS
|
|||||||
|
|
||||||
if len(xmltvProgram.Poster) == 0 {
|
if len(xmltvProgram.Poster) == 0 {
|
||||||
var poster Poster
|
var poster Poster
|
||||||
poster.Src = getCacheImageURL(xepgChannel.TvgLogo)
|
poster.Src = imgc.Image.GetURL(poster.Src)
|
||||||
program.Poster = append(program.Poster, poster)
|
program.Poster = append(program.Poster, poster)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,6 +1244,18 @@ func createM3UFile() {
|
|||||||
// XEPG Datenbank bereinigen
|
// XEPG Datenbank bereinigen
|
||||||
func cleanupXEPG() {
|
func cleanupXEPG() {
|
||||||
|
|
||||||
|
//fmt.Println(Settings.Files.M3U)
|
||||||
|
|
||||||
|
var sourceIDs []string
|
||||||
|
|
||||||
|
for source := range Settings.Files.M3U {
|
||||||
|
sourceIDs = append(sourceIDs, source)
|
||||||
|
}
|
||||||
|
|
||||||
|
for source := range Settings.Files.HDHR {
|
||||||
|
sourceIDs = append(sourceIDs, source)
|
||||||
|
}
|
||||||
|
|
||||||
showInfo("XEPG:" + fmt.Sprintf("Cleanup database"))
|
showInfo("XEPG:" + fmt.Sprintf("Cleanup database"))
|
||||||
Data.XEPG.XEPGCount = 0
|
Data.XEPG.XEPGCount = 0
|
||||||
|
|
||||||
@@ -946,7 +1265,7 @@ func cleanupXEPG() {
|
|||||||
err := json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
|
err := json.Unmarshal([]byte(mapToJSON(dxc)), &xepgChannel)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
||||||
if indexOfString(xepgChannel.Name, Data.Cache.Streams.Active) == -1 {
|
if indexOfString(xepgChannel.Name+xepgChannel.FileM3UID, Data.Cache.Streams.Active) == -1 {
|
||||||
delete(Data.XEPG.Channels, id)
|
delete(Data.XEPG.Channels, id)
|
||||||
} else {
|
} else {
|
||||||
if xepgChannel.XActive == true {
|
if xepgChannel.XActive == true {
|
||||||
@@ -954,6 +1273,10 @@ func cleanupXEPG() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if indexOfString(xepgChannel.FileM3UID, sourceIDs) == -1 {
|
||||||
|
delete(Data.XEPG.Channels, id)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ function login() {
|
|||||||
if (value.length == 0) {
|
if (value.length == 0) {
|
||||||
inputs[i].style.borderColor = "red"
|
inputs[i].style.borderColor = "red"
|
||||||
err = true
|
err = true
|
||||||
|
} else {
|
||||||
|
inputs[i].style.borderColor = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
data[key] = value
|
data[key] = value
|
||||||
@@ -30,7 +32,6 @@ function login() {
|
|||||||
if (data.hasOwnProperty("confirm")) {
|
if (data.hasOwnProperty("confirm")) {
|
||||||
|
|
||||||
if (data["confirm"] != data["password"]) {
|
if (data["confirm"] != data["password"]) {
|
||||||
alert("sdafsd")
|
|
||||||
document.getElementById('password').style.borderColor = "red"
|
document.getElementById('password').style.borderColor = "red"
|
||||||
document.getElementById('confirm').style.borderColor = "red"
|
document.getElementById('confirm').style.borderColor = "red"
|
||||||
|
|
||||||
|
|||||||
131
ts/base_ts.ts
131
ts/base_ts.ts
@@ -5,6 +5,8 @@ var SEARCH_MAPPING = new Object()
|
|||||||
var UNDO = new Object()
|
var UNDO = new Object()
|
||||||
var SERVER_CONNECTION = false
|
var SERVER_CONNECTION = false
|
||||||
var WS_AVAILABLE = false
|
var WS_AVAILABLE = false
|
||||||
|
var ACTIVE_MENU_ID:string = ""
|
||||||
|
var LAST_BULK_CHECKBOX:HTMLInputElement = null
|
||||||
|
|
||||||
|
|
||||||
// Menü
|
// Menü
|
||||||
@@ -21,9 +23,8 @@ menuItems.push(new MainMenuItem("logout", "{{.mainMenu.item.logout}}", "logout.p
|
|||||||
|
|
||||||
// Kategorien für die Einstellungen
|
// Kategorien für die Einstellungen
|
||||||
var settingsCategory = new Array()
|
var settingsCategory = new Array()
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.general}}", "xteveAutoUpdate,tuner,epgSource,api,scheme.m3u,scheme.xml"))
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.general}}", "xteveAutoUpdate,tuner,epgSource,api,use_plexAPI,plex.url,plex.token"));settingsCategory.push(new SettingsCategoryItem("{{.settings.category.files}}", "update,files.update,temp.path,cache.images,xepg.missing.epg.mode,xepg.replace.missing.images"))
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.files}}", "update,files.update,temp.path,cache.images,xepg.replace.missing.images"))
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.streaming}}", "buffer,udpxy,buffer.size.kb,buffer.timeout,user.agent,ffmpeg.path,ffmpeg.options,vlc.path,vlc.options"))
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.streaming}}", "buffer,buffer.size.kb,buffer.timeout,user.agent,ffmpeg.path,ffmpeg.options,vlc.path,vlc.options"))
|
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.backup}}", "backup.path,backup.keep"))
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.backup}}", "backup.path,backup.keep"))
|
||||||
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.authentication}}", "authentication.web,authentication.pms,authentication.m3u,authentication.xml,authentication.api"))
|
settingsCategory.push(new SettingsCategoryItem("{{.settings.category.authentication}}", "authentication.web,authentication.pms,authentication.m3u,authentication.xml,authentication.api"))
|
||||||
|
|
||||||
@@ -52,7 +53,44 @@ function showElement(elmID, type) {
|
|||||||
case false: cssClass = "none"; break;
|
case false: cssClass = "none"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById(elmID).className = cssClass;
|
var element = document.getElementById(elmID)
|
||||||
|
if (element == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
element.className = cssClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setConnectionState(state:string, text:string = "") {
|
||||||
|
|
||||||
|
var label:string = text
|
||||||
|
if (label == undefined || label.length == 0) {
|
||||||
|
switch (state) {
|
||||||
|
case "online":
|
||||||
|
label = "Connected"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "busy":
|
||||||
|
label = "Syncing"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "offline":
|
||||||
|
label = "Offline"
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
label = "Connecting"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var indicator = document.getElementById("connection-indicator")
|
||||||
|
if (indicator == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
indicator.className = "status-" + state
|
||||||
|
indicator.innerText = label
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeButtonAction(element, buttonID, attribute) {
|
function changeButtonAction(element, buttonID, attribute) {
|
||||||
@@ -145,6 +183,59 @@ function getAllSelectedChannels():string[] {
|
|||||||
return channels
|
return channels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scheduleChannelRangeSelection(checkbox:HTMLInputElement, event:MouseEvent) {
|
||||||
|
|
||||||
|
var shiftPressed = false
|
||||||
|
if (event != undefined && event.shiftKey == true) {
|
||||||
|
shiftPressed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run after the native checkbox toggle so we copy the final checked state.
|
||||||
|
setTimeout(function() {
|
||||||
|
selectChannelRange(checkbox, shiftPressed)
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectChannelRange(checkbox:HTMLInputElement, shiftPressed:boolean) {
|
||||||
|
|
||||||
|
if (BULK_EDIT == false || checkbox == undefined || checkbox == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var table = document.getElementById("content_table")
|
||||||
|
if (table == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var trs = table.getElementsByTagName("TR")
|
||||||
|
var visibleCheckboxes:HTMLInputElement[] = new Array()
|
||||||
|
|
||||||
|
for (var i = 1; i < trs.length; i++) {
|
||||||
|
if ((trs[i] as HTMLElement).style.display != "none") {
|
||||||
|
var bulkCheckbox = (trs[i] as HTMLTableRowElement).querySelector("input.bulk") as HTMLInputElement
|
||||||
|
if (bulkCheckbox != null) {
|
||||||
|
visibleCheckboxes.push(bulkCheckbox)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentIndex = visibleCheckboxes.indexOf(checkbox)
|
||||||
|
var previousIndex = -1
|
||||||
|
if (LAST_BULK_CHECKBOX != null) {
|
||||||
|
previousIndex = visibleCheckboxes.indexOf(LAST_BULK_CHECKBOX)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shiftPressed == true && previousIndex > -1 && currentIndex > -1) {
|
||||||
|
var start = Math.min(previousIndex, currentIndex)
|
||||||
|
var end = Math.max(previousIndex, currentIndex)
|
||||||
|
for (var i = start; i <= end; i++) {
|
||||||
|
visibleCheckboxes[i].checked = checkbox.checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LAST_BULK_CHECKBOX = checkbox
|
||||||
|
}
|
||||||
|
|
||||||
function selectAllChannels() {
|
function selectAllChannels() {
|
||||||
|
|
||||||
var bulk:Boolean = false
|
var bulk:Boolean = false
|
||||||
@@ -174,6 +265,7 @@ function selectAllChannels() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LAST_BULK_CHECKBOX = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +290,7 @@ function bulkEdit() {
|
|||||||
(rows[i] as HTMLInputElement).checked = false
|
(rows[i] as HTMLInputElement).checked = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LAST_BULK_CHECKBOX = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +403,7 @@ function createSearchObj() {
|
|||||||
var data = SERVER["xepg"]["epgMapping"]
|
var data = SERVER["xepg"]["epgMapping"]
|
||||||
var channels = getObjKeys(data)
|
var channels = getObjKeys(data)
|
||||||
|
|
||||||
var channelKeys:string[] = ["x-active", "x-channelID", "x-name", "_file.m3u.name", "x-group-title"]
|
var channelKeys:string[] = ["x-active", "x-channelID", "x-name", "_file.m3u.name", "x-group-title", "x-xmltv-file"]
|
||||||
|
|
||||||
channels.forEach(id => {
|
channels.forEach(id => {
|
||||||
|
|
||||||
@@ -331,7 +424,17 @@ function createSearchObj() {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
SEARCH_MAPPING[id] = SEARCH_MAPPING[id] + data[id][key] + " "
|
if (key == "x-xmltv-file") {
|
||||||
|
var xmltvFile = getValueFromProviderFile(data[id][key], "xmltv", "name")
|
||||||
|
|
||||||
|
if (xmltvFile != undefined) {
|
||||||
|
SEARCH_MAPPING[id] = SEARCH_MAPPING[id] + xmltvFile + " "
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SEARCH_MAPPING[id] = SEARCH_MAPPING[id] + data[id][key] + " "
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,17 +473,19 @@ function searchInMapping() {
|
|||||||
|
|
||||||
function calculateWrapperHeight() {
|
function calculateWrapperHeight() {
|
||||||
|
|
||||||
if (document.getElementById("box-wrapper")){
|
var elm = document.getElementById("box-wrapper");
|
||||||
|
var content = document.getElementById("content");
|
||||||
|
|
||||||
var elm = document.getElementById("box-wrapper");
|
if (elm != null && content != null){
|
||||||
|
|
||||||
var divs = new Array("myStreamsBox", "clientInfo", "content");
|
var contentTop = content.getBoundingClientRect().top
|
||||||
var elementsHeight = 0 - elm.offsetHeight;
|
var freeSpace = window.innerHeight - contentTop - 26
|
||||||
for (var i = 0; i < divs.length; i++) {
|
|
||||||
elementsHeight = elementsHeight + document.getElementById(divs[i]).offsetHeight;
|
if (freeSpace < 180) {
|
||||||
|
freeSpace = 180
|
||||||
}
|
}
|
||||||
|
|
||||||
elm.style.height = window.innerHeight - elementsHeight + "px";
|
elm.style.height = freeSpace + "px";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,18 @@ function showLogs(bottom:boolean) {
|
|||||||
|
|
||||||
var logs = SERVER["log"]["log"]
|
var logs = SERVER["log"]["log"]
|
||||||
var div = document.getElementById("content_log")
|
var div = document.getElementById("content_log")
|
||||||
|
var wrapper = document.getElementById("box-wrapper") as HTMLElement
|
||||||
|
var shouldStickToBottom:boolean = bottom
|
||||||
|
|
||||||
div.innerHTML = ""
|
div.innerHTML = ""
|
||||||
|
|
||||||
|
if (wrapper != null && shouldStickToBottom == false) {
|
||||||
|
var distanceToBottom:number = wrapper.scrollHeight - wrapper.scrollTop - wrapper.clientHeight
|
||||||
|
if (distanceToBottom < 80) {
|
||||||
|
shouldStickToBottom = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var keys = getObjKeys(logs)
|
var keys = getObjKeys(logs)
|
||||||
|
|
||||||
keys.forEach(logID => {
|
keys.forEach(logID => {
|
||||||
@@ -44,9 +53,8 @@ function showLogs(bottom:boolean) {
|
|||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
|
|
||||||
if (bottom == true) {
|
if (shouldStickToBottom == true && wrapper != null) {
|
||||||
|
|
||||||
var wrapper = document.getElementById("box-wrapper");
|
|
||||||
wrapper.scrollTop = wrapper.scrollHeight;
|
wrapper.scrollTop = wrapper.scrollHeight;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
323
ts/menu_ts.ts
323
ts/menu_ts.ts
@@ -37,6 +37,7 @@ class MainMenuItem extends MainMenu {
|
|||||||
var item = document.createElement("LI")
|
var item = document.createElement("LI")
|
||||||
item.setAttribute("onclick", "javascript: openThisMenu(this)")
|
item.setAttribute("onclick", "javascript: openThisMenu(this)")
|
||||||
item.setAttribute("id", this.id)
|
item.setAttribute("id", this.id)
|
||||||
|
item.setAttribute("data-menu", this.menuKey)
|
||||||
var img = this.createIMG(this.imgSrc)
|
var img = this.createIMG(this.imgSrc)
|
||||||
var value = this.createValue(this.value)
|
var value = this.createValue(this.value)
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ class MainMenuItem extends MainMenu {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case "mapping":
|
case "mapping":
|
||||||
this.tableHeader = ["BULK", "{{.mapping.table.chNo}}", "{{.mapping.table.logo}}", "{{.mapping.table.channelName}}", "{{.mapping.table.playlist}}", "{{.mapping.table.groupTitle}}", "{{.mapping.table.xmltvFile}}", "{{.mapping.table.xmltvID}}"]
|
this.tableHeader = ["BULK", "{{.mapping.table.chNo}}", "{{.mapping.table.logo}}", "{{.mapping.table.channelName}}", "{{.mapping.table.playlist}}", "{{.mapping.table.groupTitle}}", "{{.mapping.table.xmltvFile}}", "{{.mapping.table.xmltvID}}", "{{.mapping.table.edit}}"]
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -424,11 +425,7 @@ class Content {
|
|||||||
cell.child = true
|
cell.child = true
|
||||||
cell.childType = "IMG"
|
cell.childType = "IMG"
|
||||||
cell.imageURL = data[key]["tvg-logo"]
|
cell.imageURL = data[key]["tvg-logo"]
|
||||||
var td = cell.createCell()
|
tr.appendChild(cell.createCell())
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
|
||||||
td.id = key
|
|
||||||
|
|
||||||
tr.appendChild(td)
|
|
||||||
|
|
||||||
// Kanalname
|
// Kanalname
|
||||||
var cell:Cell = new Cell()
|
var cell:Cell = new Cell()
|
||||||
@@ -436,10 +433,7 @@ class Content {
|
|||||||
cell.childType = "P"
|
cell.childType = "P"
|
||||||
cell.className = data[key]["x-category"]
|
cell.className = data[key]["x-category"]
|
||||||
cell.value = data[key]["x-name"]
|
cell.value = data[key]["x-name"]
|
||||||
var td = cell.createCell()
|
tr.appendChild(cell.createCell())
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
|
||||||
td.id = key
|
|
||||||
tr.appendChild(td)
|
|
||||||
|
|
||||||
|
|
||||||
// Playlist
|
// Playlist
|
||||||
@@ -448,10 +442,7 @@ class Content {
|
|||||||
cell.childType = "P"
|
cell.childType = "P"
|
||||||
//cell.value = data[key]["_file.m3u.name"]
|
//cell.value = data[key]["_file.m3u.name"]
|
||||||
cell.value = getValueFromProviderFile(data[key]["_file.m3u.id"], "m3u", "name")
|
cell.value = getValueFromProviderFile(data[key]["_file.m3u.id"], "m3u", "name")
|
||||||
var td = cell.createCell()
|
tr.appendChild(cell.createCell())
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
|
||||||
td.id = key
|
|
||||||
tr.appendChild(td)
|
|
||||||
|
|
||||||
|
|
||||||
// Gruppe (group-title)
|
// Gruppe (group-title)
|
||||||
@@ -459,10 +450,7 @@ class Content {
|
|||||||
cell.child = true
|
cell.child = true
|
||||||
cell.childType = "P"
|
cell.childType = "P"
|
||||||
cell.value = data[key]["x-group-title"]
|
cell.value = data[key]["x-group-title"]
|
||||||
var td = cell.createCell()
|
tr.appendChild(cell.createCell())
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
|
||||||
td.id = key
|
|
||||||
tr.appendChild(td)
|
|
||||||
|
|
||||||
// XMLTV Datei
|
// XMLTV Datei
|
||||||
var cell:Cell = new Cell()
|
var cell:Cell = new Cell()
|
||||||
@@ -475,10 +463,7 @@ class Content {
|
|||||||
cell.value = data[key]["x-xmltv-file"]
|
cell.value = data[key]["x-xmltv-file"]
|
||||||
}
|
}
|
||||||
|
|
||||||
var td = cell.createCell()
|
tr.appendChild(cell.createCell())
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
|
||||||
td.id = key
|
|
||||||
tr.appendChild(td)
|
|
||||||
|
|
||||||
// XMLTV Kanal
|
// XMLTV Kanal
|
||||||
var cell:Cell = new Cell()
|
var cell:Cell = new Cell()
|
||||||
@@ -490,11 +475,18 @@ class Content {
|
|||||||
value = data[key]["x-mapping"].substring(0, 20) + "..."
|
value = data[key]["x-mapping"].substring(0, 20) + "..."
|
||||||
}
|
}
|
||||||
cell.value = value
|
cell.value = value
|
||||||
var td = cell.createCell()
|
tr.appendChild(cell.createCell())
|
||||||
td.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
|
||||||
td.id = key
|
|
||||||
|
|
||||||
tr.appendChild(td)
|
var cell:Cell = new Cell()
|
||||||
|
cell.child = true
|
||||||
|
cell.childType = "EDIT"
|
||||||
|
cell.value = "{{.button.edit}}"
|
||||||
|
var editTd = cell.createCell()
|
||||||
|
var editButton = (editTd.firstChild as HTMLInputElement)
|
||||||
|
editButton.setAttribute('onclick', 'javascript: openPopUp("mapping", this)')
|
||||||
|
editButton.setAttribute("id", key)
|
||||||
|
editButton.setAttribute("aria-label", "Edit " + data[key]["x-name"])
|
||||||
|
tr.appendChild(editTd)
|
||||||
|
|
||||||
rows.push(tr)
|
rows.push(tr)
|
||||||
});
|
});
|
||||||
@@ -561,6 +553,9 @@ class Cell {
|
|||||||
(element as HTMLInputElement).checked = this.value;
|
(element as HTMLInputElement).checked = this.value;
|
||||||
(element as HTMLInputElement).type = "checkbox";
|
(element as HTMLInputElement).type = "checkbox";
|
||||||
(element as HTMLInputElement).className = "bulk hideBulk";
|
(element as HTMLInputElement).className = "bulk hideBulk";
|
||||||
|
(element as HTMLInputElement).addEventListener("click", function(event) {
|
||||||
|
scheduleChannelRangeSelection((element as HTMLInputElement), (event as MouseEvent))
|
||||||
|
})
|
||||||
break
|
break
|
||||||
|
|
||||||
case "BULK_HEAD":
|
case "BULK_HEAD":
|
||||||
@@ -578,6 +573,14 @@ class Cell {
|
|||||||
element.setAttribute("onerror", "javascript: this.onerror=null;this.src=''" )
|
element.setAttribute("onerror", "javascript: this.onerror=null;this.src=''" )
|
||||||
//onerror="this.onerror=null;this.src='missing.gif';"
|
//onerror="this.onerror=null;this.src='missing.gif';"
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case "EDIT":
|
||||||
|
element = document.createElement("INPUT");
|
||||||
|
(element as HTMLInputElement).type = "button";
|
||||||
|
(element as HTMLInputElement).value = this.value;
|
||||||
|
(element as HTMLInputElement).className = "mapping-edit-button";
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
td.appendChild(element)
|
td.appendChild(element)
|
||||||
@@ -683,7 +686,7 @@ class ShowContent extends Content {
|
|||||||
input.setAttribute("id", "searchMapping")
|
input.setAttribute("id", "searchMapping")
|
||||||
input.setAttribute("placeholder", "{{.button.search}}")
|
input.setAttribute("placeholder", "{{.button.search}}")
|
||||||
input.className = "search"
|
input.className = "search"
|
||||||
input.setAttribute("onchange", 'javascript: searchInMapping()')
|
input.setAttribute("oninput", 'javascript: searchInMapping()')
|
||||||
interaction.appendChild(input)
|
interaction.appendChild(input)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -824,16 +827,227 @@ class ShowContent extends Content {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var SHELL_LAYOUT_READY:boolean = false
|
||||||
|
|
||||||
|
function setLayoutMenuState(open:boolean) {
|
||||||
|
if (document.body == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open == true) {
|
||||||
|
document.body.classList.add("menu-open")
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove("menu-open")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleLayoutMenu() {
|
||||||
|
if (document.body == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var isOpen:boolean = document.body.classList.contains("menu-open")
|
||||||
|
setLayoutMenuState(!isOpen)
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeLayoutMenuIfMobile() {
|
||||||
|
if (window.innerWidth <= 900) {
|
||||||
|
setLayoutMenuState(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setActiveMenu(menuID:string) {
|
||||||
|
|
||||||
|
ACTIVE_MENU_ID = menuID.toString()
|
||||||
|
var menu = document.getElementById("main-menu")
|
||||||
|
if (menu == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = menu.getElementsByTagName("LI")
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
items[i].classList.remove("menu-active")
|
||||||
|
}
|
||||||
|
|
||||||
|
var activeItem = document.getElementById(ACTIVE_MENU_ID)
|
||||||
|
var activeMenuKey:string = ""
|
||||||
|
if (activeItem != null) {
|
||||||
|
activeItem.classList.add("menu-active")
|
||||||
|
var menuKeyValue = activeItem.getAttribute("data-menu")
|
||||||
|
if (menuKeyValue != null) {
|
||||||
|
activeMenuKey = menuKeyValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.body != null) {
|
||||||
|
if (activeMenuKey.length > 0) {
|
||||||
|
document.body.setAttribute("data-active-menu", activeMenuKey)
|
||||||
|
} else {
|
||||||
|
document.body.removeAttribute("data-active-menu")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeMenuKey == "log") {
|
||||||
|
document.body.classList.add("menu-log-focus")
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove("menu-log-focus")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderStatusCards() {
|
||||||
|
var wrapper = document.getElementById("status-cards")
|
||||||
|
if (wrapper == null || SERVER.hasOwnProperty("clientInfo") == false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var info = SERVER["clientInfo"]
|
||||||
|
var errors:number = parseInt(info["errors"], 10)
|
||||||
|
var warnings:number = parseInt(info["warnings"], 10)
|
||||||
|
var cards:any[] = [
|
||||||
|
{label: "Streams", value: info["streams"], tone: "ok"},
|
||||||
|
{label: "EPG Source", value: info["epgSource"], tone: "neutral"},
|
||||||
|
{label: "XEPG Channels", value: info["xepg"], tone: "ok"},
|
||||||
|
{label: "Errors", value: info["errors"], tone: errors > 0 ? "error" : "ok"},
|
||||||
|
{label: "Warnings", value: info["warnings"], tone: warnings > 0 ? "warn" : "ok"},
|
||||||
|
{label: "DVR", value: info["DVR"], tone: "neutral"},
|
||||||
|
]
|
||||||
|
|
||||||
|
wrapper.innerHTML = ""
|
||||||
|
cards.forEach(card => {
|
||||||
|
|
||||||
|
var box = document.createElement("DIV")
|
||||||
|
box.className = "status-card status-card-" + card.tone
|
||||||
|
|
||||||
|
var label = document.createElement("P")
|
||||||
|
label.className = "status-card-label"
|
||||||
|
label.innerText = card.label
|
||||||
|
|
||||||
|
var value = document.createElement("P")
|
||||||
|
value.className = "status-card-value"
|
||||||
|
if (card.value == undefined || card.value == "") {
|
||||||
|
value.innerText = "-"
|
||||||
|
} else {
|
||||||
|
value.innerText = card.value
|
||||||
|
}
|
||||||
|
|
||||||
|
box.appendChild(label)
|
||||||
|
box.appendChild(value)
|
||||||
|
wrapper.appendChild(box)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function initShellLayout() {
|
||||||
|
|
||||||
|
if (SHELL_LAYOUT_READY == true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var toggle = document.getElementById("menu-toggle")
|
||||||
|
if (toggle != null) {
|
||||||
|
toggle.onclick = function() {
|
||||||
|
toggleLayoutMenu()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var overlay = document.getElementById("layout-overlay")
|
||||||
|
if (overlay != null) {
|
||||||
|
overlay.onclick = function() {
|
||||||
|
setLayoutMenuState(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("keydown", function(event) {
|
||||||
|
|
||||||
|
if (event.key == "Escape") {
|
||||||
|
setLayoutMenuState(false)
|
||||||
|
showElement("popup", false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.key == "/") {
|
||||||
|
var target = event.target as HTMLElement
|
||||||
|
var onInput = target.tagName == "INPUT" || target.tagName == "TEXTAREA" || target.tagName == "SELECT"
|
||||||
|
|
||||||
|
if (onInput == true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var search = document.getElementById("searchMapping")
|
||||||
|
if (search != null) {
|
||||||
|
event.preventDefault()
|
||||||
|
(search as HTMLInputElement).focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
setConnectionState("idle")
|
||||||
|
SHELL_LAYOUT_READY = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldPollLogs():boolean {
|
||||||
|
if (document.hidden == true) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.getElementById("content_log") == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ACTIVE_MENU_ID.length < 1) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var activeItem = document.getElementById(ACTIVE_MENU_ID)
|
||||||
|
if (activeItem == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return activeItem.getAttribute("data-menu") == "log"
|
||||||
|
}
|
||||||
|
|
||||||
function PageReady() {
|
function PageReady() {
|
||||||
|
|
||||||
|
initShellLayout()
|
||||||
|
|
||||||
var server:Server = new Server("getServerConfig")
|
var server:Server = new Server("getServerConfig")
|
||||||
server.request(new Object())
|
server.request(new Object())
|
||||||
|
|
||||||
|
var bootstrapAttempts:number = 0
|
||||||
|
var maxBootstrapAttempts:number = 5
|
||||||
|
var bootstrapTimer:number = window.setInterval(function() {
|
||||||
|
|
||||||
|
if (SERVER.hasOwnProperty("clientInfo") == true) {
|
||||||
|
window.clearInterval(bootstrapTimer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SERVER_CONNECTION == true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrapAttempts++
|
||||||
|
var retryServer:Server = new Server("getServerConfig")
|
||||||
|
retryServer.request(new Object())
|
||||||
|
|
||||||
|
if (bootstrapAttempts >= maxBootstrapAttempts) {
|
||||||
|
window.clearInterval(bootstrapTimer)
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 3000)
|
||||||
|
|
||||||
window.addEventListener("resize", function(){
|
window.addEventListener("resize", function(){
|
||||||
|
if (window.innerWidth > 900) {
|
||||||
|
setLayoutMenuState(false)
|
||||||
|
}
|
||||||
calculateWrapperHeight();
|
calculateWrapperHeight();
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
|
if (shouldPollLogs() == false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
updateLog()
|
updateLog()
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
@@ -841,6 +1055,35 @@ function PageReady() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isClientInfoHttpURL(value:string):boolean {
|
||||||
|
return /^https?:\/\//i.test(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setClientInfoValue(key:string, value:any) {
|
||||||
|
var element = document.getElementById(key)
|
||||||
|
if (element == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var textValue = ""
|
||||||
|
if (value != undefined && value != null) {
|
||||||
|
textValue = String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((key == "m3u-url" || key == "xepg-url") && isClientInfoHttpURL(textValue)) {
|
||||||
|
element.innerHTML = ""
|
||||||
|
var anchor = document.createElement("A")
|
||||||
|
anchor.href = textValue
|
||||||
|
anchor.target = "_blank"
|
||||||
|
anchor.rel = "noopener noreferrer"
|
||||||
|
anchor.textContent = textValue
|
||||||
|
element.appendChild(anchor)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
element.innerHTML = textValue
|
||||||
|
}
|
||||||
|
|
||||||
function createLayout() {
|
function createLayout() {
|
||||||
|
|
||||||
// Client Info
|
// Client Info
|
||||||
@@ -848,11 +1091,10 @@ function createLayout() {
|
|||||||
var keys = getObjKeys(obj);
|
var keys = getObjKeys(obj);
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
|
||||||
if (document.getElementById(keys[i])) {
|
setClientInfoValue(keys[i], obj[keys[i]])
|
||||||
document.getElementById(keys[i]).innerHTML = obj[keys[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
renderStatusCards()
|
||||||
|
|
||||||
if (!document.getElementById("main-menu")) {
|
if (!document.getElementById("main-menu")) {
|
||||||
return
|
return
|
||||||
@@ -889,13 +1131,32 @@ function createLayout() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ACTIVE_MENU_ID.length > 0 && document.getElementById(ACTIVE_MENU_ID)) {
|
||||||
|
setActiveMenu(ACTIVE_MENU_ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = document.getElementById("content")
|
||||||
|
var menu = document.getElementById("main-menu")
|
||||||
|
if (ACTIVE_MENU_ID.length == 0 && content != null && menu != null) {
|
||||||
|
|
||||||
|
if (content.innerHTML.replace(/\\s/g, "").length == 0) {
|
||||||
|
var firstItem = menu.getElementsByTagName("LI")[0]
|
||||||
|
if (firstItem != undefined) {
|
||||||
|
firstItem.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
function openThisMenu(element) {
|
function openThisMenu(element) {
|
||||||
var id = element.id
|
var id = element.id
|
||||||
var content:ShowContent = new ShowContent(id)
|
var content:ShowContent = new ShowContent(id)
|
||||||
|
setActiveMenu(id)
|
||||||
content.show()
|
content.show()
|
||||||
|
closeLayoutMenuIfMobile()
|
||||||
calculateWrapperHeight()
|
calculateWrapperHeight()
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -1568,7 +1829,7 @@ function openPopUp(dataType, element) {
|
|||||||
// Erweitern der EPG Kategorie
|
// Erweitern der EPG Kategorie
|
||||||
var dbKey:string = "x-category"
|
var dbKey:string = "x-category"
|
||||||
var text:string[] = ["-", "Kids (Emby only)", "News", "Movie", "Series", "Sports"]
|
var text:string[] = ["-", "Kids (Emby only)", "News", "Movie", "Series", "Sports"]
|
||||||
var values:string[] = ["-", "Kids", "News", "Movie", "Series", "Sports"]
|
var values:string[] = ["", "Kids", "News", "Movie", "Series", "Sports"]
|
||||||
var select = content.createSelect(text, values, data[dbKey], dbKey)
|
var select = content.createSelect(text, values, data[dbKey], dbKey)
|
||||||
select.setAttribute("onchange", "javascript: this.className = 'changed'")
|
select.setAttribute("onchange", "javascript: this.className = 'changed'")
|
||||||
content.appendRow("{{.mapping.epgCategory.title}}", select)
|
content.appendRow("{{.mapping.epgCategory.title}}", select)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Server {
|
|||||||
if (this.cmd != "updateLog") {
|
if (this.cmd != "updateLog") {
|
||||||
showElement("loading", true)
|
showElement("loading", true)
|
||||||
UNDO = new Object()
|
UNDO = new Object()
|
||||||
|
setConnectionState("busy")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(window.location.protocol) {
|
switch(window.location.protocol) {
|
||||||
@@ -29,13 +30,67 @@ class Server {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = this.protocol + window.location.hostname + ":" + window.location.port + "/data/" + "?Token=" + getCookie("Token")
|
var wsHost:string = window.location.host
|
||||||
|
if (wsHost == undefined || wsHost.length < 1) {
|
||||||
|
wsHost = window.location.hostname
|
||||||
|
}
|
||||||
|
var url = this.protocol + wsHost + "/data/" + "?Token=" + getCookie("Token")
|
||||||
|
|
||||||
data["cmd"] = this.cmd
|
data["cmd"] = this.cmd
|
||||||
|
var requestCmd:string = data["cmd"]
|
||||||
var ws = new WebSocket(url)
|
var ws = new WebSocket(url)
|
||||||
|
var isLogUpdate:boolean = data["cmd"] == "updateLog"
|
||||||
|
var responseReceived:boolean = false
|
||||||
|
var requestFinished:boolean = false
|
||||||
|
var timeoutMs:number = 12000
|
||||||
|
var requestTimeout:number
|
||||||
|
|
||||||
|
var finishRequest = function(state:string, responseSuccess:boolean = false):void {
|
||||||
|
if (requestFinished == true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
requestFinished = true
|
||||||
|
SERVER_CONNECTION = false
|
||||||
|
window.clearTimeout(requestTimeout)
|
||||||
|
|
||||||
|
if (responseSuccess == true) {
|
||||||
|
if (state == "online") {
|
||||||
|
WS_FAILURE_COUNT = 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
WS_FAILURE_COUNT++
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLogUpdate == false) {
|
||||||
|
showElement("loading", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != "") {
|
||||||
|
setConnectionState(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
requestTimeout = window.setTimeout(function() {
|
||||||
|
console.log("Websocket request timed out.")
|
||||||
|
var timeoutState:string = "offline"
|
||||||
|
if (isLogUpdate == true && WS_FAILURE_COUNT < 2) {
|
||||||
|
timeoutState = "idle"
|
||||||
|
}
|
||||||
|
finishRequest(timeoutState, false)
|
||||||
|
try {
|
||||||
|
ws.close()
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
}, timeoutMs)
|
||||||
|
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
|
|
||||||
WS_AVAILABLE = true
|
WS_AVAILABLE = true
|
||||||
|
if (data["cmd"] != "updateLog") {
|
||||||
|
setConnectionState("busy")
|
||||||
|
}
|
||||||
|
|
||||||
console.log("REQUEST (JS):");
|
console.log("REQUEST (JS):");
|
||||||
console.log(data)
|
console.log(data)
|
||||||
@@ -50,9 +105,13 @@ class Server {
|
|||||||
ws.onerror = function(e) {
|
ws.onerror = function(e) {
|
||||||
|
|
||||||
console.log("No websocket connection to xTeVe could be established. Check your network configuration.")
|
console.log("No websocket connection to xTeVe could be established. Check your network configuration.")
|
||||||
SERVER_CONNECTION = false
|
var errorState:string = "offline"
|
||||||
|
if (isLogUpdate == true && WS_FAILURE_COUNT < 2) {
|
||||||
|
errorState = "idle"
|
||||||
|
}
|
||||||
|
finishRequest(errorState, false)
|
||||||
|
|
||||||
if (WS_AVAILABLE == false) {
|
if (WS_AVAILABLE == false && isLogUpdate == false && requestCmd != "getServerConfig") {
|
||||||
alert("No websocket connection to xTeVe could be established. Check your network configuration.")
|
alert("No websocket connection to xTeVe could be established. Check your network configuration.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +119,8 @@ class Server {
|
|||||||
|
|
||||||
|
|
||||||
ws.onmessage = function (e) {
|
ws.onmessage = function (e) {
|
||||||
|
responseReceived = true
|
||||||
SERVER_CONNECTION = false
|
finishRequest("online", true)
|
||||||
showElement("loading", false)
|
|
||||||
|
|
||||||
console.log("RESPONSE:");
|
console.log("RESPONSE:");
|
||||||
var response = JSON.parse(e.data);
|
var response = JSON.parse(e.data);
|
||||||
@@ -74,6 +132,7 @@ class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response["status"] == false) {
|
if (response["status"] == false) {
|
||||||
|
setConnectionState("offline")
|
||||||
|
|
||||||
alert(response["err"])
|
alert(response["err"])
|
||||||
|
|
||||||
@@ -136,10 +195,24 @@ class Server {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws.onclose = function() {
|
||||||
|
if (responseReceived == true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var closeState:string = "offline"
|
||||||
|
if (isLogUpdate == true && WS_FAILURE_COUNT < 2) {
|
||||||
|
closeState = "idle"
|
||||||
|
}
|
||||||
|
finishRequest(closeState, false)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var WS_FAILURE_COUNT:number = 0
|
||||||
|
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
var value = "; " + document.cookie;
|
var value = "; " + document.cookie;
|
||||||
var parts = value.split("; " + name + "=");
|
var parts = value.split("; " + name + "=");
|
||||||
|
|||||||
@@ -75,6 +75,35 @@ class SettingsCategory {
|
|||||||
setting.appendChild(tdRight)
|
setting.appendChild(tdRight)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case "plex.url":
|
||||||
|
var tdLeft = document.createElement("TD")
|
||||||
|
tdLeft.innerHTML = "{{.settings.plexURL.title}}" + ":"
|
||||||
|
|
||||||
|
var tdRight = document.createElement("TD")
|
||||||
|
var input = content.createInput("text", "plex.url", data)
|
||||||
|
input.setAttribute("placeholder", "{{.settings.plexURL.placeholder}}")
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'")
|
||||||
|
tdRight.appendChild(input)
|
||||||
|
|
||||||
|
setting.appendChild(tdLeft)
|
||||||
|
setting.appendChild(tdRight)
|
||||||
|
break
|
||||||
|
|
||||||
|
case "plex.token":
|
||||||
|
var tdLeft = document.createElement("TD")
|
||||||
|
tdLeft.innerHTML = "{{.settings.plexToken.title}}" + ":"
|
||||||
|
|
||||||
|
var tdRight = document.createElement("TD")
|
||||||
|
var input = content.createInput("password", "plex.token", data)
|
||||||
|
input.setAttribute("placeholder", "{{.settings.plexToken.placeholder}}")
|
||||||
|
input.setAttribute("autocomplete", "off")
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'")
|
||||||
|
tdRight.appendChild(input)
|
||||||
|
|
||||||
|
setting.appendChild(tdLeft)
|
||||||
|
setting.appendChild(tdRight)
|
||||||
|
break
|
||||||
|
|
||||||
case "buffer.timeout":
|
case "buffer.timeout":
|
||||||
var tdLeft = document.createElement("TD")
|
var tdLeft = document.createElement("TD")
|
||||||
tdLeft.innerHTML = "{{.settings.bufferTimeout.title}}" + ":"
|
tdLeft.innerHTML = "{{.settings.bufferTimeout.title}}" + ":"
|
||||||
@@ -286,10 +315,40 @@ class SettingsCategory {
|
|||||||
setting.appendChild(tdRight)
|
setting.appendChild(tdRight)
|
||||||
break
|
break
|
||||||
|
|
||||||
// Select
|
case "use_plexAPI":
|
||||||
case "tuner":
|
var tdLeft = document.createElement("TD")
|
||||||
var tdLeft = document.createElement("TD")
|
tdLeft.innerHTML = "{{.settings.usePlexAPI.title}}" + ":"
|
||||||
tdLeft.innerHTML = "{{.settings.tuner.title}}" + ":"
|
|
||||||
|
var tdRight = document.createElement("TD")
|
||||||
|
var input = content.createCheckbox(settingsKey)
|
||||||
|
input.checked = data
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'")
|
||||||
|
tdRight.appendChild(input)
|
||||||
|
|
||||||
|
setting.appendChild(tdLeft)
|
||||||
|
setting.appendChild(tdRight)
|
||||||
|
break
|
||||||
|
|
||||||
|
// Select
|
||||||
|
case "xepg.missing.epg.mode":
|
||||||
|
var tdLeft = document.createElement("TD")
|
||||||
|
tdLeft.innerHTML = "{{.settings.xepgMissingEPGMode.title}}" + ":"
|
||||||
|
|
||||||
|
var tdRight = document.createElement("TD")
|
||||||
|
var text:any[] = ["{{.settings.xepgMissingEPGMode.info_strict}}", "{{.settings.xepgMissingEPGMode.info_relaxed}}"]
|
||||||
|
var values:any[] = ["strict", "relaxed"]
|
||||||
|
|
||||||
|
var select = content.createSelect(text, values, data, settingsKey)
|
||||||
|
select.setAttribute("onchange", "javascript: this.className = 'changed'")
|
||||||
|
tdRight.appendChild(select)
|
||||||
|
|
||||||
|
setting.appendChild(tdLeft)
|
||||||
|
setting.appendChild(tdRight)
|
||||||
|
break
|
||||||
|
|
||||||
|
case "tuner":
|
||||||
|
var tdLeft = document.createElement("TD")
|
||||||
|
tdLeft.innerHTML = "{{.settings.tuner.title}}" + ":"
|
||||||
|
|
||||||
var tdRight = document.createElement("TD")
|
var tdRight = document.createElement("TD")
|
||||||
var text = new Array()
|
var text = new Array()
|
||||||
@@ -372,33 +431,16 @@ class SettingsCategory {
|
|||||||
setting.appendChild(tdRight)
|
setting.appendChild(tdRight)
|
||||||
break
|
break
|
||||||
|
|
||||||
case "scheme.m3u":
|
case "udpxy":
|
||||||
var tdLeft = document.createElement("TD")
|
|
||||||
tdLeft.innerHTML = "{{.settings.schemeM3U.title}}" + ":"
|
var tdLeft = document.createElement("TD");
|
||||||
|
tdLeft.innerHTML = "{{.settings.udpxy.title}}" + ":"
|
||||||
|
|
||||||
var tdRight = document.createElement("TD")
|
var tdRight = document.createElement("TD")
|
||||||
var text:any[] = ["HTTP", "HTTPS"]
|
var input = content.createInput("text", "udpxy", data)
|
||||||
var values:any[] = ["HTTP", "HTTPS"]
|
input.setAttribute("placeholder", "{{.settings.udpxy.placeholder}}")
|
||||||
|
input.setAttribute("onchange", "javascript: this.className = 'changed'")
|
||||||
var select = content.createSelect(text, values, data, settingsKey)
|
tdRight.appendChild(input)
|
||||||
select.setAttribute("onchange", "javascript: this.className = 'changed'")
|
|
||||||
tdRight.appendChild(select)
|
|
||||||
|
|
||||||
setting.appendChild(tdLeft)
|
|
||||||
setting.appendChild(tdRight)
|
|
||||||
break
|
|
||||||
|
|
||||||
case "scheme.xml":
|
|
||||||
var tdLeft = document.createElement("TD")
|
|
||||||
tdLeft.innerHTML = "{{.settings.schemeXML.title}}" + ":"
|
|
||||||
|
|
||||||
var tdRight = document.createElement("TD")
|
|
||||||
var text:any[] = ["HTTP", "HTTPS"]
|
|
||||||
var values:any[] = ["HTTP", "HTTPS"]
|
|
||||||
|
|
||||||
var select = content.createSelect(text, values, data, settingsKey)
|
|
||||||
select.setAttribute("onchange", "javascript: this.className = 'changed'")
|
|
||||||
tdRight.appendChild(select)
|
|
||||||
|
|
||||||
setting.appendChild(tdLeft)
|
setting.appendChild(tdLeft)
|
||||||
setting.appendChild(tdRight)
|
setting.appendChild(tdRight)
|
||||||
@@ -471,6 +513,14 @@ class SettingsCategory {
|
|||||||
text = "{{.settings.userAgent.description}}"
|
text = "{{.settings.userAgent.description}}"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case "plex.url":
|
||||||
|
text = "{{.settings.plexURL.description}}"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "plex.token":
|
||||||
|
text = "{{.settings.plexToken.description}}"
|
||||||
|
break
|
||||||
|
|
||||||
case "ffmpeg.path":
|
case "ffmpeg.path":
|
||||||
text = "{{.settings.ffmpegPath.description}}"
|
text = "{{.settings.ffmpegPath.description}}"
|
||||||
break
|
break
|
||||||
@@ -503,6 +553,10 @@ class SettingsCategory {
|
|||||||
text = "{{.settings.api.description}}"
|
text = "{{.settings.api.description}}"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case "use_plexAPI":
|
||||||
|
text = "{{.settings.usePlexAPI.description}}"
|
||||||
|
break
|
||||||
|
|
||||||
case "files.update":
|
case "files.update":
|
||||||
text = "{{.settings.filesUpdate.description}}"
|
text = "{{.settings.filesUpdate.description}}"
|
||||||
break
|
break
|
||||||
@@ -511,19 +565,18 @@ class SettingsCategory {
|
|||||||
text = "{{.settings.cacheImages.description}}"
|
text = "{{.settings.cacheImages.description}}"
|
||||||
break
|
break
|
||||||
|
|
||||||
case "xepg.replace.missing.images":
|
case "xepg.replace.missing.images":
|
||||||
text = "{{.settings.replaceEmptyImages.description}}"
|
text = "{{.settings.replaceEmptyImages.description}}"
|
||||||
break
|
break
|
||||||
|
|
||||||
case "scheme.m3u":
|
case "xepg.missing.epg.mode":
|
||||||
text = "{{.settings.schemeM3U.description}}"
|
text = "{{.settings.xepgMissingEPGMode.description}}"
|
||||||
break
|
break
|
||||||
|
|
||||||
case "scheme.xml":
|
case "udpxy":
|
||||||
text = "{{.settings.schemeXML.description}}"
|
text = "{{.settings.udpxy.description}}"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
text = ""
|
text = ""
|
||||||
break
|
break
|
||||||
|
|||||||
15
xteve.go
15
xteve.go
@@ -13,7 +13,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"./src"
|
"xteve/src"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GitHubStruct : GitHub Account. Über diesen Account werden die Updates veröffentlicht
|
// GitHubStruct : GitHub Account. Über diesen Account werden die Updates veröffentlicht
|
||||||
@@ -39,7 +39,8 @@ var GitHub = GitHubStruct{Branch: "master", User: "xteve-project", Repo: "xTeVe-
|
|||||||
const Name = "xTeVe"
|
const Name = "xTeVe"
|
||||||
|
|
||||||
// Version : Version, die Build Nummer wird in der main func geparst.
|
// Version : Version, die Build Nummer wird in der main func geparst.
|
||||||
const Version = "2.1.1.0111"
|
// Can be overwritten at build time: -ldflags "-X main.Version=..."
|
||||||
|
var Version = "2.2.0.0200"
|
||||||
|
|
||||||
// DBVersion : Datanbank Version
|
// DBVersion : Datanbank Version
|
||||||
const DBVersion = "2.1.0"
|
const DBVersion = "2.1.0"
|
||||||
@@ -47,9 +48,6 @@ const DBVersion = "2.1.0"
|
|||||||
// APIVersion : API Version
|
// APIVersion : API Version
|
||||||
const APIVersion = "1.1.0"
|
const APIVersion = "1.1.0"
|
||||||
|
|
||||||
// Dev : Aktiviert den Entwicklungsmodus. Für den Webserver werden dann die lokalen Dateien verwendet.
|
|
||||||
const Dev = false
|
|
||||||
|
|
||||||
var homeDirectory = fmt.Sprintf("%s%s.%s%s", src.GetUserHomeDirectory(), string(os.PathSeparator), strings.ToLower(Name), string(os.PathSeparator))
|
var homeDirectory = fmt.Sprintf("%s%s.%s%s", src.GetUserHomeDirectory(), string(os.PathSeparator), strings.ToLower(Name), string(os.PathSeparator))
|
||||||
var samplePath = fmt.Sprintf("%spath%sto%sxteve%s", string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator))
|
var samplePath = fmt.Sprintf("%spath%sto%sxteve%s", string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator))
|
||||||
var sampleRestore = fmt.Sprintf("%spath%sto%sfile%s", string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator))
|
var sampleRestore = fmt.Sprintf("%spath%sto%sfile%s", string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator), string(os.PathSeparator))
|
||||||
@@ -63,6 +61,9 @@ var debug = flag.Int("debug", 0, ": Debug level [0 - 3] (default: 0)")
|
|||||||
var info = flag.Bool("info", false, ": Show system info")
|
var info = flag.Bool("info", false, ": Show system info")
|
||||||
var h = flag.Bool("h", false, ": Show help")
|
var h = flag.Bool("h", false, ": Show help")
|
||||||
|
|
||||||
|
// Aktiviert den Entwicklungsmodus. Für den Webserver werden dann die lokalen Dateien verwendet.
|
||||||
|
var dev = flag.Bool("dev", false, ": Activates the developer mode, the source code must be available. The local files for the web interface are used.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Build-Nummer von der Versionsnummer trennen
|
// Build-Nummer von der Versionsnummer trennen
|
||||||
@@ -73,7 +74,6 @@ func main() {
|
|||||||
system.Branch = GitHub.Branch
|
system.Branch = GitHub.Branch
|
||||||
system.Build = build[len(build)-1:][0]
|
system.Build = build[len(build)-1:][0]
|
||||||
system.DBVersion = DBVersion
|
system.DBVersion = DBVersion
|
||||||
system.Dev = Dev
|
|
||||||
system.GitHub = GitHub
|
system.GitHub = GitHub
|
||||||
system.Name = Name
|
system.Name = Name
|
||||||
system.Version = strings.Join(build[0:len(build)-1], ".")
|
system.Version = strings.Join(build[0:len(build)-1], ".")
|
||||||
@@ -122,6 +122,8 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
system.Dev = *dev
|
||||||
|
|
||||||
// Systeminformationen anzeigen
|
// Systeminformationen anzeigen
|
||||||
if *info {
|
if *info {
|
||||||
|
|
||||||
@@ -189,7 +191,6 @@ func main() {
|
|||||||
err = src.BinaryUpdate()
|
err = src.BinaryUpdate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
src.ShowError(err, 0)
|
src.ShowError(err, 0)
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = src.StartSystem(false)
|
err = src.StartSystem(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user