def start(): monitor = xbmc.Monitor() restart_required = False while not monitor.waitForAbort(5): forced = xbmc.getInfoLabel( 'Skin.String({})'.format(ADDON_ID)) == FORCE_RUN_FLAG xbmc.executebuiltin('Skin.SetString({},)'.format(ADDON_ID)) if forced or time.time() - userdata.get( 'last_run', 0) > settings.getInt('reload_time_mins') * 60: try: run_merge() except Exception as e: result = False log.exception(e) else: result = True userdata.set('last_run', int(time.time())) if result: restart_required = settings.getBool('restart_pvr', False) if forced: gui.notification(_.MERGE_COMPLETE) elif forced: gui.exception() if restart_required and not xbmc.getCondVisibility( 'Pvr.IsPlayingTv') and not xbmc.getCondVisibility( 'Pvr.IsPlayingRadio'): restart_required = False addon_id = PVR_ADDON_IDS[settings.getInt('unused_pvr_id')] xbmc.executebuiltin('InstallAddon({})'.format(addon_id), True) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":true}}}}' .format(addon_id)) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":false}}}}' .format(addon_id))
def start(): restart_queued = False while not monitor.waitForAbort(2): forced = ADDON_DEV or xbmc.getInfoLabel( 'Skin.String({})'.format(ADDON_ID)) == FORCE_RUN_FLAG if forced or (settings.getBool('auto_merge', True) and time.time() - userdata.get('last_run', 0) > settings.getInt('reload_time_mins', 10) * 60): xbmc.executebuiltin('Skin.SetString({},{})'.format( ADDON_ID, FORCE_RUN_FLAG)) try: run_merge([Source.PLAYLIST, Source.EPG]) except Exception as e: result = False log.exception(e) else: result = True userdata.set('last_run', int(time.time())) xbmc.executebuiltin('Skin.SetString({},)'.format(ADDON_ID)) if result: restart_queued = True if forced: gui.notification(_.MERGE_COMPLETE) elif forced: gui.exception() if restart_queued and ( forced or (settings.getBool('restart_pvr', False) and not xbmc.getCondVisibility('Pvr.IsPlayingTv') and not xbmc.getCondVisibility('Pvr.IsPlayingRadio'))): restart_queued = False xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":false}}}}' .format(IPTV_SIMPLE_ID)) monitor.waitForAbort(2) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":true}}}}' .format(IPTV_SIMPLE_ID)) if ADDON_DEV: break
def _parse_video(asset): alerts = userdata.get('alerts', []) now = arrow.now() start = arrow.get(asset['transmissionTime']) precheck = start if 'preCheckTime' in asset: precheck = arrow.get(asset['preCheckTime']) if precheck > start: precheck = start start_from = (start - precheck).seconds item = plugin.Item( label=asset['title'], art={ 'thumb': _get_image(asset, 'carousel-item'), 'fanart': _get_image(asset, 'hero-default'), }, info={ 'plot': asset.get('description'), 'plotoutline': asset.get('description-short'), 'mediatype': 'video', }, playable=True, is_folder=False, ) is_live = False if now < start: is_live = True item.label = _(_.STARTING_SOON, title=asset['title'], humanize=start.humanize()) toggle_alert = plugin.url_for(alert, asset=asset['id'], title=asset['title'], image=item.art['thumb']) if asset['id'] not in userdata.get('alerts', []): item.info['playcount'] = 0 item.context.append( (_.SET_REMINDER, "XBMC.RunPlugin({})".format(toggle_alert))) else: item.info['playcount'] = 1 item.context.append( (_.REMOVE_REMINDER, "XBMC.RunPlugin({})".format(toggle_alert))) elif asset['isLive'] and asset.get('isStreaming', False): is_live = True item.label = _(_.LIVE, title=asset['title']) item.context.append((_.FROM_LIVE, "XBMC.PlayMedia({})".format( plugin.url_for(play, id=asset['id'], is_live=is_live, start_from=0)))) item.context.append((_.FROM_START, "XBMC.PlayMedia({})".format( plugin.url_for(play, id=asset['id'], is_live=is_live, start_from=start_from)))) index = settings.getInt('live_play_type', 0) if is_live and LIVE_PLAY_TYPE[index] == FROM_LIVE: start_from = 0 item.path = plugin.url_for(play, id=asset['id'], is_live=is_live, start_from=start_from) return item
def get_region(): return REGIONS[settings.getInt('region_index')]
from six.moves.urllib_parse import urlparse from kodi_six import xbmc, xbmcaddon from matthuisman import settings, userdata, database, gui from matthuisman.constants import ADDON_ID, ADDON_DEV, ADDON_PROFILE from matthuisman.log import log from matthuisman.session import Session from matthuisman.exceptions import Error from matthuisman.util import remove_file from .constants import FORCE_RUN_FLAG, PLAYLIST_FILE_NAME, EPG_FILE_NAME, METHOD_PLAYLIST, METHOD_EPG, MERGE_SETTING_FILE, IPTV_SIMPLE_ID, MERGE_START_WAIT, MERGE_TIMEOUT from .models import Source, Channels, save_epg_channels from .language import _ monitor = xbmc.Monitor() CHUNKSIZE = settings.getInt('chunksize', 4096) def call(cmd): log.debug('Subprocess call: {}'.format(cmd)) return subprocess.call(cmd) def find_gz(): log.debug('Searching for Gzip binary...') for gzbin in [ '/bin/gzip', '/usr/bin/gzip', '/usr/local/bin/gzip', '/system/bin/gzip' ]: if os.path.exists(gzbin):