Skip to content

Commit

Permalink
V-001 changes from community
Browse files Browse the repository at this point in the history
  • Loading branch information
tobalan committed Jun 25, 2023
1 parent 095dc1f commit ee34f62
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 94 deletions.
10 changes: 8 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.jiotv" name="JioTV" version="2.3.3" provider-name="tobalan">
<addon id="plugin.video.jiotv" name="JioTV" version="2.3.4" provider-name="tobalan">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.codequick" version="1.0.2"/>
<import addon="script.module.inputstreamhelper" version="0.5.10"/>
<import addon="inputstream.adaptive" minversion="2.6.6"/>
<import addon="inputstream.adaptive" version="20.3.2"/>
<import addon="script.module.m3u8" version="0.5.4"/>
<!-- <import addon="repository.botallen" version="2.0.0"/> -->
<!-- <import addon="script.module.web-pdb" /> -->
Expand All @@ -24,6 +24,12 @@
<email>[email protected]</email>
<source>https://github.com/tobalan/plugin.video.jiotv</source>
<news>
[- 2.3.4 -]
[added] AAC multi-audio fix (3rd Jun 2023)
[added] Genres selection in Settings with Languages
[added] EPG Source URL editable in Settings
[added] Settings sections rearranged, removed 'Welcome-donate' popup.

