Skip to content

Commit

Permalink
Merge pull request #398 from rabilrbl/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rabilrbl authored Sep 3, 2024
2 parents 776a277 + 280208a commit 5bbf780
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
- "develop"
tags:
- "v*.*"
paths-ignore:
Expand Down Expand Up @@ -35,11 +36,9 @@ jobs:
packages: write
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
Expand All @@ -55,22 +54,18 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GHCR
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
Expand All @@ -79,4 +74,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
7 changes: 7 additions & 0 deletions docs/usage/iptv.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ JioTV Go offers a convenient M3U playlist endpoint to enhance your IPTV experien
Please note that either `c=split` or `c=language` can be used at a time.
6. If you would like to skip one or more genre from playlist, you can use `sg=Educational,Lifestyle`
```
http://localhost:5001/playlist.m3u?sg=Educational,Lifestyle
```
This will skip all channels from provided list of genres.
For both specific quality and split category, append the `q=` and `c=` query parameters:
```
Expand Down
3 changes: 3 additions & 0 deletions docs/usage/paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ You can append `?q=<level>` to the path where `<level>` should be replaced with

You can also append `&c=split` to the path to have categories based on both language and genre. Example categories: `Hindi - Entertainment`, `English - News`, `Tamil - Sports`, etc.

You can also append `&sg=<genre_list>` to the path in order to skip specific genres. Here replace `<genre_list>` with comma(,) seperated list of genres.
Valid genres: `Entertainment`, `Movies`, `Kids`, `Sports`, `Lifestyle`, `Infotainment`, `News`, `Music`, `Devotional`, `Business`, `Educational`, `Shopping`, `JioDarshan`

### M3U Playlist

- **Path**: `/channels?type=m3u`
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
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.5.0 // 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
Expand All @@ -30,7 +30,7 @@ require (
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/madflojo/tasks v1.2.0
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.15 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/madflojo/tasks v1.2.0 h1:wYVgHx293eFFN2xtfsgNQ8T4LUPZEdnGH5jvLn3B7kg=
github.com/madflojo/tasks v1.2.0/go.mod h1:BKSfcHnUSlQMA5wXdaxgthhKc75GfVIivEywn2YWqt0=
github.com/madflojo/tasks v1.2.1 h1:0HMN1RCVf6yDjrlIbthkET1KCB+gxknQG3/SLO+HHj4=
github.com/madflojo/tasks v1.2.1/go.mod h1:/WMv6u3Xb5eyy+aIM76ildaIT166GOxN/jya9oI7dyo=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand All @@ -41,8 +41,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.14.6 h1:GyjwcWBAf+GFDMLziwerKvpuS7ZF+mNTAXIB2aspiZs=
Expand Down
16 changes: 13 additions & 3 deletions internal/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var (
const (
REFRESH_TOKEN_URL = "https://auth.media.jio.com/tokenservice/apis/v1/refreshtoken?langId=6"
REFRESH_SSO_TOKEN_URL = "https://tv.media.jio.com/apis/v2.0/loginotp/refresh?langId=6"
PLAYER_USER_AGENT = "plaYtv/7.0.5 (Linux;Android 8.1.0) ExoPlayerLib/2.11.7"
REQUEST_USER_AGENT = "okhttp/4.2.2"
)

// Init initializes the necessary operations required for the handlers to work.
Expand Down Expand Up @@ -304,6 +306,7 @@ func SLHandler(c *fiber.Ctx) error {
c.Request().Header.Del("Accept-Language")
c.Request().Header.Del("Origin")
c.Request().Header.Del("Referer")
c.Request().Header.Set("User-Agent", PLAYER_USER_AGENT)
if err := proxy.Do(c, url, TV.Client); err != nil {
return err
}
Expand Down Expand Up @@ -341,7 +344,7 @@ func RenderKeyHandler(c *fiber.Ctx) error {
c.Request().Header.Set("srno", "230203144000")
c.Request().Header.Set("ssotoken", TV.SsoToken)
c.Request().Header.Set("channelId", channel_id)

c.Request().Header.Set("User-Agent", PLAYER_USER_AGENT)
if err := proxy.Do(c, decoded_url, TV.Client); err != nil {
return err
}
Expand All @@ -358,7 +361,7 @@ func RenderTSHandler(c *fiber.Ctx) error {
utils.Log.Panicln(err)
return err
}

c.Request().Header.Set("User-Agent", PLAYER_USER_AGENT)
if err := proxy.Do(c, decoded_url, TV.Client); err != nil {
return err
}
Expand All @@ -373,6 +376,7 @@ func ChannelsHandler(c *fiber.Ctx) error {
quality := strings.TrimSpace(c.Query("q"))
splitCategory := strings.TrimSpace(c.Query("c"))
languages := strings.TrimSpace(c.Query("l"))
skipGenres := strings.TrimSpace(c.Query("sg"))
apiResponse := television.Channels()
// hostUrl should be request URL like http://localhost:5001
hostURL := strings.ToLower(c.Protocol()) + "://" + c.Hostname()
Expand All @@ -388,6 +392,10 @@ func ChannelsHandler(c *fiber.Ctx) error {
continue
}

if skipGenres != "" && utils.ContainsString(television.CategoryMap[channel.Category], strings.Split(skipGenres, ",")) {
continue
}

var channelURL string
if quality != "" {
channelURL = fmt.Sprintf("%s/live/%s/%s.m3u8", hostURL, quality, channel.ID)
Expand Down Expand Up @@ -482,12 +490,14 @@ func PlaylistHandler(c *fiber.Ctx) error {
quality := c.Query("q")
splitCategory := c.Query("c")
languages := c.Query("l")
return c.Redirect("/channels?type=m3u&q="+quality+"&c="+splitCategory+"&l="+languages, fiber.StatusMovedPermanently)
skipGenres := c.Query("sg")
return c.Redirect("/channels?type=m3u&q="+quality+"&c="+splitCategory+"&l="+languages+"&sg="+skipGenres, fiber.StatusMovedPermanently)
}

// ImageHandler loads image from JioTV server
func ImageHandler(c *fiber.Ctx) error {
url := "https://jiotv.catchup.cdn.jio.com/dare_images/images/" + c.Params("file")
c.Request().Header.Set("User-Agent", REQUEST_USER_AGENT)
if err := proxy.Do(c, url, TV.Client); err != nil {
return err
}
Expand Down

0 comments on commit 5bbf780

Please sign in to comment.