From cc44c970d66064d1ab6a25d73badc8a2a926cb01 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Thu, 5 Sep 2024 11:43:26 +0530 Subject: [PATCH 01/12] fix: EPG posters in jellyfin (#402) --- .devcontainer/devcontainer.json | 2 +- pkg/epg/epg.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 32922a53..3b0fb3cb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ { "name": "Go", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bullseye", + "image": "mcr.microsoft.com/devcontainers/go:1-1.23-bullseye", "features": { "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": true, diff --git a/pkg/epg/epg.go b/pkg/epg/epg.go index 538d6b57..b982aafd 100644 --- a/pkg/epg/epg.go +++ b/pkg/epg/epg.go @@ -23,6 +23,8 @@ const ( CHANNEL_URL = "https://jiotv.data.cdn.jio.com/apis/v3.0/getMobileChannelList/get/?os=android&devicetype=phone&usertype=tvYR7NSNn7rymo3F" // URL for fetching EPG data for individual channels from JioTV API EPG_URL = "https://jiotv.data.cdn.jio.com/apis/v1.3/getepg/get/?offset=%d&channel_id=%d" + // EPG_POSTER_URL + EPG_POSTER_URL = "https://jiotv.catchup.cdn.jio.com/dare_images/shows" // EPG_TASK_ID is the ID of the EPG generation task EPG_TASK_ID = "jiotv_epg" ) @@ -81,7 +83,7 @@ func Init() { // NewProgramme creates a new Programme with the given parameters. func NewProgramme(channelID int, start, stop, title, desc, category, iconSrc string) Programme { - iconURL := fmt.Sprintf("/jtvposter/%s", iconSrc) + iconURL := fmt.Sprintf("%s/%s", EPG_POSTER_URL, iconSrc) return Programme{ Channel: fmt.Sprint(channelID), Start: start, @@ -121,7 +123,7 @@ func genXML() ([]byte, error) { resp := fasthttp.AcquireResponse() - for offset := -1; offset < 2; offset++ { + for offset := 0; offset < 2; offset++ { reqUrl := fmt.Sprintf(EPG_URL, offset, channel.ID) req.SetRequestURI(reqUrl) From 3969302368d5d40102afa881cadbb6c82973aa18 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Thu, 5 Sep 2024 11:56:32 +0530 Subject: [PATCH 02/12] Build for android5 armv7 legacy (#403) --- .github/workflows/pre-release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index be3845ed..cef0c6a2 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -96,6 +96,10 @@ jobs: # Wait for all background jobs to finish wait + # Build for android5 arm with CC=armv7a-linux-androideabi21-clang + echo "Building android5 arm" + CGO_ENABLED=1 GOOS=android GOARCH=arm CC="armv7a-linux-androideabi21-clang" CXX="armv7a-linux-androideabi21-clang++" go build -o bin/jiotv_go-android5-armv7 -trimpath -ldflags="-s -w" . + - name: Delete previous release 🗑️ run: | tag=$(git describe --tags --match "${{ github.ref_name }}.[0-9]*.[0-9]*.[0-9]*" --abbrev=0) From 70de4df082d7a735534ef3e3d03d24e9e1d2d11d Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Thu, 5 Sep 2024 06:32:28 +0000 Subject: [PATCH 03/12] chore: Update build command for android5 arm to include GOARM=7 --- .github/workflows/pre-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index cef0c6a2..fe505cb1 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -98,7 +98,7 @@ jobs: # Build for android5 arm with CC=armv7a-linux-androideabi21-clang echo "Building android5 arm" - CGO_ENABLED=1 GOOS=android GOARCH=arm CC="armv7a-linux-androideabi21-clang" CXX="armv7a-linux-androideabi21-clang++" go build -o bin/jiotv_go-android5-armv7 -trimpath -ldflags="-s -w" . + CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 CC="armv7a-linux-androideabi21-clang" CXX="armv7a-linux-androideabi21-clang++" go build -o bin/jiotv_go-android5-armv7 -trimpath -ldflags="-s -w" . - name: Delete previous release 🗑️ run: | From 00c4d61cbb4cddc380b838bd4b901468cfe54df5 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Fri, 6 Sep 2024 08:46:31 +0530 Subject: [PATCH 04/12] Update release.yml to include android5 armv7 build --- .github/workflows/release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 390974f0..52bf0b07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -95,7 +95,7 @@ jobs: - name: Setup android NDK run: | - wget -q --show-progress https://dl.google.com/android/repository/android-ndk-r26b-linux.zip + wget -q https://dl.google.com/android/repository/android-ndk-r26b-linux.zip unzip -qq android-ndk-r26b-linux.zip echo "$PWD/android-ndk-r26b/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH @@ -151,6 +151,10 @@ jobs: # Wait for all background jobs to finish wait + # Build for android5 arm with CC=armv7a-linux-androideabi21-clang + echo "Building android5 arm" + CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 CC="armv7a-linux-androideabi21-clang" CXX="armv7a-linux-androideabi21-clang++" go build -o bin/jiotv_go-android5-armv7 -trimpath -ldflags="-s -w" . + - name: Release 📦 uses: softprops/action-gh-release@v1 with: From da8de0cbfd1749117693d6ec42615791b7b16e45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 03:21:27 +0000 Subject: [PATCH 05/12] chore(deps): Bump golang.org/x/term from 0.23.0 to 0.24.0 (#405) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 183da0cb..c7f4789c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.23.0 + golang.org/x/term v0.24.0 ) require ( @@ -39,6 +39,6 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.55.0 github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.23.0 // indirect + golang.org/x/sys v0.25.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) diff --git a/go.sum b/go.sum index a8dd727b..a8987b10 100644 --- a/go.sum +++ b/go.sum @@ -66,11 +66,11 @@ golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From ad1fc63324560f6c64fbcaca5f54fd6d01a37cb8 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Mon, 9 Sep 2024 11:04:14 +0000 Subject: [PATCH 06/12] Fix major issue --- internal/handlers/auth.go | 4 ++-- internal/handlers/drm.go | 2 +- internal/handlers/handlers.go | 3 +++ pkg/television/television.go | 2 +- pkg/utils/utils.go | 36 +++++++++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 1885fedd..0e62f896 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -131,7 +131,7 @@ func LoginRefreshAccessToken() error { // Prepare the request body requestBody := map[string]string{ "appName": "RJIL_JioTV", - "deviceId": "6fcadeb7b4b10d77", + "deviceId": utils.GetDeviceID(), "refreshToken": tokenData.RefreshToken, } @@ -218,7 +218,7 @@ func LoginRefreshSSOToken() error { req.Header.Set("User-Agent", "okhttp/4.2.2") req.Header.Set("ssoToken", tokenData.SSOToken) req.Header.Set("uniqueid", tokenData.UniqueID) - req.Header.Set("deviceid", "6fcadeb7b4b10d77") + req.Header.Set("deviceid",utils.GetDeviceID()) // Send the request resp := fasthttp.AcquireResponse() diff --git a/internal/handlers/drm.go b/internal/handlers/drm.go index efba9a01..64e447ef 100644 --- a/internal/handlers/drm.go +++ b/internal/handlers/drm.go @@ -132,7 +132,7 @@ func DRMKeyHandler(c *fiber.Ctx) error { c.Request().Header.Set("devicetype", "phone") c.Request().Header.Set("Accept-Encoding", "gzip, deflate") c.Request().Header.Set("osVersion", "13") - c.Request().Header.Set("deviceId", "b6985e8cf2401d35") + c.Request().Header.Set("deviceId", utils.GetDeviceID()) c.Request().Header.Set("Content-Type", "application/octet-stream") // Delete User-Agent header from the request diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 8793214c..7f5c2e88 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -48,6 +48,9 @@ func Init() { if DisableTSHandler { utils.Log.Println("TS Handler disabled!. All TS video requests will be served directly from JioTV servers.") } + err := utils.GenerateRandomString(); if err != nil { + utils.Log.Println("Error generating random string", err) + } // Get credentials from file credentials, err := utils.GetJIOTVCredentials() // Initialize TV object with nil credentials diff --git a/pkg/television/television.go b/pkg/television/television.go index ede5eed6..79e2b502 100644 --- a/pkg/television/television.go +++ b/pkg/television/television.go @@ -35,7 +35,7 @@ func New(credentials *utils.JIOTV_CREDENTIALS) *Television { "channel_id": "", "crmid": credentials.CRM, "userId": credentials.CRM, - "deviceId": "e4286d7b481d69b8", + "deviceId": utils.GetDeviceID(), "devicetype": "phone", "isott": "false", "languageId": "6", diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7ef2e688..437cd53d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -1,7 +1,9 @@ package utils import ( + "crypto/rand" "encoding/base64" + "encoding/hex" "encoding/json" "fmt" "log" @@ -324,6 +326,28 @@ func GetPathPrefix() string { return store.GetPathPrefix() } +// GetDeviceID returns the device ID +func GetDeviceID() string { + deviceID, err := store.Get("deviceId") + if err != nil { + Log.Println(err) + err = GenerateRandomString() + if err != nil { + Log.Println(err) + return "" + } + deviceID, err = store.Get("deviceId") + if deviceID == "" { + Log.Println("Device ID is empty") + return "" + } else if err != nil { + Log.Println(err) + return "" + } + } + return deviceID +} + // GetJIOTVCredentials return credentials from environment variables or credentials file // Important note: If credentials are provided from environment variables, they will be used instead of credentials file func GetJIOTVCredentials() (*JIOTV_CREDENTIALS, error) { @@ -533,3 +557,15 @@ func ContainsString(item string, slice []string) bool { } return false } + +// GenerateRandomString generates a random 16-character hexadecimal string. +func GenerateRandomString() error { + bytes := make([]byte, 8) // 8 bytes will result in a 16-character hex string + if _, err := rand.Read(bytes); err != nil { + return err + } + if _, err := store.Get("deviceId"); err != nil { + store.Set("deviceId", hex.EncodeToString(bytes)) + } + return nil +} From 0d378a5361eba119daa42cb11a30b29d32fcd595 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Mon, 9 Sep 2024 11:19:09 +0000 Subject: [PATCH 07/12] Update store filename for new changes --- pkg/store/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/store/store.go b/pkg/store/store.go index 18fc71d7..db8f3c5c 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -29,7 +29,7 @@ var KVS *TomlStore // Init initializes the TOML file, creates if not exist, otherwise reads and decodes to struct. func Init() error { KVS = &TomlStore{} - filename := filepath.Join(GetPathPrefix(), "store_v2.toml") + filename := filepath.Join(GetPathPrefix(), "store_v3.toml") KVS.mu.Lock() defer KVS.mu.Unlock() From a494abd819a6b373ebcb2c86ca29c4f1c4f664ba Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Mon, 9 Sep 2024 11:20:26 +0000 Subject: [PATCH 08/12] Update comment --- pkg/store/store.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/store/store.go b/pkg/store/store.go index db8f3c5c..b0c814ae 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -29,6 +29,7 @@ var KVS *TomlStore // Init initializes the TOML file, creates if not exist, otherwise reads and decodes to struct. func Init() error { KVS = &TomlStore{} + // store_vX.toml, where X is changed whenever new version requires re-login filename := filepath.Join(GetPathPrefix(), "store_v3.toml") KVS.mu.Lock() From f8e3c096ac36f18da764a29b0db6f107536a5296 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Mon, 9 Sep 2024 12:23:49 +0000 Subject: [PATCH 09/12] Generate new device ID if not present --- internal/handlers/handlers.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 7f5c2e88..95dbee27 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -48,9 +48,8 @@ func Init() { if DisableTSHandler { utils.Log.Println("TS Handler disabled!. All TS video requests will be served directly from JioTV servers.") } - err := utils.GenerateRandomString(); if err != nil { - utils.Log.Println("Error generating random string", err) - } + // Generate a new device ID if not present + utils.GetDeviceID() // Get credentials from file credentials, err := utils.GetJIOTVCredentials() // Initialize TV object with nil credentials From 75a9fe9e3f93fd4c08d1d4dbe3d9770f8368e934 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Tue, 10 Sep 2024 02:15:10 +0000 Subject: [PATCH 10/12] Update device ID header in auth handlers --- internal/handlers/auth.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 0e62f896..6370edce 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -153,6 +153,7 @@ func LoginRefreshAccessToken() error { req.Header.Set("Accept-Encoding", "gzip") req.Header.Set("User-Agent", "okhttp/4.2.2") req.Header.Set("accessToken", tokenData.AccessToken) + req.Header.Set("deviceId", utils.GetDeviceID()) req.SetBody(requestBodyJSON) // Send the request @@ -218,7 +219,7 @@ func LoginRefreshSSOToken() error { req.Header.Set("User-Agent", "okhttp/4.2.2") req.Header.Set("ssoToken", tokenData.SSOToken) req.Header.Set("uniqueid", tokenData.UniqueID) - req.Header.Set("deviceid",utils.GetDeviceID()) + req.Header.Set("deviceid", utils.GetDeviceID()) // Send the request resp := fasthttp.AcquireResponse() From f2b75cb868e84fd1f73f19cc19089728a2b366b5 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Tue, 10 Sep 2024 02:59:01 +0000 Subject: [PATCH 11/12] Update device ID header in auth handlers --- internal/handlers/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 6370edce..7b7b111d 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -153,7 +153,7 @@ func LoginRefreshAccessToken() error { req.Header.Set("Accept-Encoding", "gzip") req.Header.Set("User-Agent", "okhttp/4.2.2") req.Header.Set("accessToken", tokenData.AccessToken) - req.Header.Set("deviceId", utils.GetDeviceID()) + req.Header.Set("deviceid", utils.GetDeviceID()) req.SetBody(requestBodyJSON) // Send the request From f34465e7fb35ed80c73306367ee1b7e20aa1dbb7 Mon Sep 17 00:00:00 2001 From: Mohammed Rabil Date: Tue, 10 Sep 2024 03:16:17 +0000 Subject: [PATCH 12/12] Update device ID header in auth handlers --- internal/handlers/auth.go | 1 - pkg/store/store.go | 2 +- pkg/utils/utils.go | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 7b7b111d..4ff5a6cd 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -153,7 +153,6 @@ func LoginRefreshAccessToken() error { req.Header.Set("Accept-Encoding", "gzip") req.Header.Set("User-Agent", "okhttp/4.2.2") req.Header.Set("accessToken", tokenData.AccessToken) - req.Header.Set("deviceid", utils.GetDeviceID()) req.SetBody(requestBodyJSON) // Send the request diff --git a/pkg/store/store.go b/pkg/store/store.go index b0c814ae..b870a07f 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -30,7 +30,7 @@ var KVS *TomlStore func Init() error { KVS = &TomlStore{} // store_vX.toml, where X is changed whenever new version requires re-login - filename := filepath.Join(GetPathPrefix(), "store_v3.toml") + filename := filepath.Join(GetPathPrefix(), "store_v4.toml") KVS.mu.Lock() defer KVS.mu.Unlock() diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 437cd53d..ca9df64c 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -125,7 +125,7 @@ func LoginVerifyOTP(number, otp string) (map[string]string, error) { Platform: LoginPayloadDeviceInfoInfoPlatform{ Name: "SM-G930F", }, - AndroidID: "6fcadeb7b4b10d77", + AndroidID: GetDeviceID(), }, }, } @@ -249,7 +249,7 @@ func Login(username, password string) (map[string]string, error) { Name: "vbox86p", Version: "8.0.0", }, - AndroidID: "6fcadeb7b4b10d77", + AndroidID: GetDeviceID(), }, }, }