[- 2.3.3 -]
[added] updated epg url
[added] set epg cache to false
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FEATURED_SRC = "https://tv.media.jio.com/apis/v1.6/getdata/featurednew?start=0&limit=30&langId=6"
CHANNELS_SRC_NEW = "https://jiotv.data.cdn.jio.com/apis/v3.0/getMobileChannelList/get/?langId=6&os=android&devicetype=phone&usertype=tvYR7NSNn7rymo3F&version=285"
CHANNELS_SRC = CHANNELS_SRC_NEW if Settings.get_boolean(
"channelsrc") else "https://jiotv.data.cdn.jio.com/apis/v1.3/getMobileChannelList/get/?os=android&devicetype=phone&usertype=JIO&version=290&langId=6"
"channelsrc") else "https://jiotv.data.cdn.jio.com/apis/v1.4/getMobileChannelList/get/?os=android&devicetype=phone&usertype=JIO&version=296&langId=6"
GET_CHANNEL_URL = "https://tv.media.jio.com/apis/v2.0/getchannelurl/getchannelurl?langId=6&userLanguages=All"
CATCHUP_SRC = "https://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
151 changes: 80 additions & 71 deletions resources/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,78 +299,87 @@ def play(plugin, channel_id, showtime=None, srno=None, programId=None, begin=Non
# Script.notify("srno", srno)
# Script.notify("showtime", showtime)
# Script.notify("channel_id", channel_id)
is_helper = inputstreamhelper.Helper("mpd", drm="com.widevine.alpha")
hasIs = is_helper.check_inputstream()
if not hasIs:
return
rjson = {
"channel_id": int(channel_id),
"stream_type": "Seek"
}
isCatchup = False
if showtime and srno:
isCatchup = True
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()) if "srno" not in rjson else rjson["srno"]
res = urlquick.post(GET_CHANNEL_URL, json=rjson,
headers=getChannelHeaders(), max_age=-1)
resp = res.json()
art = {}
onlyUrl = resp.get("result", "").split("?")[0].split('/')[-1]
art["thumb"] = art["icon"] = IMG_CATCHUP + \
onlyUrl.replace(".m3u8", ".png")
cookie = "__hdnea__"+resp.get("result", "").split("__hdnea__")[-1]
headers['cookie'] = cookie
uriToUse = resp.get("result", "")
qltyopt = Settings.get_string("quality")
selectionType = "adaptive"
if qltyopt == 'Manual':
selectionType = "ask-quality"
else:
m3u8Headers = {}
m3u8Headers['user-agent'] = headers['user-agent']
m3u8Headers['cookie'] = cookie
m3u8Res = urlquick.get(uriToUse, headers=m3u8Headers,
max_age=-1, raise_for_status=True)
# Script.notify("m3u8url", m3u8Res.status_code)
m3u8String = m3u8Res.text
variant_m3u8 = m3u8.loads(m3u8String)
if variant_m3u8.is_variant and (variant_m3u8.version is None or variant_m3u8.version < 7):
quality = quality_to_enum(qltyopt, len(variant_m3u8.playlists))
if isCatchup:
tmpurl = variant_m3u8.playlists[quality].uri
if "?" in tmpurl:
uriToUse = uriToUse.split("?")[0].replace(onlyUrl, tmpurl)
else:
uriToUse = uriToUse.replace(onlyUrl, tmpurl.split("?")[0])
del headers['cookie']
else:
uriToUse = uriToUse.replace(
onlyUrl, variant_m3u8.playlists[quality].uri)
Script.log(uriToUse, lvl=Script.INFO)
return Listitem().from_dict(**{
"label": plugin._title,
"art": art,
"callback": uriToUse,
"properties": {
"IsPlayable": True,
"inputstream": "inputstream.adaptive",
'inputstream.adaptive.stream_selection_type': selectionType,
"inputstream.adaptive.chooser_resolution_secure_max": "4K",
"inputstream.adaptive.stream_headers": urlencode(headers),
"inputstream.adaptive.manifest_type": "hls",
"inputstream.adaptive.license_key": "|" + urlencode(headers) + "|R{SSM}|",
try:
is_helper = inputstreamhelper.Helper("mpd", drm="com.widevine.alpha")
hasIs = is_helper.check_inputstream()
if not hasIs:
return
rjson = {
"channel_id": int(channel_id),
"stream_type": "Seek"
}
})

isCatchup = False
if showtime and srno:
isCatchup = True
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()) if "srno" not in rjson else rjson["srno"]
res = urlquick.post(GET_CHANNEL_URL, json=rjson,
headers=getChannelHeaders(), max_age=-1, raise_for_status=True)
# if res.status_code
resp = res.json()
art = {}
onlyUrl = resp.get("result", "").split("?")[0].split('/')[-1]
art["thumb"] = art["icon"] = IMG_CATCHUP + \
onlyUrl.replace(".m3u8", ".png")
cookie = "__hdnea__"+resp.get("result", "").split("__hdnea__")[-1]
headers['cookie'] = cookie
uriToUse = resp.get("result", "")
qltyopt = Settings.get_string("quality")
selectionType = "adaptive"
if qltyopt == 'Manual':
selectionType = "ask-quality"
else:
m3u8Headers = {}
m3u8Headers['user-agent'] = headers['user-agent']
m3u8Headers['cookie'] = cookie
m3u8Res = urlquick.get(uriToUse, headers=m3u8Headers,
max_age=-1, raise_for_status=True)
# Script.notify("m3u8url", m3u8Res.status_code)
m3u8String = m3u8Res.text
variant_m3u8 = m3u8.loads(m3u8String)
if variant_m3u8.is_variant and (variant_m3u8.version is None or variant_m3u8.version < 7):
quality = quality_to_enum(qltyopt, len(variant_m3u8.playlists))
if isCatchup:
tmpurl = variant_m3u8.playlists[quality].uri
if "?" in tmpurl:
uriToUse = uriToUse.split(
"?")[0].replace(onlyUrl, tmpurl)
else:
uriToUse = uriToUse.replace(
onlyUrl, tmpurl.split("?")[0])
del headers['cookie']
else:
uriToUse = uriToUse.replace(
onlyUrl, variant_m3u8.playlists[quality].uri)
Script.log(uriToUse, lvl=Script.INFO)
return Listitem().from_dict(**{
"label": plugin._title,
"art": art,
"callback": uriToUse,
"properties": {
"IsPlayable": True,
"inputstream": "inputstream.adaptive",
'inputstream.adaptive.stream_selection_type': selectionType,
"inputstream.adaptive.chooser_resolution_secure_max": "4K",
"inputstream.adaptive.manifest_headers": urlencode(headers),
"inputstream.adaptive.manifest_type": "hls",
"inputstream.adaptive.license_key": "|" + urlencode(headers) + "|R{SSM}|",
}
})
except Exception as e:
Script.notify("Login Error", "Session expired. Please login again")
executebuiltin(
"RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/login/)")
return False

# Login `route` to access from Settings
@Script.register
Expand Down
10 changes: 7 additions & 3 deletions resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def login(username, password, mode="unpw"):
# db["exp"] = time.time() + 432000
db["exp"] = time.time() + 31536000
if mode == "unpw":
db["exp"] = time.time() + 432000
db["username"] = username
db["password"] = password
Script.notify("Login Success", "")
Expand Down Expand Up @@ -204,9 +205,12 @@ def getFeatured():
Script.notify("Connection error ", "Retry after sometime")

def cleanLocalCache():
with PersistentDict("localdb") as db:
del db["channelList"]
del db["dictionary"]
try:
with PersistentDict("localdb") as db:
del db["channelList"]
del db["dictionary"]
except:
Script.notify("Cache", "Cleaned")


