From 61ba90812da7fea33a3e3d94a5dcfe5557e09bd3 Mon Sep 17 00:00:00 2001 From: okjack Date: Mon, 22 Jul 2024 20:40:46 +0800 Subject: [PATCH] Add timeZone param for live epg --- README.md | 1 + .../com/fongmi/android/tv/model/LiveViewModel.java | 14 ++++++++++++++ other/sample/live/online.json | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6369072ad..a3c1a60db 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ https://github.com/CatVodTVOfficial/CatVodTVJarLoader | ua | none | 用戶代理 | | | origin | none | 來源 | | | referer | none | 參照地址 | | +| epg | none | 節目地址 | &serverTimeZone | | epg | none | 節目地址 | | | logo | none | 台標地址 | | | pass | false | 是否免密碼 | | diff --git a/app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java b/app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java index 84b2efe6f..155101c95 100644 --- a/app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java +++ b/app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java @@ -1,5 +1,7 @@ package com.fongmi.android.tv.model; +import android.net.Uri; + import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; @@ -22,6 +24,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.Locale; +import java.util.TimeZone; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -59,6 +62,7 @@ public class LiveViewModel extends ViewModel { public void getLive(Live item) { execute(LIVE, () -> { VodConfig.get().setRecent(item.getJar()); + setTimeZone(item.getEpg()); LiveParser.start(item); verify(item); return item; @@ -94,6 +98,16 @@ public class LiveViewModel extends ViewModel { }); } + private void setTimeZone(String url) { + try { + if (!url.contains("serverTimeZone=")) return; + TimeZone timeZone = TimeZone.getTimeZone(Uri.parse(url).getQueryParameter("serverTimeZone")); + formatDate.setTimeZone(timeZone); + formatTime.setTimeZone(timeZone); + } catch (Exception ignored) { + } + } + private void verify(Live item) { Iterator iterator = item.getGroups().iterator(); while (iterator.hasNext()) if (iterator.next().isEmpty()) iterator.remove(); diff --git a/other/sample/live/online.json b/other/sample/live/online.json index 689f5bbc5..90433b9ea 100644 --- a/other/sample/live/online.json +++ b/other/sample/live/online.json @@ -38,7 +38,7 @@ "boot": false, "pass": true, "url": "https://github.com/live.txt", - "epg": "https://epg.112114.xyz/?ch={name}&date={date}", + "epg": "https://epg.112114.xyz/?ch={name}&date={date}&serverTimeZone=Asia/Shanghai", "logo": "https://epg.112114.xyz/logo/{name}.png", "header": { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",