def merge(**kwargs):
    if xbmc.getInfoLabel('Skin.String({})'.format(ADDON_ID)) == FORCE_RUN_FLAG:
        raise PluginError(_.MERGE_IN_PROGRESS)

    xbmc.executebuiltin('Skin.SetString({},{})'.format(ADDON_ID,
                                                       FORCE_RUN_FLAG))
    gui.notification(_.MERGE_STARTED)
Beispiel #2
0
def alert(asset, title, **kwargs):
    alerts = userdata.get('alerts', [])

    if asset not in alerts:
        alerts.append(asset)
        gui.notification(title, heading=_.REMINDER_SET)
    else:
        alerts.remove(asset)
        gui.notification(title, heading=_.REMINDER_REMOVED)

    userdata.set('alerts', alerts)
    gui.refresh()
def alert(asset, title, image):
    alerts = userdata.get('alerts', [])

    if asset not in alerts:
        alerts.append(asset)
        gui.notification(_.REMINDER_SET, heading=title, icon=image)
    else:
        alerts.remove(asset)
        gui.notification(_.REMINDER_REMOVED, heading=title, icon=image)

    userdata.set('alerts', alerts)
    gui.refresh()
Beispiel #4
0
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
Beispiel #5
0
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 export_sources(**kwargs):
    folder = xbmcgui.Dialog().browseSingle(3, _.SELECT_EXPORT_FOLDER, "")
    if not folder:
        return

    folder = xbmc.translatePath(folder)
    path = os.path.join(folder, 'export.iptv_merge')

    data = []
    for source in Source.select():
        data.append({
            'item_type': source.item_type,
            'path_type': source.path_type,
            'path': source.path,
            'file_type': source.file_type,
            'order': source.order,
            'enabled': source.enabled,
        })

    with open(path, 'w') as outfile:
        json.dump(data, outfile)

    gui.notification(_(_.SOURCES_EXPORTED, count=len(data)))
def import_sources(**kwargs):
    file_path = xbmcgui.Dialog().browseSingle(1,
                                              _.SELECT_IMPORT_FILE,
                                              "",
                                              mask='.iptv_merge')
    if not file_path:
        return

    with open(file_path) as f:
        data = json.load(f)

    Source.truncate()

    count = 0
    for row in data:
        try:
            source = Source(**row)
            source.save()
        except:
            continue
        else:
            count += 1

    gui.notification(_(_.SOURCES_IMPORTED, count=count))
def remove_watchlist(id, title, **kwargs):
    api.set_user_media(id, is_bookmarked='false')
    gui.notification(title, heading=_.WATCHLIST_REMOVED)
    gui.refresh()
def add_watchlist(id, title, **kwargs):
    api.set_user_media(id, is_bookmarked='true')
    gui.notification(title, heading=_.WATCHLIST_ADDED)
    gui.refresh()
def merge():
    if not settings.get('output_dir'):
        raise plugin.PluginError(_.NO_OUTPUT_DIR)

    xbmc.executebuiltin('Skin.SetString({},{})'.format(ADDON_ID, FORCE_RUN_FLAG))
    gui.notification(_.MERGE_STARTED)