def getChannelHeaders():
Expand Down
40 changes: 26 additions & 14 deletions resources/settings.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="Account">
<setting id="login" type="action" label="Login" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/login/)" option="close"/>
<setting id="logout" type="action" label="Logout" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/logout/)" option="close"/>
<setting id="setMobile" type="action" label="Update jio number" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/setmobile/)" option="close"/>
<setting id="mobile" type="text" label="Jio number"/>
<setting id="applyAllSettings0" type="action" label="Apply all settings" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/applyall/)" option="close"/>
</category>
<category label="Setup">
<setting id="channelsrc" type="bool" label="Channel API 3.0" default="true"/>
<setting id="quality" type="labelenum" label="Stream Quality" values="Manual|Best|High|Medium+|Medium|Low|Lowest" default="Best"/>
<setting id="cleanup" type="action" label="Clear Cache" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/cleanup/)" option="close"/>
<setting label="Setup Simple IPTV PVR" type="action" id="pvrsetup" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/pvrsetup/)" option="close"/>
<setting id="m3ugen" type="bool" label="Generate Playlist On Startup" default="false"/>
<!-- <setting id="extraPl" type="text" label="Extra Playlist"/> -->
<setting id="channelsrc" type="bool" label="Channel API 3.0" default="false"/>
<setting id="epgsource" type="text" label="EPG Source" default="https://tobalan.github.io/epg.xml.gz"/>
<setting id="applyAllSettings1" type="action" label="Apply all settings" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/applyall/)" option="close"/>
</category>
<category label="Genres">
<setting id="Entertainment" type="bool" label="Entertainment" default="true"/>
<setting id="Lifestyle" type="bool" label="Lifestyle" default="true"/>
<setting id="Infotainment" type="bool" label="Infotainment" default="true"/>
<setting id="Devotional" type="bool" label="Devotional" default="true"/>
<setting id="Jio Darshan" type="bool" label="Jio Darshan" default="true"/>
<setting id="News" type="bool" label="News" default="true"/>
<setting id="Business News" type="bool" label="Business News" default="true"/>
<setting id="Movies" type="bool" label="Movies" default="true"/>
<setting id="Music" type="bool" label="Music" default="true"/>
<setting id="Educational" type="bool" label="Educational" default="true"/>
<setting id="Kids" type="bool" label="Kids" default="true"/>
<setting id="Shopping" type="bool" label="Shopping" default="true"/>
<setting id="Sports" type="bool" label="Sports" default="true"/>
<setting id="applyAllSettings3" type="action" label="Apply all settings" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/applyall/)" option="close"/>
</category>
<category label="Languages">
<setting id="Hindi" type="bool" label="Hindi" default="true"/>
<setting id="English" type="bool" label="English" default="true"/>
Expand All @@ -33,11 +44,12 @@
<setting id="Extra" type="bool" label="Extra" default="true"/>
<setting id="applyAllSettings2" type="action" label="Apply all settings" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/applyall/)" option="close"/>
</category>
<category label="More">
<setting id="cleanup" type="action" label="Clear Cache" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/cleanup/)" option="close"/>
<setting id="popup" type="bool" label="Disable Welcome Popup" default="true"/>
<setting id="quality" type="labelenum" label="Stream Quality" values="Manual|Best|High|Medium+|Medium|Low|Lowest" default="Best"/>
<setting id="applyAllSettings3" type="action" label="Apply all settings" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/applyall/)" option="close"/>
<category label="Account">
<setting id="login" type="action" label="Login" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/login/)" option="close"/>
<setting id="logout" type="action" label="Logout" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/logout/)" option="close"/>
<setting id="setMobile" type="action" label="Update Jio number" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/setmobile/)" option="close"/>
<setting id="mobile" type="text" label="Jio number"/>
<setting id="applyAllSettings0" type="action" label="Apply all settings" action="RunPlugin(plugin://plugin.video.jiotv/resources/lib/main/applyall/)" option="close"/>
</category>
</settings>

6 changes: 3 additions & 3 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def serveForever(handler):
t.setDaemon(True)
t.start()

if not Settings.get_boolean("popup"):
xbmcgui.Dialog().ok("JioTV Notification",
"Now you can create your custom playlist from BotAllen Dashboard. [CR]Find out more at [B]https://botallen.com/#dashboard[/B] [CR][CR]If you like this add-on then consider donating from [B]https://botallen.com/#donate[/B] [CR][CR]Github: [B]https://github.com/botallen/repository.botallen[/B] [CR]Discord: [B]https://botallen.com/discord[/B] [CR][CR][I]You can disable this popup from settings[/I]")
# if not Settings.get_boolean("popup"):
# xbmcgui.Dialog().ok("JioTV Notification",
# "Now you can create your custom playlist from BotAllen Dashboard. [CR]Find out more at [B]https://botallen.com/#dashboard[/B] [CR][CR]If you like this add-on then consider donating from [B]https://botallen.com/#donate[/B] [CR][CR]Github: [B]https://github.com/botallen/repository.botallen[/B] [CR]Discord: [B]https://botallen.com/discord[/B] [CR][CR][I]You can disable this popup from settings[/I]")

if Settings.get_boolean("m3ugen"):
executebuiltin(
Expand Down

0 comments on commit ee34f62

Please sign in to comment.