コード例 #1
0
def main():
    parser = argparse.ArgumentParser(
        prog='plexlibrary',
        description=("This utility creates or maintains a Plex library "
                     "based on a configuration recipe."),
        usage='%(prog)s [options] [<recipe>]',
    )
    parser.add_argument('recipe', nargs='?',
                        help='Create a library using this recipe')
    parser.add_argument(
        '-l', '--list-recipes', action='store_true',
        help='list available recipes')
    parser.add_argument(
        '-s', '--sort-only', action='store_true', help='only sort the library')

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    args = parser.parse_args()
    if args.list_recipes:
        list_recipes()
        sys.exit(0)

    if args.recipe not in recipes.get_recipes():
        print("Error: No such recipe")
        list_recipes()
        sys.exit(1)

    r = Recipe(args.recipe)
    r.run(args.sort_only)

    print("Done!")
コード例 #2
0
def list_recipes(directory=None):
    """
    list all the recipes available
    """
    print("Available recipes:")
    for name in recipes.get_recipes(directory):
        print("    {}".format(name))
コード例 #3
0
def main():
    parser = argparse.ArgumentParser(
        prog='plexlibrary',
        description=("This utility creates or maintains a Plex library "
                     "based on a configuration recipe."),
        usage='%(prog)s [options] [<recipe>]',
    )
    parser.add_argument('recipe',
                        nargs='?',
                        help='Create a library using this recipe')
    parser.add_argument('-l',
                        '--list-recipes',
                        action='store_true',
                        help='list available recipes')
    parser.add_argument('-s',
                        '--sort-only',
                        action='store_true',
                        help='only sort the library')
    parser.add_argument('-p',
                        '--playlists',
                        action='store_true',
                        help='make playlists rather than libraries')
    parser.add_argument(
        '-e',
        '--everyone',
        action='store_true',
        help='share playlist with all users (overrides settings in recipe)')

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    args = parser.parse_args()
    if args.list_recipes:
        list_recipes()
        sys.exit(0)

    if args.recipe not in recipes.get_recipes():
        print("Error: No such recipe")
        list_recipes()
        sys.exit(1)

    r = Recipe(recipe_name=args.recipe, use_playlists=args.playlists)
    r.run(sort_only=args.sort_only, share_playlist_to_all=args.everyone)

    print("Done!")
コード例 #4
0
ファイル: thewebsite.py プロジェクト: mrpasta/coolwebsite
app = Flask(__name__, static_url_path='/static')

assets = Environment(app)
js = Bundle('js/main.jsx',
            depends=('*/*.js*'),
            filters=Browserify,
            output='app.js')
assets.register('js_all', js)


@app.route('/')
def index():
    return render_template('index.html')


recipe_dict = get_recipes()
recipe_list = recipe_dict.values()


@app.route('/recipes/')
@app.route('/recipes/<int:recipeid>')
def recipes(recipeid=None):
    def filter_keys(item):
        return {
            key: item[key]
            for key in [
                'recipeid', 'recipetitle', 'firstline', 'recipemeta',
                'recipetext', 'recipenotes'
            ]
        }
コード例 #5
0
ファイル: make_db.py プロジェクト: CS446-Group12/Pocket-Chef
import recipes
import sqlite3
import ingredients
import sys

all_recipes = recipes.get_recipes()
all_ingredients = ingredients.read_ingredients()


def get_first(result):
    for r in result:
        return r[0]


def insert_ingredients(conn):
    def insert_ingredient(i_id, ingred):
        sql = "insert into INGREDIENT(id, name) values (?, ?)"
        conn.execute(sql, (i_id, ingred))

    for i_id in all_ingredients:
        name = all_ingredients[i_id]
        insert_ingredient(i_id, name)


def insert_recipe_ingreds(conn, recipe, recipe_id):
    def insert_recipe_ingred(recipe_id, i_id):
        # sql = "select ID from ingredient where name=?"
        # ingred_id = get_first(conn.execute(sql, (ingred,)))
        sql = "insert or ignore into recipe_ingredient values(?,?)"
        conn.execute(sql, (recipe_id, i_id))