2017-02-21 15:00:55 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2017-02-21 15:09:40 +00:00
|
|
|
import dbtools
|
|
|
|
|
2017-02-21 15:00:55 +00:00
|
|
|
def addLyrics(text, ref = 0, db = dbtools.dbHelper()):
|
2017-02-26 18:12:37 +00:00
|
|
|
db.executeQuery("INSERT INTO lyrics(text, ref, active) VALUES('%s', %i, %i);" % (text.replace("'", "''"), ref, (1 if ref == 0 else 0)))
|
2017-02-21 15:00:55 +00:00
|
|
|
db.commit()
|
|
|
|
return db.cur.lastrowid
|
|
|
|
|
|
|
|
def queryLyrics(ref = 0):
|
2017-02-26 18:12:37 +00:00
|
|
|
text = "."
|
|
|
|
out = ""
|
|
|
|
|
|
|
|
while text != "":
|
|
|
|
text = input("Text: ")
|
|
|
|
if out != "":
|
|
|
|
out += "\n%s" % text
|
|
|
|
else:
|
|
|
|
out = text
|
|
|
|
|
|
|
|
if len(out) > 130:
|
|
|
|
print("Text too long (%i characters)" % len(out))
|
2017-02-21 15:03:45 +00:00
|
|
|
return queryLyrics(ref)
|
|
|
|
|
|
|
|
ref = int(input("Reference [%i]: " % ref) or ref)
|
2017-02-21 15:00:55 +00:00
|
|
|
|
2017-02-26 18:12:37 +00:00
|
|
|
row = addLyrics(out, ref)
|
2017-02-21 15:00:55 +00:00
|
|
|
|
2017-02-26 18:52:55 +00:00
|
|
|
ans = "."
|
2017-02-21 15:00:55 +00:00
|
|
|
|
2017-02-26 18:12:37 +00:00
|
|
|
while ans.lower() not in ("y", "n", ""):
|
2017-02-21 15:00:55 +00:00
|
|
|
ans = input("Add follow-up lyrics? [Y/n] ")
|
|
|
|
|
|
|
|
if ans.lower() != "n":
|
|
|
|
queryLyrics(row)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
queryLyrics()
|