From 809f9fe6a7a26a99a69209198aad169740487770 Mon Sep 17 00:00:00 2001 From: GitHub Action <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:13:35 +0000 Subject: [PATCH 01/15] Bump version to v3.8.0 --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 90a2b28..28c0f98 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ func main() { Name: "JioTV Go", Usage: "Stream JioTV on any device", HelpName: "jiotv_go", - Version: "v3.7.0", + Version: "v3.8.0", Copyright: "© JioTV Go by Mohammed Rabil (https://github.com/rabilrbl/jiotv_go)", Compiled: time.Now(), Suggest: true, From 6df6b2d2d9d64697a97b46a35b840d41fb44b192 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Fri, 23 Aug 2024 20:10:45 +0530 Subject: [PATCH 02/15] Update test_build.yml: Remove PR Comments --- .github/workflows/test_build.yml | 43 -------------------------------- 1 file changed, 43 deletions(-) diff --git a/.github/workflows/test_build.yml b/.github/workflows/test_build.yml index bb1da6a..daa6c8c 100644 --- a/.github/workflows/test_build.yml +++ b/.github/workflows/test_build.yml @@ -21,27 +21,8 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -permissions: - contents: read - pull-requests: write - repository-projects: write - jobs: - init: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - name: Comment Build started - run: | - gh pr comment "$PR_URL" -b "Build started for this PR. [Check logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build: - needs: init runs-on: ubuntu-latest strategy: matrix: @@ -63,27 +44,3 @@ jobs: with: name: jiotv_go-${{ matrix.goos }}-${{ matrix.goarch }} path: ./bin/ - - post_success: - runs-on: ubuntu-latest - needs: build - if: success() - steps: - - name: Comment Build success - run: | - gh pr comment "$PR_URL" --edit-last -b "Build success for this PR ✅. [Download artifacts](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post_failure: - runs-on: ubuntu-latest - needs: build - if: failure() - steps: - - name: Comment Build failed - run: | - gh pr comment "$PR_URL" --edit-last -b "Build failed for this PR ❌. [Check logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a6e11b2717afc7547c6da0a1bff8f23616926d84 Mon Sep 17 00:00:00 2001 From: dheerajv4855 <48526859+dheerajv4855@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:26:21 +0530 Subject: [PATCH 03/15] fix for lg webos tv (#371) Co-authored-by: Mohammed Rabil Co-authored-by: Mohammed Rabil Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Action <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: dj --- cmd/jiotv_go.go | 11 +---------- internal/handlers/handlers.go | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/jiotv_go.go b/cmd/jiotv_go.go index e4ce306..6d5cd22 100644 --- a/cmd/jiotv_go.go +++ b/cmd/jiotv_go.go @@ -14,9 +14,7 @@ import ( "github.com/rabilrbl/jiotv_go/v3/web" "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/etag" "github.com/gofiber/fiber/v2/middleware/filesystem" - "github.com/gofiber/fiber/v2/middleware/helmet" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/fiber/v2/middleware/recover" "github.com/gofiber/template/html/v2" @@ -32,11 +30,10 @@ func JioTVServer(host, port, configPath string, prefork bool) error { if err := config.Cfg.Load(configPath); err != nil { return err } - + // Initialize the logger object utils.Log = utils.GetLogger() - // Initialize the store object if err := store.Init(); err != nil { return err @@ -88,12 +85,6 @@ func JioTVServer(host, port, configPath string, prefork bool) error { Browse: false, })) - // Helmet middleware to set security headers - app.Use(helmet.New()) - - // ETag middleware to set ETag header for caching - app.Use(etag.New()) - // Handle all /bpk-tv/* routes app.Use("/bpk-tv/", handlers.BpkProxyHandler) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index adb1684..8739b9c 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -357,6 +357,7 @@ func RenderTSHandler(c *fiber.Ctx) error { // ChannelsHandler fetch all channels from JioTV API // Also to generate M3U playlist func ChannelsHandler(c *fiber.Ctx) error { + quality := strings.TrimSpace(c.Query("q")) splitCategory := strings.TrimSpace(c.Query("c")) languages := strings.TrimSpace(c.Query("l")) @@ -397,8 +398,7 @@ func ChannelsHandler(c *fiber.Ctx) error { // Set the Content-Disposition header for file download c.Set("Content-Disposition", "attachment; filename=jiotv_playlist.m3u") c.Set("Content-Type", "application/vnd.apple.mpegurl") // Set the video M3U MIME type - c.Response().Header.Set("Cache-Control", "public, max-age=3600") - return c.SendString(m3uContent) + return c.SendStream(strings.NewReader(m3uContent)) } for i, channel := range apiResponse.Result { From 2f469792f332f26cf544d17ae49fcb657d140b1d Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 24 Aug 2024 22:11:00 +0530 Subject: [PATCH 04/15] Bump go version to v1.23 --- Dockerfile | 2 +- dev.Dockerfile | 2 +- go.mod | 2 +- main.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee0f3d4..0bcacbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-alpine AS builder +FROM golang:1.23-alpine AS builder # Set the working directory inside the container WORKDIR /app diff --git a/dev.Dockerfile b/dev.Dockerfile index cd7e0fb..8aa4e4e 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-alpine +FROM golang:1.23-alpine ENV GO111MODULE=on \ JIOTV_DEBUG=true diff --git a/go.mod b/go.mod index d765974..160f1fc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/rabilrbl/jiotv_go/v3 -go 1.22 +go 1.23 require ( github.com/BurntSushi/toml v1.4.0 diff --git a/main.go b/main.go index 90a2b28..67793fa 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ func main() { Name: "JioTV Go", Usage: "Stream JioTV on any device", HelpName: "jiotv_go", - Version: "v3.7.0", + Version: "v3.7.0", Copyright: "© JioTV Go by Mohammed Rabil (https://github.com/rabilrbl/jiotv_go)", Compiled: time.Now(), Suggest: true, From 1e50894781e012b9ddec6acc27f256c9a90ce10c Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 24 Aug 2024 22:14:17 +0530 Subject: [PATCH 05/15] Skip update check in docker --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0bcacbb..cf6e3d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,4 +39,4 @@ EXPOSE 5001 ENTRYPOINT ["./jiotv_go"] # Default arguments -CMD ["serve", "--public"] +CMD ["serve", "--public", "--skip-update-check"] From 758ba3a554dddbc8d4b2040c4f6bd3dcf66aa62b Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 24 Aug 2024 22:27:22 +0530 Subject: [PATCH 06/15] Fix boolean configs --- internal/handlers/auth.go | 2 +- internal/handlers/handlers.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index fe06cd5..1885fed 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -14,7 +14,7 @@ import ( ) const ( - REFRESH_TOKEN_TASK_ID = "jiotv_refresh_token" + REFRESH_TOKEN_TASK_ID = "jiotv_refresh_token" REFRESH_SSOTOKEN_TASK_ID = "jiotv_refresh_sso_token" ) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 8739b9c..0b210b2 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -21,10 +21,10 @@ import ( var ( TV *television.Television - DisableTSHandler = config.Cfg.DisableTSHandler - isLogoutDisabled = config.Cfg.DisableLogout + DisableTSHandler bool + isLogoutDisabled bool Title string - EnableDRM = config.Cfg.DRM + EnableDRM bool SONY_LIST = []string{"154", "155", "162", "289", "291", "471", "474", "476", "483", "514", "524", "525", "697", "872", "873", "874", "891", "892", "1146", "1393", "1772", "1773", "1774", "1775"} ) @@ -40,6 +40,9 @@ func Init() { } else { Title = "JioTV Go" } + DisableTSHandler = config.Cfg.DisableTSHandler + isLogoutDisabled = config.Cfg.DisableLogout + EnableDRM = config.Cfg.DRM if DisableTSHandler { utils.Log.Println("TS Handler disabled!. All TS video requests will be served directly from JioTV servers.") } From 8b22ab7df146e303fec79e306ff6438f8364c27f Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 24 Aug 2024 22:34:05 +0530 Subject: [PATCH 07/15] Refactor DisableTSHandler config check --- pkg/television/television.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/television/television.go b/pkg/television/television.go index fa926c9..ede5eed 100644 --- a/pkg/television/television.go +++ b/pkg/television/television.go @@ -17,11 +17,6 @@ const ( CHANNELS_API_URL = "https://jiotvapi.cdn.jio.com/apis/v3.0/getMobileChannelList/get/?langId=6&os=android&devicetype=phone&usertype=JIO&version=315&langId=6" ) -var ( - // DisableTSHandler is used to serve .ts files directly from JioTV Servers - DisableTSHandler = config.Cfg.DisableTSHandler -) - // New function creates a new Television instance with the provided credentials func New(credentials *utils.JIOTV_CREDENTIALS) *Television { // Check if credentials are provided @@ -252,7 +247,7 @@ func ReplaceM3U8(baseUrl, match []byte, params, channel_id string) []byte { } func ReplaceTS(baseUrl, match []byte, params string) []byte { - if DisableTSHandler { + if config.Cfg.DisableTSHandler { return []byte(string(baseUrl) + string(match) + "?" + params) } coded_url, err := secureurl.EncryptURL(string(baseUrl) + string(match) + "?" + params) @@ -264,7 +259,7 @@ func ReplaceTS(baseUrl, match []byte, params string) []byte { } func ReplaceAAC(baseUrl, match []byte, params string) []byte { - if DisableTSHandler { + if config.Cfg.DisableTSHandler { return []byte(string(baseUrl) + string(match) + "?" + params) } coded_url, err := secureurl.EncryptURL(string(baseUrl) + string(match) + "?" + params) From 23d8c317a7fb0c5d600c56e741369d48154881c9 Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 24 Aug 2024 22:56:11 +0530 Subject: [PATCH 08/15] Add error for empty channel url returned from JioTV API --- internal/handlers/handlers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 0b210b2..3f111f4 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -148,6 +148,14 @@ func LiveHandler(c *fiber.Ctx) error { if id[:2] == "sl" { return sonyLivRedirect(c, liveResult) } + // Check if liveResult.Bitrates.Auto is empty + if liveResult.Bitrates.Auto == "" { + error_message := "No stream found for channel id: " + id + "Status: " + liveResult.Message + utils.Log.Println(error_message) + return c.Status(fiber.StatusNotFound).JSON(fiber.Map{ + "message": error_message, + }) + } // quote url as it will be passed as a query parameter // It is required to quote the url as it may contain special characters like ? and & coded_url, err := secureurl.EncryptURL(liveResult.Bitrates.Auto) From 7a02c5581151bffbd3b8fd4ea49e6a96f8b80304 Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 24 Aug 2024 22:58:33 +0530 Subject: [PATCH 09/15] Add error for empty channel url returned from JioTV API --- internal/handlers/handlers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 3f111f4..d0898a4 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -152,6 +152,7 @@ func LiveHandler(c *fiber.Ctx) error { if liveResult.Bitrates.Auto == "" { error_message := "No stream found for channel id: " + id + "Status: " + liveResult.Message utils.Log.Println(error_message) + utils.Log.Println(liveResult) return c.Status(fiber.StatusNotFound).JSON(fiber.Map{ "message": error_message, }) From dd1bf84c802a2bbcb951358bd13cfcb588424edb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 24 Aug 2024 23:06:31 +0530 Subject: [PATCH 10/15] chore(deps-dev): Bump micromatch from 4.0.5 to 4.0.8 in /web (#388) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- web/package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index 85111f5..c779833 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -520,12 +520,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { From 494f37902e237db4ee114bf0dedc8f31661d38ec Mon Sep 17 00:00:00 2001 From: Anbuselvan Palaniyandi Date: Sun, 25 Aug 2024 19:23:54 +0530 Subject: [PATCH 11/15] fix epg for Kodi player (#391) --- pkg/epg/epg.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/epg/epg.go b/pkg/epg/epg.go index 2152fdd..538d6b5 100644 --- a/pkg/epg/epg.go +++ b/pkg/epg/epg.go @@ -228,6 +228,10 @@ func GenXMLGz(filename string) error { if err != nil { return err } + // Add XML header + xmlHeader := ` + ` + xml = append([]byte(xmlHeader), xml...) // write to file f, err := os.Create(filename) if err != nil { From a61f4f6ade74478be98da79f85f321a788e080cb Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 31 Aug 2024 14:12:04 +0530 Subject: [PATCH 12/15] Add user agents for proxy request --- internal/handlers/handlers.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index d0898a4..3956dda 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -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. @@ -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 } @@ -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 } @@ -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 } @@ -488,6 +491,7 @@ func PlaylistHandler(c *fiber.Ctx) error { // 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 } From 9428940ec23358fd6792fbc091a5af7f1191475b Mon Sep 17 00:00:00 2001 From: rabilrbl Date: Sat, 31 Aug 2024 16:56:14 +0530 Subject: [PATCH 13/15] Add docker builds for develop branch --- .github/workflows/docker.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 70f88a9..fd0a3cb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,7 @@ on: push: branches: - "main" + - "develop" tags: - "v*.*" paths-ignore: @@ -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: @@ -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: . @@ -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 \ No newline at end of file + cache-to: type=gha,mode=max From a7c5f7052e495c3249550f7526b70f30bc24fcfb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 03:31:14 +0000 Subject: [PATCH 14/15] chore(deps): Bump github.com/madflojo/tasks from 1.2.0 to 1.2.1 (#395) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 160f1fc..183da0c 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 435fb82..a8dd727 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= From 280208afaf15701f7709445fe64874cec88c4070 Mon Sep 17 00:00:00 2001 From: Mohit Kothari Date: Tue, 3 Sep 2024 09:48:16 +0530 Subject: [PATCH 15/15] feat: Add query parameter to skip specific genres from m3u playlist (#396) Co-authored-by: Mohammed Rabil --- docs/usage/iptv.md | 7 +++++++ docs/usage/paths.md | 3 +++ internal/handlers/handlers.go | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/usage/iptv.md b/docs/usage/iptv.md index 3e29d2f..a9107c8 100644 --- a/docs/usage/iptv.md +++ b/docs/usage/iptv.md @@ -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: ``` diff --git a/docs/usage/paths.md b/docs/usage/paths.md index 7c4f1ab..2ef33e6 100644 --- a/docs/usage/paths.md +++ b/docs/usage/paths.md @@ -69,6 +69,9 @@ You can append `?q=` to the path where `` 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=` to the path in order to skip specific genres. Here replace `` 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` diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 3956dda..8793214 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -376,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() @@ -391,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) @@ -485,7 +490,8 @@ 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