1212import routing
1313
1414from resources .lib .cbc import CBC
15- from resources .lib .utils import log , getAuthorizationFile , get_cookie_file , get_iptv_channels_file
15+ from resources .lib .utils import log , getAuthorizationFile , get_iptv_channels_file , is_pending , iso8601_to_local
1616from resources .lib .livechannels import LiveChannels
1717from resources .lib .gemv2 import GemV2
1818from resources .lib .iptvmanager import IPTVManager
@@ -119,7 +119,6 @@ def logout():
119119 """Remove authorization stuff."""
120120 log ('Logging out...' , True )
121121 os .remove (getAuthorizationFile ())
122- os .remove (get_cookie_file ())
123122
124123
125124@plugin .route ('/iptv/channels' )
@@ -174,6 +173,7 @@ def play_live_channel():
174173def live_channels_menu ():
175174 """Populate the menu with live channels."""
176175 xbmcplugin .setContent (plugin .handle , 'videos' )
176+ xbmcplugin .addSortMethod (plugin .handle , xbmcplugin .SORT_METHOD_LABEL )
177177 chans = LiveChannels ()
178178 chan_list = chans .get_live_channels ()
179179 cbc = CBC ()
@@ -184,7 +184,10 @@ def live_channels_menu():
184184 item = xbmcgui .ListItem (labels ['title' ])
185185 item .setArt ({'thumb' : image , 'poster' : image })
186186 item .setInfo (type = "Video" , infoLabels = labels )
187- item .setProperty ('IsPlayable' , 'true' )
187+ air_date = channel .get ('airDate' )
188+ local_dt = iso8601_to_local (air_date ) if air_date else None
189+ if local_dt is None or not is_pending (local_dt ):
190+ item .setProperty ('IsPlayable' , 'true' )
188191 item .addContextMenuItems ([
189192 (getString (30014 ), 'RunPlugin({})' .format (plugin .url_for (live_channels_add_all ))),
190193 (getString (30015 ), 'RunPlugin({})' .format (plugin .url_for (live_channels_add , callsign ))),
@@ -222,16 +225,16 @@ def layout_menu(path):
222225 for f in items :
223226 n = GemV2 .normalized_format_item (f )
224227 p = GemV2 .normalized_format_path (f , path )
225- item = xbmcgui .ListItem (n ['label ' ])
228+ item = xbmcgui .ListItem (n ['title ' ])
226229 if 'art' in n :
227230 item .setArt (n ['art' ])
228231 item .setInfo (type = "Video" , infoLabels = n ['info_labels' ])
229- if n [ 'playable ' ]:
230- item .setProperty ('IsPlayable' , 'true' )
232+ if 'app_code' in n and n [ 'app_code ' ]:
233+ item .setProperty ('IsPlayable' , 'true' if 'playable' in n and n [ 'playable' ] else 'false' )
231234 url = plugin .url_for (play_live_channel , id = p , app_code = n ['app_code' ])
232235 else :
233236 url = plugin .url_for (layout_menu , p )
234- xbmcplugin .addDirectoryItem (handle , url , item , not n [ 'playable' ] )
237+ xbmcplugin .addDirectoryItem (handle , url , item , not 'app_code' in n )
235238 xbmcplugin .endOfDirectory (handle )
236239
237240
0 commit comments