Example #1
0
def ean_add_to_db(ean):
    res = query_db("SELECT * FROM inventory WHERE ean=:ean", {"ean": ean})

    if len(res) >= 1:
        d = res[0]
    else:
        d = resolve_ean(ean, "images")
        d["added"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

        if isinstance(d["artists"], list):
            d["artists"] = ",".join(d["artists"]) 

        insert_from_dict("inventory", d, {"type": "category"}, ["imgurl"])

    return d
Example #2
0
def errors():
    cur = get_db().cursor()
    
    #Process POST data when available
    resolved_data = []
    for oldean, newean in request.form.items():
        if newean.strip() != "":
            d = resolve_ean(newean, "images")
            resolved_data.append(d)
            cur.execute("UPDATE inventory SET title=:title, description=:description, duration=:duration, imgfile=:imgfile, studio=:studio WHERE ean=:ean", d)
            get_db().commit()

    cur.execute("SELECT ean FROM inventory WHERE title IS NULL")
    unsorteditems = cur.fetchall()

    return render_template("errors.html", eanlist=unsorteditems, resolved_data=resolved_data)
Example #3
0
from ean_resolve import resolve_ean
import pathlib

EANS = [
    4010232055620,
    4010232046369,
    5050582871753,
    5051890139610,
    4045167004429
]

if __name__ == "__main__":
#    try:
        dl_dir = "images"
        dl_dir_path = pathlib.Path(dl_dir)
        if not dl_dir_path.exists():
            dl_dir_path.mkdir()
        for ean in EANS:
            print(resolve_ean(ean, dl_dir=dl_dir))

#    except:
#        import pdb;
#        pdb.post_mortem()
Example #4
0
import sqlite3
from ean_resolve import resolve_ean, EANNotResolved

#EAN-Liste generieren
db = sqlite3.connect("test.db")
cur = db.cursor()
cur.execute("SELECT ean FROM movies")
eans = [e[0] for e in cur.fetchall()]

import pprint; pprint.pprint(eans)

for ean in eans:
    try:
        dvd_movie = resolve_ean(ean, dl_dir="images") 
        cur.execute("UPDATE movies SET title=?, artists=?, duration=?, imgfile=?, studio=?, description=? WHERE ean=?", (dvd_movie["title"], ", ".join(dvd_movie["artists"]) if "artists" in dvd_movie else None, dvd_movie["duration"], dvd_movie["imgfile"], dvd_movie["studio"], dvd_movie["description"], dvd_movie["ean"])) 
        db.commit()
        print("Updating EAN = ", ean)
    except Exception as e:
        print("EAN {} could not be resolved!".format(ean))
        print(e)