@@ -113,7 +113,11 @@ def show_featured(plugin, id=None):
113113 info_dict ["params" ] = {
114114 "channel_id" : child .get ("channel_id" ),
115115 "showtime" : child .get ("showtime" , "" ).replace (":" , "" ),
116- "srno" : datetime .fromtimestamp (int (child .get ("startEpoch" , 0 )* .001 )).strftime ('%Y%m%d' )
116+ "srno" : datetime .fromtimestamp (int (child .get ("startEpoch" , 0 )* .001 )).strftime ('%Y%m%d' ),
117+ "stream_type" : "Catchup" ,
118+ "programId" : child .get ("srno" , "" ),
119+ "begin" : datetime .utcfromtimestamp (int (child .get ("startEpoch" , 0 )* .001 )).strftime ('%Y%m%dT%H%M%S' ),
120+ "end" : datetime .utcfromtimestamp (int (child .get ("endEpoch" , 0 )* .001 )).strftime ('%Y%m%dT%H%M%S' )
117121 }
118122 yield Listitem .from_dict (** info_dict )
119123 else :
@@ -219,7 +223,11 @@ def show_epg(plugin, day, channel_id):
219223 "params" : {
220224 "channel_id" : each .get ("channel_id" ),
221225 "showtime" : None if islive else each .get ("showtime" , "" ).replace (":" , "" ),
222- "srno" : None if islive else datetime .fromtimestamp (int (each .get ("startEpoch" , 0 )* .001 )).strftime ('%Y%m%d' )
226+ "srno" : None if islive else datetime .fromtimestamp (int (each .get ("startEpoch" , 0 )* .001 )).strftime ('%Y%m%d' ),
227+ "stream_type" : None if islive else "Catchup" ,
228+ "programId" : None if islive else each .get ("srno" , "" ).replace (":" , "" ),
229+ "begin" : None if islive else datetime .utcfromtimestamp (int (each .get ("startEpoch" , 0 )* .001 )).strftime ('%Y%m%dT%H%M%S' ),
230+ "end" : None if islive else datetime .utcfromtimestamp (int (each .get ("endEpoch" , 0 )* .001 )).strftime ('%Y%m%dT%H%M%S' )
223231 }
224232 })
225233 if int (day ) == 0 :
@@ -267,7 +275,7 @@ def play_ex(plugin, dt=None):
267275# Also insures that user is logged in.
268276@Resolver .register
269277@isLoggedIn
270- def play (plugin , channel_id , showtime = None , srno = None ):
278+ def play (plugin , channel_id , showtime = None , srno = None , stream_type = None , programId = None , begin = None , end = None ):
271279 is_helper = inputstreamhelper .Helper ("mpd" , drm = "com.widevine.alpha" )
272280 hasIs = is_helper .check_inputstream ()
273281 if not hasIs :
@@ -279,7 +287,10 @@ def play(plugin, channel_id, showtime=None, srno=None):
279287 if extra .get (str (channel_id )).get ("ext" ):
280288 return extra .get (str (channel_id )).get ("ext" )
281289 return PLAY_EX_URL + extra .get (str (channel_id )).get ("data" )
282-
290+ # Script.notify("showtime", showtime)
291+ # Script.notify("begin", begin)
292+ # Script.notify("programid", programId)
293+ # Script.notify("stream_type", stream_type)
283294 rjson = {
284295 "channel_id" : int (channel_id ),
285296 "stream_type" : "Seek"
@@ -288,24 +299,30 @@ def play(plugin, channel_id, showtime=None, srno=None):
288299 rjson ["showtime" ] = showtime
289300 rjson ["srno" ] = srno
290301 rjson ["stream_type" ] = "Catchup"
302+ rjson ["programId" ] = programId
303+ rjson ["begin" ] = begin
304+ rjson ["end" ] = end
305+ Script .log (str (rjson ), lvl = Script .INFO )
291306 headers = getHeaders ()
292307 headers ['channelid' ] = str (channel_id )
293308 headers ['srno' ] = str (uuid4 ())
294309 res = urlquick .post (GET_CHANNEL_URL , json = rjson , headers = getChannelHeaders (), max_age = - 1 )
295310 # Script.notify("challelurl", res.status_code)
311+ Script .log (str (getChannelHeaders ()), lvl = Script .INFO )
296312 resp = res .json ()
313+ Script .log (str (res .json ()), lvl = Script .INFO )
297314 art = {}
298315 onlyUrl = resp .get ("result" , "" ).split ("?" )[0 ].split ('/' )[- 1 ]
299316 art ["thumb" ] = art ["icon" ] = IMG_CATCHUP + \
300317 onlyUrl .replace (".m3u8" , ".png" )
301- cookie = resp .get ("result" , "" ).split ("? " )[- 1 ]
318+ cookie = "__hdnea__" + resp .get ("result" , "" ).split ("__hdnea__ " )[- 1 ]
302319 headers ['cookie' ] = cookie
303320 params = getTokenParams ()
304321 uriToUse = resp .get ("result" ,"" )
305322 m3u8Headers = {}
306323 m3u8Headers ['user-agent' ] = headers ['user-agent' ]
307324 m3u8Headers ['cookie' ] = cookie
308- m3u8Res = urlquick .get (resp . get ( "result" , "" ) , headers = m3u8Headers , max_age = - 1 , raise_for_status = True , timeout = 5 )
325+ m3u8Res = urlquick .get (uriToUse , headers = m3u8Headers , max_age = - 1 , raise_for_status = True , timeout = 5 )
309326 # Script.notify("m3u8url", m3u8Res.status_code)
310327 m3u8String = m3u8Res .text
311328 variant_m3u8 = m3u8 .loads (m3u8String )
@@ -317,6 +334,8 @@ def play(plugin, channel_id, showtime=None, srno=None):
317334 # else:
318335 # quality = len(variant_m3u8.playlists) - 2
319336 #quality = len(variant_m3u8.playlists) - 1
337+ if rjson ["stream_type" ] == 'Catchup' and "?" in variant_m3u8 .playlists [quality ].uri :
338+ uriToUse = uriToUse .split ("?" )[0 ] + "&" + cookie
320339 uriToUse = uriToUse .replace (onlyUrl , variant_m3u8 .playlists [quality ].uri )
321340 return Listitem ().from_dict (** {
322341 "label" : plugin ._title ,
@@ -388,7 +407,9 @@ def m3ugen(plugin, notify="yes"):
388407 "channel_id={0}" .format (channel .get ("channel_id" ))
389408 catchup = ""
390409 if channel .get ("isCatchupAvailable" ):
391- catchup = ' catchup="vod" catchup-source="{0}channel_id={1}&showtime={{H}}{{M}}{{S}}&srno={{Y}}{{m}}{{d}}" catchup-days="7"' .format (
410+ # get the epg for this channel
411+
412+ 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 (
392413 PLAY_URL , channel .get ("channel_id" ))
393414 m3ustr += M3U_CHANNEL .format (
394415 tvg_id = channel .get ("channel_id" ),
0 commit comments