From 8bb730112f7b442b83dcca30d6a6ade7098a4c9b Mon Sep 17 00:00:00 2001 From: krreet <34994993+krreet@users.noreply.github.com> Date: Sun, 5 Feb 2023 19:51:36 +0530 Subject: [PATCH 1/3] OS-001 fix featured catchup --- resources/lib/main.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/resources/lib/main.py b/resources/lib/main.py index aa8ade3..4a96d01 100644 --- a/resources/lib/main.py +++ b/resources/lib/main.py @@ -113,7 +113,11 @@ def show_featured(plugin, id=None): info_dict["params"] = { "channel_id": child.get("channel_id"), "showtime": child.get("showtime", "").replace(":", ""), - "srno": datetime.fromtimestamp(int(child.get("startEpoch", 0)*.001)).strftime('%Y%m%d') + "srno": datetime.fromtimestamp(int(child.get("startEpoch", 0)*.001)).strftime('%Y%m%d'), + "stream_type": "Catchup", + "programId": child.get("srno", ""), + "begin": datetime.utcfromtimestamp(int(child.get("startEpoch", 0)*.001)).strftime('%Y%m%dT%H%M%S'), + "end": datetime.utcfromtimestamp(int(child.get("endEpoch", 0)*.001)).strftime('%Y%m%dT%H%M%S') } yield Listitem.from_dict(**info_dict) else: @@ -219,7 +223,11 @@ def show_epg(plugin, day, channel_id): "params": { "channel_id": each.get("channel_id"), "showtime": None if islive else each.get("showtime", "").replace(":", ""), - "srno": None if islive else datetime.fromtimestamp(int(each.get("startEpoch", 0)*.001)).strftime('%Y%m%d') + "srno": None if islive else datetime.fromtimestamp(int(each.get("startEpoch", 0)*.001)).strftime('%Y%m%d'), + "stream_type": None if islive else "Catchup", + "programId": None if islive else each.get("srno", "").replace(":", ""), + "begin": None if islive else datetime.utcfromtimestamp(int(each.get("startEpoch", 0)*.001)).strftime('%Y%m%dT%H%M%S'), + "end": None if islive else datetime.utcfromtimestamp(int(each.get("endEpoch", 0)*.001)).strftime('%Y%m%dT%H%M%S') } }) if int(day) == 0: @@ -267,7 +275,7 @@ def play_ex(plugin, dt=None): # Also insures that user is logged in. @Resolver.register @isLoggedIn -def play(plugin, channel_id, showtime=None, srno=None): +def play(plugin, channel_id, showtime=None, srno=None , stream_type=None, programId=None, begin=None, end=None): is_helper = inputstreamhelper.Helper("mpd", drm="com.widevine.alpha") hasIs = is_helper.check_inputstream() if not hasIs: @@ -279,7 +287,10 @@ def play(plugin, channel_id, showtime=None, srno=None): if extra.get(str(channel_id)).get("ext"): return extra.get(str(channel_id)).get("ext") return PLAY_EX_URL + extra.get(str(channel_id)).get("data") - + # Script.notify("showtime", showtime) + # Script.notify("begin", begin) + # Script.notify("programid", programId) + # Script.notify("stream_type", stream_type) rjson = { "channel_id": int(channel_id), "stream_type": "Seek" @@ -288,24 +299,30 @@ def play(plugin, channel_id, showtime=None, srno=None): rjson["showtime"] = showtime rjson["srno"] = srno rjson["stream_type"] = "Catchup" + rjson["programId"] = programId + rjson["begin"] = begin + rjson["end"] = end + Script.log(str(rjson), lvl=Script.INFO) headers = getHeaders() headers['channelid'] = str(channel_id) headers['srno'] = str(uuid4()) res = urlquick.post(GET_CHANNEL_URL, json=rjson, headers=getChannelHeaders(), max_age=-1) # Script.notify("challelurl", res.status_code) + Script.log(str(getChannelHeaders()), lvl=Script.INFO) resp = res.json() + Script.log(str(res.json()), lvl=Script.INFO) art = {} onlyUrl = resp.get("result", "").split("?")[0].split('/')[-1] art["thumb"] = art["icon"] = IMG_CATCHUP + \ onlyUrl.replace(".m3u8", ".png") - cookie = resp.get("result", "").split("?")[-1] + cookie = "__hdnea__"+resp.get("result", "").split("__hdnea__")[-1] headers['cookie'] = cookie params = getTokenParams() uriToUse = resp.get("result","") m3u8Headers = {} m3u8Headers['user-agent'] = headers['user-agent'] m3u8Headers['cookie'] = cookie - m3u8Res = urlquick.get(resp.get("result",""), headers=m3u8Headers, max_age=-1 , raise_for_status=True , timeout=5) + m3u8Res = urlquick.get(uriToUse, headers=m3u8Headers, max_age=-1 , raise_for_status=True , timeout=5) # Script.notify("m3u8url", m3u8Res.status_code) m3u8String = m3u8Res.text variant_m3u8 = m3u8.loads(m3u8String) @@ -317,6 +334,8 @@ def play(plugin, channel_id, showtime=None, srno=None): # else: # quality = len(variant_m3u8.playlists) - 2 #quality = len(variant_m3u8.playlists) - 1 + if rjson["stream_type"] == 'Catchup'and "?" in variant_m3u8.playlists[quality].uri: + uriToUse=uriToUse.split("?")[0] + "&" + cookie uriToUse = uriToUse.replace(onlyUrl, variant_m3u8.playlists[quality].uri) return Listitem().from_dict(**{ "label": plugin._title, @@ -388,7 +407,9 @@ def m3ugen(plugin, notify="yes"): "channel_id={0}".format(channel.get("channel_id")) catchup = "" if channel.get("isCatchupAvailable"): - catchup = ' catchup="vod" catchup-source="{0}channel_id={1}&showtime={{H}}{{M}}{{S}}&srno={{Y}}{{m}}{{d}}" catchup-days="7"'.format( + # get the epg for this channel + + catchup = ' catchup="vod" catchup-source="{0}channel_id={1}&showtime={{H}}{{M}}{{S}}&srno={{Y}}{{m}}{{d}}&begin={{Y}}{{m}}{{d}}T{{H}}{{M}}{{S}}&end={{Y}}{{m}}{{d}}T{{H}}{{M}}{{S}}" catchup-days="7"'.format( PLAY_URL, channel.get("channel_id")) m3ustr += M3U_CHANNEL.format( tvg_id=channel.get("channel_id"), From b20ac01f7f0dbcf3f9626f77c62b7b6f4aaa4acb Mon Sep 17 00:00:00 2001 From: krreet <34994993+krreet@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:45:02 +0530 Subject: [PATCH 2/3] OS-001 fix catchup from context menu --- resources/lib/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/main.py b/resources/lib/main.py index 4a96d01..86191d4 100644 --- a/resources/lib/main.py +++ b/resources/lib/main.py @@ -225,7 +225,7 @@ def show_epg(plugin, day, channel_id): "showtime": None if islive else each.get("showtime", "").replace(":", ""), "srno": None if islive else datetime.fromtimestamp(int(each.get("startEpoch", 0)*.001)).strftime('%Y%m%d'), "stream_type": None if islive else "Catchup", - "programId": None if islive else each.get("srno", "").replace(":", ""), + "programId": None if islive else each.get("srno", ""), "begin": None if islive else datetime.utcfromtimestamp(int(each.get("startEpoch", 0)*.001)).strftime('%Y%m%dT%H%M%S'), "end": None if islive else datetime.utcfromtimestamp(int(each.get("endEpoch", 0)*.001)).strftime('%Y%m%dT%H%M%S') } From 2e517f1ccc2d3142f5e499090d42d4bfd5304a90 Mon Sep 17 00:00:00 2001 From: krreet <34994993+krreet@users.noreply.github.com> Date: Wed, 8 Feb 2023 20:42:28 +0530 Subject: [PATCH 3/3] OS-000 fix key 18 error --- resources/lib/constants.py | 4 ++-- resources/lib/main.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/resources/lib/constants.py b/resources/lib/constants.py index 3cc923d..df06108 100644 --- a/resources/lib/constants.py +++ b/resources/lib/constants.py @@ -14,7 +14,7 @@ FEATURED_SRC = "https://tv.media.jio.com/apis/v1.6/getdata/featurednew?start=0&limit=30&langId=6" EXTRA_CHANNELS = os.path.join(translatePath( ADDON.getAddonInfo("path")), "resources", "extra", "channels.json") -CHANNELS_SRC = "http://jiotv.data.cdn.jio.com/apis/v1.3/getMobileChannelList/get/?os=android&devicetype=phone&version=7.0.8" +CHANNELS_SRC = "http://jiotv.data.cdn.jio.com/apis/v1.3/getMobileChannelList/get/?os=android&devicetype=phone&version=6.0.9" GET_CHANNEL_URL = "https://tv.media.jio.com/apis/v2.0/getchannelurl/getchannelurl?langId=6&userLanguages=All" CATCHUP_SRC = "http://jiotv.data.cdn.jio.com/apis/v1.3/getepg/get?offset={0}&channel_id={1}&langId=6" M3U_SRC = os.path.join(translatePath( @@ -161,7 +161,7 @@ } ] LANG_MAP = {6: "English", 1: "Hindi", 2: "Marathi", 3: "Punjabi", 4: "Urdu", 5: "Bengali", 7: "Malayalam", 8: "Tamil", - 9: "Gujarati", 10: "Odia", 11: "Telugu", 12: "Bhojpuri", 13: "Kannada", 14: "Assamese", 15: "Nepali", 16: "French"} + 9: "Gujarati", 10: "Odia", 11: "Telugu", 12: "Bhojpuri", 13: "Kannada", 14: "Assamese", 15: "Nepali", 16: "French", 18:"Extra"} GENRE_MAP = {8: "Sports", 5: "Entertainment", 6: "Movies", 12: "News", 13: "Music", 7: "Kids", 9: "Lifestyle", 10: "Infotainment", 15: "Devotional", 16: "Business", 17: "Educational", 18: "Shopping", 19: "JioDarshan"} CONFIG = {"Genres": GENRE_CONFIG, "Languages": LANGUAGE_CONFIG} diff --git a/resources/lib/main.py b/resources/lib/main.py index 86191d4..c79f272 100644 --- a/resources/lib/main.py +++ b/resources/lib/main.py @@ -289,6 +289,7 @@ def play(plugin, channel_id, showtime=None, srno=None , stream_type=None, progra return PLAY_EX_URL + extra.get(str(channel_id)).get("data") # Script.notify("showtime", showtime) # Script.notify("begin", begin) + # Script.notify("end", end) # Script.notify("programid", programId) # Script.notify("stream_type", stream_type) rjson = { @@ -308,9 +309,9 @@ def play(plugin, channel_id, showtime=None, srno=None , stream_type=None, progra headers['srno'] = str(uuid4()) res = urlquick.post(GET_CHANNEL_URL, json=rjson, headers=getChannelHeaders(), max_age=-1) # Script.notify("challelurl", res.status_code) - Script.log(str(getChannelHeaders()), lvl=Script.INFO) + # Script.log(str(getChannelHeaders()), lvl=Script.INFO) resp = res.json() - Script.log(str(res.json()), lvl=Script.INFO) + # Script.log(str(resp), lvl=Script.INFO) art = {} onlyUrl = resp.get("result", "").split("?")[0].split('/')[-1] art["thumb"] = art["icon"] = IMG_CATCHUP + \ @@ -322,6 +323,8 @@ def play(plugin, channel_id, showtime=None, srno=None , stream_type=None, progra m3u8Headers = {} m3u8Headers['user-agent'] = headers['user-agent'] m3u8Headers['cookie'] = cookie + # Script.log(str(m3u8Headers), lvl=Script.INFO) + # Script.log(uriToUse, lvl=Script.INFO) m3u8Res = urlquick.get(uriToUse, headers=m3u8Headers, max_age=-1 , raise_for_status=True , timeout=5) # Script.notify("m3u8url", m3u8Res.status_code) m3u8String = m3u8Res.text @@ -337,6 +340,7 @@ def play(plugin, channel_id, showtime=None, srno=None , stream_type=None, progra if rjson["stream_type"] == 'Catchup'and "?" in variant_m3u8.playlists[quality].uri: uriToUse=uriToUse.split("?")[0] + "&" + cookie uriToUse = uriToUse.replace(onlyUrl, variant_m3u8.playlists[quality].uri) + # Script.log(uriToUse, lvl=Script.INFO) return Listitem().from_dict(**{ "label": plugin._title, "art": art, @@ -408,8 +412,9 @@ def m3ugen(plugin, notify="yes"): catchup = "" if channel.get("isCatchupAvailable"): # get the epg for this channel + # }&begin={{Y}}{{m}}{{d}}T{{H}}{{M}}{{S}}&end={{Y}}{{m}}{{d}}T{{H}}{{M}}{{S}} - catchup = ' catchup="vod" catchup-source="{0}channel_id={1}&showtime={{H}}{{M}}{{S}}&srno={{Y}}{{m}}{{d}}&begin={{Y}}{{m}}{{d}}T{{H}}{{M}}{{S}}&end={{Y}}{{m}}{{d}}T{{H}}{{M}}{{S}}" catchup-days="7"'.format( + catchup = ' catchup="vod" catchup-source="{0}channel_id={1}&showtime={{H}}{{M}}{{S}}&srno={{Y}}{{m}}{{d}}" catchup-days="7"'.format( PLAY_URL, channel.get("channel_id")) m3ustr += M3U_CHANNEL.format( tvg_id=channel.get("channel_id"),