コード例 #1
0
ファイル: main.py プロジェクト: tikki/movielst
def movie(variable):
    if not session.get('logged_in') and config.get_setting(
            'Web', 'require_login') == "True":
        return login()
    else:
        data = database.db_to_json()
        i = 0
        list = {}
        cached = None
        for datas in data:
            if datas["title"] == variable:
                list["title"] = datas["title"]
                list["genre"] = datas["genre"]
                list["imdb"] = datas["imdb"]
                list["runtime"] = datas["runtime"]
                list["tomato"] = datas["tomato"]
                list["year"] = datas["year"]
                list["awards"] = datas["awards"]
                list["cast"] = datas["cast"]
                list["director"] = datas["director"]
                list["poster"] = datas["poster"]
                list["file_info_name"] = datas["file_info"]["name"]
                if re.match(regex_url_valid, list["poster"]):
                    cached = False
                else:
                    list["poster"] = list["poster"].replace(
                        config.CONFIG_PATH + 'cache/', '')
                    cached = True

                list["description"] = datas["description"]
            i += 1
        return render_template('movie.html', list=list, cached=cached)
コード例 #2
0
ファイル: main.py プロジェクト: tikki/movielst
def export(type, name):
    if not session.get('logged_in') and config.get_setting(
            'Web', 'require_login') == "True":
        return login()
    else:
        if type == 'csv':
            database.export_to_csv(config.CONFIG_PATH + name)
            return send_file(config.CONFIG_PATH + name, as_attachment=True)
        elif type == 'xlsx':
            database.export_to_xlsx(config.CONFIG_PATH + name)
            return send_file(config.CONFIG_PATH + name, as_attachment=True)
        else:
            return "File type not supported"
コード例 #3
0
ファイル: main.py プロジェクト: tikki/movielst
def settings_user():
    if not session.get('logged_in') and config.get_setting(
            'Web', 'require_login') == "True":
        return login()
    else:
        form = AddUserForm()
        choices_list = [(i[0], i[0]) for i in database.get_users()]
        form.user_list_field.choices = choices_list

        if form.validate_on_submit():
            if form.submit.data:
                # Add user to database
                database.add_user(form.username_field.data,
                                  form.password_field.data)
            if form.delete.data:
                database.delete_user(form.user_list_field.data)
        form.process()
        return render_template('settings/users.html', form=form)
コード例 #4
0
ファイル: main.py プロジェクト: tikki/movielst
def index():
    if not session.get('logged_in') and config.get_setting(
            'Web', 'require_login') == "True":
        return login()
    else:
        form = IndexForm()
        error = None
        cached = False
        data = database.db_to_json()
        if not data:
            data = None
        if form.validate_on_submit():
            if form.run_index.data:
                output = subprocess.check_output('movielst ' +
                                                 form.index_location.data)
                if "Directory does not exists." in str(output):
                    error = "invalid directory"
                else:
                    return redirect('/')
        form.process()
        search_form = SearchForm(request.form)
        if search_form.search.data:
            if search_form.autocomp.data:
                return redirect('/movie/' + search_form.autocomp.data)
        if data is not None:
            for movie in data:
                if re.match(regex_url_valid, movie["poster"]):
                    # is a valid url, return cached False, ie. do nothing
                    cached = False
                else:
                    # Is not a url, return cached True to show local file instead#
                    cached = True
        return render_template('home.html',
                               movie_list=data,
                               form=form,
                               error=error,
                               cached=cached,
                               search=search_form)
コード例 #5
0
ファイル: main.py プロジェクト: tikki/movielst
def main():
    check_for_dep()
    app.run(host=config.get_setting('Web', 'host'),
            port=config.get_setting('Web', 'port'),
            debug=False)
コード例 #6
0
ファイル: main.py プロジェクト: tikki/movielst
def settings():
    if not session.get('logged_in') and config.get_setting(
            'Web', 'require_login') == "True":
        return login()
    else:
        form = SettingsForm()
        form.log_level_field.default = config.get_setting(
            'General', 'log_level')
        form.log_location_field.default = config.get_setting(
            'General', 'log_location')
        form.location_field.default = config.get_setting('Index', 'location')
        form.min_index_field.default = config.get_setting(
            'Index', 'min_size_to_index')
        form.use_external_api_field.default = config.get_setting(
            'API', 'use_external_api')
        form.omdb_api_key_field.default = config.get_setting(
            'API', 'OMDb_API_key')
        form.tmdb_api_key_field.default = config.get_setting(
            'API', 'TMdb_API_key')
        form.web_host_field.default = config.get_setting('Web', 'host')
        form.web_port_field.default = config.get_setting('Web', 'port')
        form.web_require_login_field.default = config.get_setting(
            'Web', 'require_login')
        if form.validate_on_submit():
            config.update_config('General', 'log_level',
                                 form.log_level_field.data)
            config.update_config('General', 'log_location',
                                 form.log_location_field.data)
            config.update_config('Index', 'location', form.location_field.data)
            config.update_config('Index', 'min_size_to_index',
                                 str(form.min_index_field.data))
            config.update_config('API', 'use_external_api',
                                 form.use_external_api_field.data)
            config.update_config('API', 'OMDb_API_key',
                                 form.omdb_api_key_field.data)
            config.update_config('API', 'TMdb_API_key',
                                 form.tmdb_api_key_field.data)
            config.update_config('Web', 'host', form.web_host_field.data)
            config.update_config('Web', 'port', form.web_port_field.data)
            config.update_config('Web', 'require_login',
                                 form.web_require_login_field.data)
            if form.delete_index.data:
                database.delete_all_movies()
        form.process()
        return render_template('settings/settings.html', form=form)