Skip to content

Commit

Permalink
edit changelog & default config
Browse files Browse the repository at this point in the history
fix https option
  • Loading branch information
mejgun committed Sep 20, 2024
1 parent 1d71cda commit 338d649
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 35 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
- app refactored & reworked

## 2.0.0 - 2024-09-20
app refactored & reworked
### Added
- direct extractor (returning same url)
- per site settings
- direct/no extractor (returning same url)
- json format logs
- disabling logs
- force https links to extractor options
- host setting in config
- stripping (bad) http(s) prefix in url
- os signals catching
- config reload (SIGHUP)
### Changed
- default config name from "config.json" to "config.jsonc"

## 1.6.0 - 2024-09-13
### Added
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,4 @@ This is yt-dlp based video restreamer, part of another project: https://github.c

### Options ###

Run with `--help`

### Exit codes ###

- 0 - OK
- 1 - config read/parse error
- 2 - logger create error
- 3 - extractor create error
- 4 - streamer create error
- 5 - web server error
- 6 - links cache error
Run with `--help`
86 changes: 69 additions & 17 deletions config.example.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@
// web server listen port.
// DEFAULT 8080
"port": 8080,
// restreamer config.
// logger config
"log": {
// log level
// debug/info/warning/error/nothing
// DEFAULT "info"
"level": "info",
// log destination
// stdout/file/both
// DEFAULT "stdout"
"output": "stdout",
// filename if writing to file
// DEFAULT "log.txt"
"filename": "log.txt",
// set output to json format
// DEFAULT false
"json": false
},
// default restreamer config.
// restreamer takes https stream and restream it as http.
"streamer": {
// show errors in headers (insecure).
Expand Down Expand Up @@ -49,48 +66,83 @@
// DEFAULT "TLS 1.2"
"min-tls-version": "TLS 1.2"
},
// media extractor config
// default media extractor config
"extractor": {
// file path
// "direct" - do not use extractor, just pass url to streamer
// DEFAULT "yt-dlp"
"path": "yt-dlp",
// arguments for extractor
// args separator is ",,", not space
// {{.HEIGHT}} will be replaced with requested height (360/480/720)
// {{.URL}} will be replace with requested url
// also you can use {{.FORMAT}} - requested format (now - only mp4 or m4a)
// DEFAULT "-f,,(mp4)[height<={{.HEIGHT}}],,-g,,{{.URL}}",
"mp4": "-f,,(mp4)[height<={{.HEIGHT}}],,-g,,{{.URL}}",
// same for m4a
// DEFAULT "-f,,(m4a),,-g,,{{.URL}}",
"m4a": "-f,,(m4a),,-g,,{{.URL}}",
// args for getting user-agent
// DEFAULT "--dump-user-agent"
"get-user-agent": "--dump-user-agent",
// add "https://" to links passed to extractor
// DEFAULT true
"force-https": true,
// custom options list to extractor, like proxy, etc.
// same rules as mp4/m4a
// HEIGHT/URL/.. templates also can be used
// "custom-options": []
// DEFAULT []
"custom-options": [
"--option1,,value1",
"--option2",
"value2",
"--option3",
"very long value 3"
"very long value 3",
"--option4,,very long value 4"
]
},
// logger config
"log": {
// log level
// debug/info/warning/error/nothing
"level": "info",
// log destination
// stdout/file/both
"output": "stdout",
// filename if writing to file
"filename": "log.txt"
},
// links cache config
// default links cache config
"cache": {
// links expire time
// time units are "s", "m", "h", e.g. "1h10m10s", "10h", "1s"
// "0s" will disable cache
// DEFAULT "3h"
"expire-time": "3h"
}
},
// per site configs for streamer, extractor and cache.
// absent options will be set from default part.
// only exact matching domains will be affected.
// e.g. "site.com/video" matching "site.com"
// but "www.site.com/video" is not
// DEFAULT []
"sub-config": [
{
// sub config name. displayed in logs
// cannot be empty
"name": "some site",
// sites list
"sites": [
"site.com",
"a.site.com"
],
"extractor": {
"path": "my-extractor",
"mp4": "{{.URL}}"
}
},
{
"name": "my stream",
"sites": [
"my.streamer.example"
],
"extractor": {
"path": "direct"
},
"streamer": {
"error-headers": true,
"ignore-missing-headers": true,
"ignore-ssl-errors": true
}
}
]
}
6 changes: 3 additions & 3 deletions lib/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func defaultConfig() ConfigT {
M4A: &e[2],
GetUserAgent: &e[3],
CustomOptions: &co,
ForceHttp: &tru,
ForceHttps: &tru,
},
Log: logger_config.ConfigT{
Level: &ll,
Expand Down Expand Up @@ -135,8 +135,8 @@ func appendConfig(src ConfigT, dst ConfigT) ConfigT {
if dst.Extractor.CustomOptions == nil {
dst.Extractor.CustomOptions = src.Extractor.CustomOptions
}
if dst.Extractor.ForceHttp == nil {
dst.Extractor.ForceHttp = src.Extractor.ForceHttp
if dst.Extractor.ForceHttps == nil {
dst.Extractor.ForceHttps = src.Extractor.ForceHttps
}
// logger
if dst.Log.Level == nil {
Expand Down
2 changes: 1 addition & 1 deletion lib/extractor/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type ConfigT struct {
M4A *string `json:"m4a"`
GetUserAgent *string `json:"get-user-agent"`
CustomOptions *[]string `json:"custom-options"`
ForceHttp *bool `json:"force-http"`
ForceHttps *bool `json:"force-https"`
}

type ResultT struct {
Expand Down
2 changes: 1 addition & 1 deletion lib/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func New(c extractor_config.ConfigT, log logger.T) (T, error) {
ext layer
err error
)
ext.force_http = *c.ForceHttp
ext.force_http = *c.ForceHttps
if ext.force_http {
log.LogDebug("", "force-http", true)
}
Expand Down

0 comments on commit 338d649

Please sign in to comment.