def export_strm(row_id, export_path=None): if export_path is None: export_path = kodi.get_setting('export_path_strm') if not export_path: export_path = kodi.Dialog().browse(3, kodi.i18n('export_path_strm'), 'files', '', False, False) kodi.set_setting('export_path_strm', export_path) if export_path: default_filename = '' play_history = PlayHistory() rows = play_history.get(row_id=row_id) if rows: url, content_type, title, thumb = rows[0] default_filename = kodi.string_to_filename(title) + '.strm' strm_name = kodi.get_keyboard(kodi.i18n('strm_filename'), default_filename) if strm_name: if export_path.startswith('special://'): if not export_path.endswith('/'): export_path += '/' kodi.set_setting('export_path_strm', export_path) strm_file = kodi.translate_path(export_path + strm_name) else: strm_file = os.path.join(export_path, strm_name) STRMUtils(strm_file).export(row_id)
def delete_row(row_id, title='', refresh=True): confirmed = kodi.Dialog().yesno( kodi.i18n('confirm'), '%s \'%s\'%s' % (kodi.i18n('delete_url'), unquote(title), '?')) if confirmed: play_history = PlayHistory() result, rowcount = play_history.delete_row_id(row_id) if (result, rowcount) == (1, 1) and refresh: kodi.refresh_container()
def clear_cache(): confirmed = kodi.Dialog().yesno(kodi.i18n('confirm'), kodi.i18n('cache_yes_no')) if confirmed: result = cache.reset_cache() if result: kodi.notify(msg=kodi.i18n('cache_success'), sound=False) else: kodi.notify(msg=kodi.i18n('cache_failed'), sound=False)
def clear_history(ctype=None): ltype = ctype if ltype is None: ltype = 'all' confirmed = kodi.Dialog().yesno(kodi.i18n('confirm'), kodi.i18n('clear_yes_no') % ltype) if confirmed: play_history = PlayHistory() play_history.clear(ctype) kodi.refresh_container()
def change_thumb_by_row_id(row_id, local=True, refresh=True): if local: thumbnail = kodi.Dialog().browse(2, kodi.i18n('choose_thumbnail'), 'pictures', '', True, False, THUMBNAILS_DIR) else: thumbnail = kodi.get_keyboard(kodi.i18n('input_new_thumb')) if thumbnail and (not thumbnail.endswith('/')) and ( not thumbnail.endswith('\\')): play_history = PlayHistory() result = play_history.change_thumb(row_id, thumbnail) if result and refresh: kodi.refresh_container()
def clear_cookies(): confirmed = kodi.Dialog().yesno(kodi.i18n('confirm'), kodi.i18n('cookies_yes_no')) if confirmed: try: if kodi.vfs.exists(COOKIE_FILE): result = kodi.vfs.delete(COOKIE_FILE) else: result = True except: result = False if result: kodi.notify(msg=kodi.i18n('cookies_success'), sound=False) else: kodi.notify(msg=kodi.i18n('cookies_failed'), sound=False)
def manage_context(row_id, title): context_items = [ 'rename_row_id(row_id=row_id)', 'change_thumb_by_row_id(row_id=row_id)', 'change_thumb_by_row_id(row_id=row_id, local=False)', 'delete_row(row_id=row_id, title=unquote(title))' ] select_items = [ kodi.i18n('rename'), kodi.i18n('local_thumb'), kodi.i18n('url_thumb'), kodi.i18n('delete_url') ] result = kodi.Dialog().select(kodi.i18n('manage'), select_items) if result != -1: eval(context_items[result])
def export_m3u(export_path=None, from_list='history', ctype='video'): if export_path is None: export_path = kodi.get_setting('export_path') if not export_path: export_path = kodi.Dialog().browse(3, kodi.i18n('export_path'), 'files', '', False, False) kodi.set_setting('export_path', export_path) if export_path: m3u_name = kodi.get_keyboard(kodi.i18n('m3u_filename'), '') if m3u_name: if export_path.startswith('special://'): if not export_path.endswith('/'): export_path += '/' kodi.set_setting('export_path', export_path) m3u_file = kodi.translate_path(export_path + m3u_name) else: m3u_file = os.path.join(export_path, m3u_name) M3UUtils(m3u_file, from_list).export(ctype=ctype)
def history_dialog(self, ctype): if self.size_limit() != 0: _queries = self.get() if len(_queries) > 0: queries = [] for item, content_type, label in _queries: if content_type == ctype: queries += [label] if len(queries) > 0: queries.insert(0, '[B]{0!s}[/B]'.format(kodi.i18n('new_'))) queries.insert( 1, '[B]{0!s}[/B]'.format(kodi.i18n('clear_history'))) index = kodi.Dialog().select(kodi.i18n('choose_playback'), queries) if index > -1: if index == 1: self.clear() return '' elif index > 1: return queries[index] else: return '' return self.get_input()
def export_context(row_id, ctype): context_items = ['export_strm(row_id=row_id)', 'export_m3u(ctype=ctype)'] select_items = [kodi.i18n('export_to_strm'), kodi.i18n('export_list_m3u')] result = kodi.Dialog().select(kodi.i18n('export'), select_items) if result != -1: eval(context_items[result])