Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/JioTV-Go/jiotv_go
Browse files Browse the repository at this point in the history
  • Loading branch information
itsyourap committed Jan 23, 2025
2 parents 4eea85c + b2be6cd commit 581d2d2
Show file tree
Hide file tree
Showing 27 changed files with 2,913 additions and 2,956 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.11.0
v3.12.1
31 changes: 23 additions & 8 deletions cmd/jiotv_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,23 @@ import (
"github.com/gofiber/template/html/v2"
)

type JioTVServerConfig struct {
Host string
Port string
ConfigPath string
TLS bool
TLSCertPath string
TLSKeyPath string
}

// JioTVServer starts the JioTV server.
// It loads the config, initializes logging, secure URLs, and EPG.
// It then configures the Fiber app with middleware and routes.
// It starts listening on the provided host and port.
// Returns an error if listening fails.
func JioTVServer(host, port, configPath string, prefork bool) error {
func JioTVServer(jiotvServerConfig JioTVServerConfig) error {
// Load the config file
if err := config.Cfg.Load(configPath); err != nil {
if err := config.Cfg.Load(jiotvServerConfig.ConfigPath); err != nil {
return err
}

Expand Down Expand Up @@ -60,7 +69,7 @@ func JioTVServer(host, port, configPath string, prefork bool) error {

app := fiber.New(fiber.Config{
Views: engine,
Prefork: prefork,
Network: fiber.NetworkTCP,
StreamRequestBody: true,
CaseSensitive: false,
StrictRouting: false,
Expand All @@ -87,9 +96,6 @@ func JioTVServer(host, port, configPath string, prefork bool) error {
Browse: false,
}))

// Handle all /bpk-tv/* routes
app.Use("/bpk-tv/", handlers.BpkProxyHandler)

// Handle all /out/* routes
app.Use("/out/", handlers.SLHandler)

Expand All @@ -110,7 +116,6 @@ func JioTVServer(host, port, configPath string, prefork bool) error {
app.Get("/playlist.m3u", handlers.PlaylistHandler)
app.Get("/play/:id", handlers.PlayHandler)
app.Get("/player/:id", handlers.PlayerHandler)
app.Get("/clappr/:id", handlers.ClapprHandler)
app.Get("/favicon.ico", handlers.FaviconHandler)
app.Get("/jtvimage/:file", handlers.ImageHandler)
app.Get("/epg.xml.gz", handlers.EPGHandler)
Expand All @@ -120,5 +125,15 @@ func JioTVServer(host, port, configPath string, prefork bool) error {
app.Post("/drm", handlers.DRMKeyHandler)
app.Get("/dashtime", handlers.DASHTimeHandler)

return app.Listen(host + ":" + port)
app.Get("/render.mpd", handlers.MpdHandler)
app.Use("/render.dash", handlers.DashHandler)

if jiotvServerConfig.TLS {
if jiotvServerConfig.TLSCertPath == "" || jiotvServerConfig.TLSKeyPath == "" {
return fmt.Errorf("TLS cert and key paths are required for HTTPS. Please provide them using --tls-cert and --tls-key flags")
}
return app.ListenTLS(fmt.Sprintf("%s:%s", jiotvServerConfig.Host, jiotvServerConfig.Port), jiotvServerConfig.TLSCertPath, jiotvServerConfig.TLSKeyPath)
} else {
return app.Listen(fmt.Sprintf("%s:%s", jiotvServerConfig.Host, jiotvServerConfig.Port))
}
}
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func Update(currentVersion, customVersion string) error {
// getLatestRelease fetches the latest release information from the GitHub API for the given owner and repo.
// It returns a Release struct containing the release details like tag name, assets etc.
func getLatestRelease(customVersion string) (*Release, error) {
owner := "rabilrbl"
owner := "JioTV-Go"
repo := "jiotv_go"

var url string
Expand Down
3 changes: 2 additions & 1 deletion dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM golang:1.23-alpine

ENV GO111MODULE=on \
JIOTV_DEBUG=true
JIOTV_DEBUG=true \
JIOTV_PATH_PREFIX="/app/.jiotv_go"

WORKDIR /app

Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
version: '3'

services:
app:
build:
context: .
dockerfile: ./dev.Dockerfile
environment:
- JIOTV_DEBUG=true
- JIOTV_PATH_PREFIX=/app/.jiotv_go
ports:
- 5001:5001
volumes:
- ./:/app
env_file:
- ./.env
- ./.env
39 changes: 34 additions & 5 deletions docs/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Automatic Installation (Recommended)

We have video tutorials for [Windows](https://youtu.be/BnNTYTSvVBc), and [Android](https://youtu.be/ejiuml11g8o) users. Please watch them if you are unsure about the installation process.
We have video tutorials for [Windows](https://youtu.be/BnNTYTSvVBc), and [Android](https://youtu.be/ejiuml11g8o) users. Please watch them if you are unsure about the installation process.

#### Linux/Android/macOS

Expand Down Expand Up @@ -43,7 +43,7 @@ iwr -useb https://jiotv_go.rabil.me/install.ps1 | iex
### Pre-Built Binaries
You can also download the pre-built binaries for your platform from the [releases](https://github.com/rabilrbl/jiotv-go/releases) page or click on `Binary Name` links in the table below.
You can also download the pre-built binaries for your platform from the [releases](https://github.com/JioTV-Go/jiotv-go/releases) page or click on `Binary Name` links in the table below.
#### The following table lists the binaries available for download:
Expand Down Expand Up @@ -102,22 +102,51 @@ Make sure you have [Docker](https://docs.docker.com/get-docker/) installed on yo
### Run JioTV Go with Docker
Run the command:
For single command setup, run:
```sh
docker run -p 5001:5001 -v ./.jiotv_go/secrets:/app/secrets ghcr.io/jiotv-go/jiotv_go
docker run -p 5001:5001 -e TZ=Asia/Kolkata -e JIOTV_DRM=true -e JIOTV_PATH_PREFIX=/app/.jiotv_go -v jiotv_go:/app/.jiotv_go ghcr.io/jiotv-go/jiotv_go
```
If you prefer docker-compose, create a `docker-compose.yml` file with the following content:
```yml
services:
jiotv_go:
image: ghcr.io/jiotv-go/jiotv_go
ports:
- "5001:5001"
volumes:
- jiotv_go:/app/.jiotv_go
environment:
- JIOTV_PATH_PREFIX=/app/.jiotv_go
- TZ=Asia/Kolkata
# below is optional, but we strongly recommend setting it to true. Read https://t.me/jiotv_go/128 for more information.
- JIOTV_DRM=true
# Read https://jiotv_go.rabil.me/config.html to know all configuration options.
volumes:
jiotv_go:
```
Then, run:
```sh
docker-compose up -d
```
Open your web browser and visit [http://localhost:5001/](http://localhost:5001/).
If you're impatient for new features, to get unstable build, use the `ghcr.io/jiotv-go/jiotv_go:develop` image.
### Using CLI Options with Docker
By default, JioTV Go Docker image runs with `serve --public` command. You can override this by passing the command as an argument to the `docker run` command.
For example, to run JioTV Go with `serve --public --port 8080` command, run:
```sh
docker run -p 8080:8080 -v ./.jiotv_go:/app/.jiotv_go ghcr.io/jiotv-go/jiotv_go serve --public --port 8080
docker run -p 8080:8080 -v jiotv_go:/app/secrets ghcr.io/jiotv-go/jiotv_go serve --public --port 8080
```
### Keep JioTV Go Updated
Expand Down
23 changes: 18 additions & 5 deletions docs/usage/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jiotv_go command [command options]

You can always use the `help` command or `-h` / `--help` flag to get help about a command.


## 1. Login Command

The `login` command helps you to login to JioTV Go. Alternatively, you can also login using the web interface at `http://localhost:5001/`.
Expand Down Expand Up @@ -70,7 +69,6 @@ jiotv_go login reset

The `reset` command helps you to reset your credentials. This will delete the existing credentials. You have to login again to use JioTV Go.


## 2. Serve Command

The `serve` command starts the JioTV Go server.
Expand All @@ -86,7 +84,9 @@ jiotv_go serve [command options] [arguments...]
- `--host value, -H value`: Host to listen on (default: "localhost").
- `--port value, -p value`: Port to listen on (default: "5001").
- `--public, -P`: Open the server to the public. This will expose your server outside your local network. Equivalent to passing `--host 0.0.0.0` (default: false).
- `--prefork`: Enable prefork. This will enable preforking the server to multiple processes. This is useful for production deployment (default: false).
- `--tls`: Enable TLS. This will enable HTTPS. You need to provide the certificate and key file (default: false).
- `--tls-cert value, --cert value`: Path to the TLS certificate file. Generate a self-signed certificate using `openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout key.pem -out cert.pem`. cert.pem is the TLS certificate file and key.pem is the TLS key file.
- `--tls-key value, --cert-key value`: Path to the TLS key file.
- `--skip-update-check`: Skip checking for updates on startup (default: false).
- `--help, -h`: Show help for the `serve` command.

Expand All @@ -102,6 +102,16 @@ jiotv_go serve --port 8080 --public
Use of the <code>--public</code> flag is not recommended. It exposes your server outside your local network. Use it only if it is necessary for you in some cases where you want to access JioTV Go server in your phone to TV or other devices.
</div>

TLS on port 5002 with a self-signed certificate with `--public` flag for public access.

```shell
jiotv_go serve --public --port 5002 --tls --tls-cert cert.pem --tls-key key.pem
```

If you run the server with TLS using above command, you can access the server at `https://localhost:5002/`.

You can also choose standard https port 443 for TLS. Then you can access the server at `https://localhost/`.

## 3. Update Command

The `update` command updates JioTV Go to the latest version.
Expand Down Expand Up @@ -160,7 +170,6 @@ jiotv_go epg Delete [command options] [arguments...]

The `delete` command deletes the existing EPG file if it exists. This will disable EPG on the server.


## 5. Help Command

The `help` command shows a list of commands or help for a specific command.
Expand Down Expand Up @@ -222,19 +231,23 @@ The `background` command allows you to run the JioTV Go server in the background
#### COMMANDS

- `start (run, r)`: Run JioTV Go server in the background

```shell
jiotv_go background start [command options] [arguments...]
```

- `--args value, -a value`: String value arguments passed to the `serve/run` command while running in the background as mentioned in the [Serve Command](#2-serve-command) section.
- `--config value, -c value`: Path to the configuration file. Reads the custom `path_prefix` to store the background process PID file at the specified location. Also passes the same configuration file to the `serve/run` command unless explicitly specified in `--args`.
<br>By default, JioTV Go will look for a file named `jiotv_go.(toml|yaml|json)` or `config.(toml|yaml|json)` in the same directory as the binary or `$HOME/.jiotv_go/` directory.

Description: The `start` command starts the JioTV Go server in the background. It runs the `JioTVServer` function in a separate process.

- `stop (k, kill)`: Stop JioTV Go server running in the background

```shell
jiotv_go background stop
```

- `--config value, -c value`: Path to the configuration file. Reads the custom `path_prefix` to access the background process PID file at the location.
<br>By default, JioTV Go will look for a file named `jiotv_go.(toml|yaml|json)` or `config.(toml|yaml|json)` in the same directory as the binary or `$HOME/.jiotv_go/` directory.

Expand All @@ -246,7 +259,7 @@ The `background` command allows you to run the JioTV Go server in the background
jiotv_go background start
```

Example with arguments *(make sure to enclose the arguments in quotes)*:
Example with arguments _(make sure to enclose the arguments in quotes)_:

```shell
jiotv_go background start --config config.toml --args "--port 8080"
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ go 1.23
require (
github.com/BurntSushi/toml v1.4.0
github.com/ilyakaznacheev/cleanenv v1.5.0
github.com/urfave/cli/v2 v2.27.4
golang.org/x/term v0.24.0
github.com/urfave/cli/v2 v2.27.5
golang.org/x/term v0.27.0
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/gofiber/template v1.8.3 // indirect
github.com/gofiber/utils v1.1.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/text v0.20.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
)

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/gofiber/fiber/v2 v2.52.5
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/gofiber/fiber/v2 v2.52.6
github.com/gofiber/template/html/v2 v2.1.2
github.com/google/uuid v1.5.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/madflojo/tasks v1.2.1
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/schollz/progressbar/v3 v3.16.0
github.com/schollz/progressbar/v3 v3.17.1
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.55.0
github.com/valyala/fasthttp v1.58.0
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/sys v0.28.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)
Loading

0 comments on commit 581d2d2

Please sign in to comment.