def run_merge(types): output_dir = xbmc.translatePath( settings.get('output_dir', '').strip() or ADDON_PROFILE) if not os.path.exists(output_dir): os.mkdir(output_dir) database.connect() try: if Source.PLAYLIST in types: playlists = list(Source.select().where( Source.item_type == Source.PLAYLIST, Source.enabled == True).order_by(Source.order.asc())) playlist_path = merge_playlists(playlists, output_dir) shutil.move(playlist_path, os.path.join(output_dir, PLAYLIST_FILE_NAME)) if Source.EPG in types: epgs = list(Source.select().where(Source.item_type == Source.EPG, Source.enabled == True).order_by( Source.order.asc())) epg_path = merge_epgs(epgs, output_dir) shutil.move(epg_path, os.path.join(output_dir, EPG_FILE_NAME)) finally: database.close()
def setup(**kwargs): try: xbmc.executebuiltin('InstallAddon({})'.format(IPTV_SIMPLE_ID), True) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":true}}}}' .format(IPTV_SIMPLE_ID)) addon = xbmcaddon.Addon(IPTV_SIMPLE_ID) except: raise PluginError(_.NO_IPTV_SIMPLE) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":false}}}}' .format(IPTV_SIMPLE_ID)) output_dir = xbmc.translatePath( settings.get('output_dir', '').strip() or ADDON_PROFILE) playlist_path = os.path.join(output_dir, PLAYLIST_FILE_NAME) epg_path = os.path.join(output_dir, EPG_FILE_NAME) addon.setSetting('m3uPathType', '0') addon.setSetting('m3uPath', playlist_path) addon.setSetting('epgPathType', '0') addon.setSetting('epgPath', epg_path) settings.setBool('restart_pvr', True) xbmc.executeJSONRPC( '{{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{{"addonid":"{}","enabled":true}}}}' .format(IPTV_SIMPLE_ID)) xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"epg.futuredaystodisplay", "value":7}, "id":1}' ) xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.backendchannelorder", "value":true}, "id":1}' ) xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.usebackendchannelnumbers", "value":true}, "id":1}' ) xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.syncchannelgroups", "value":true}, "id":1}' ) xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"epg.ignoredbforclient", "value":true}, "id":1}' ) #xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.preselectplayingchannel", "value":true}, "id":1}') gui.ok(_.SETUP_COMPLETE)
def run_merge(): output_dir = xbmc.translatePath(settings.get('output_dir')) if not output_dir: return database.connect() playlists = list( Source.select().where(Source.item_type == Source.PLAYLIST)) epgs = list(Source.select().where(Source.item_type == Source.EPG)) database.close() playlist = merge_playlists(playlists) epg = merge_epgs(epgs) with open(os.path.join(output_dir, PLAYLIST_FILE_NAME), 'wb') as f: f.write(playlist) with open(os.path.join(output_dir, EPG_FILE_NAME), 'wb') as f: f.write(epg)
def proxy_merge(type=None, **kwargs): from .service import run_merge output_dir = xbmc.translatePath( settings.get('output_dir', '').strip() or ADDON_PROFILE) playlist_path = os.path.join(output_dir, PLAYLIST_FILE_NAME) epg_path = os.path.join(output_dir, EPG_FILE_NAME) if type == 'epg': run_merge([Source.EPG]) return plugin.Item(path=epg_path) elif type == 'playlist': run_merge([Source.PLAYLIST]) return plugin.Item(path=playlist_path) else: run_merge([Source.EPG, Source.PLAYLIST]) return plugin.Item(path=output_dir)
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)