import os import re import codecs import logging import music from flask import Flask, json, render_template from functools import wraps from flask_ask import Ask, session, question, statement, audio, request, context from shutil import copyfile from kodi_voice import KodiConfigParser, Kodi app = Flask(__name__) config_file = os.path.join(os.path.dirname(__file__), "kodi.config") config = KodiConfigParser(config_file) LOGLEVEL = config.get('global', 'loglevel') LOGSENSITIVE = config.getboolean('global', 'logsensitive') logging.basicConfig(level=logging.INFO) log = logging.getLogger('kodi_alexa.' + __name__) log.setLevel(LOGLEVEL) kodi_voice_log = logging.getLogger('kodi_voice') kodi_voice_log.setLevel(LOGLEVEL) kodi_voice_log.propagate = True if LOGSENSITIVE: requests_log = logging.getLogger('requests.packages.urllib3') requests_log.setLevel(LOGLEVEL) requests_log.propagate = True SKILL_ID = config.get('alexa', 'skill_id')
import re import string import random import os from kodi_voice import KodiConfigParser, Kodi config_file = os.path.join(os.path.dirname(__file__), "kodi.config") config = KodiConfigParser(config_file) kodi = Kodi(config) def most_words(l=[]): longest = 0 for s in l: if len(s.split()) > longest: longest = len(s.split()) return longest def sort_by_words(l, longest): distributed = [] for i in range(1, longest + 1): dl = [s for s in l if len(s.split()) == i] if dl: distributed.append(dl) return distributed def clean_results(resp, cat, key, limit=None): if not limit: