Skip to content

Commit

Permalink
Merge pull request botallen#8 from krreet/feature/support-for-catchup
Browse files Browse the repository at this point in the history
Feature/support for catchup
  • Loading branch information
krreet authored Feb 8, 2023
2 parents de77add + 5d7c0d8 commit ace9feb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions resources/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}
11 changes: 8 additions & 3 deletions resources/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 + \
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit ace9feb

Please sign in to comment.