twitools/lyricsmanager.py
Klaus-Uwe Mitterer 6ad9a8a8da Add matching )
2017-02-21 16:08:09 +01:00

29 lines
651 B
Python
Executable file

#!/usr/bin/env python3
def addLyrics(text, ref = 0, db = dbtools.dbHelper()):
db.executeQuery("INSERT INTO lyrics(text, ref, active) VALUES('%s', %i, %i);" % (text, ref, (1 if ref == 0 else 0)))
db.commit()
return db.cur.lastrowid
def queryLyrics(ref = 0):
text = input("Text: ")
if len(text) > 130:
print("Text too long (%i characters)" % len(text))
return queryLyrics(ref)
ref = int(input("Reference [%i]: " % ref) or ref)
row = addLyrics(text, ref)
ans = ""
while ans.lower() not in ("y", "n"):
ans = input("Add follow-up lyrics? [Y/n] ")
if ans.lower() != "n":
queryLyrics(row)
if __name__ == "__main__":
queryLyrics()