Ticket #8115: mythburn2.diff
File mythburn2.diff, 8.6 KB (added by , 14 years ago) |
---|
-
mythburn.py
804 804 write( "Obtaining MythTV settings from MySQL database for hostname " + configHostname) 805 805 806 806 #TVFormat is not dependant upon the hostname. 807 sqlstatement=""" select value, data from settings where value in('DBSchemaVer')808 or (hostname='""" + configHostname + """' and value in(807 sqlstatement="""SELECT value, data FROM settings WHERE value IN('DBSchemaVer') 808 OR (hostname=%s AND value IN( 809 809 'VideoStartupDir', 810 810 'GalleryDir', 811 811 'MusicLocation', … … 838 838 'ISO639Language0', 839 839 'ISO639Language1', 840 840 'JobQueueCPU' 841 )) order byvalue"""841 )) ORDER BY value""" 842 842 843 843 #write( sqlstatement) 844 844 … … 847 847 # create a cursor 848 848 cursor = db.cursor() 849 849 # execute SQL statement 850 cursor.execute(sqlstatement )850 cursor.execute(sqlstatement, configHostname) 851 851 # get the resultset as a tuple 852 852 result = cursor.fetchall() 853 853 … … 871 871 db = getDatabaseConnection() 872 872 cursor = db.cursor() 873 873 874 query = "DELETE from settings "875 query += "WHERE value = '" + name + "' AND hostname = '" + configHostname + "'"876 cursor.execute(query)874 cursor.execute("""DELETE FROM settings 875 WHERE value=%s 876 AND hostname=%s""", (name, configHostname)) 877 877 878 query = "INSERT INTO settings (value, data, hostname) " 879 query += "VALUES ('" + name + "', '" + data + "', '" + configHostname + "')" 880 cursor.execute(query) 878 cursor.execute("""INSERT INTO settings (value, data, hostname) 879 VALUES(%s, %s, %s)""", (name, data, configHostname)) 881 880 882 881 db.close() 883 882 del db … … 894 893 db = getDatabaseConnection() 895 894 cursor = db.cursor() 896 895 897 cursor.execute("DELETE from archiveitems;")896 cursor.execute("DELETE FROM archiveitems") 898 897 899 898 db.close() 900 899 del db … … 1404 1403 # if this a myth recording we still need to find the chanid, starttime and hascutlist 1405 1404 if file.attributes["type"].value=="recording": 1406 1405 basename = os.path.basename(file.attributes["filename"].value) 1407 sqlstatement = """SELECT starttime, chanid FROM recorded1408 WHERE basename = '%s'""" % basename.replace("'", "\\'")1409 1406 1410 1407 db = getDatabaseConnection() 1411 1408 cursor = db.cursor() 1412 cursor.execute(sqlstatement) 1409 cursor.execute("""SELECT starttime, chanid FROM recorded 1410 WHERE basename=%s""", basename) 1411 1413 1412 result = cursor.fetchall() 1414 1413 numrows = int(cursor.rowcount) 1415 1414 … … 1433 1432 chanid = record[1] 1434 1433 1435 1434 # find the cutlist if available 1436 sqlstatement = """SELECT mark, type FROM recordedmarkup1437 WHERE chanid = '%s' AND starttime = '%s'1438 AND type IN (0,1) ORDER BY mark""" % (chanid, starttime)1439 1435 cursor = db.cursor() 1440 # execute SQL statement 1441 cursor.execute(sqlstatement) 1436 cursor.execute("""SELECT mark, type FROM recordedmarkup 1437 WHERE chanid=%s 1438 AND starttime=%s 1439 AND type IN(0,1) 1440 ORDER BY mark""", (chanid, starttime)) 1441 1442 1442 if cursor.rowcount > 0: 1443 1443 node = infoDOM.createElement("hascutlist") 1444 1444 node.appendChild(infoDOM.createTextNode("yes")) … … 1450 1450 1451 1451 # find the cut list end marks if available to use as chapter marks 1452 1452 if file.attributes["usecutlist"].value == "0" and addCutlistChapters == True: 1453 sqlstatement = """SELECT mark, type FROM recordedmarkup1454 WHERE chanid = '%s' AND starttime = '%s'1455 AND type = 0 ORDER BY mark""" % (chanid, starttime)1456 1453 cursor = db.cursor() 1457 # execute SQL statement 1458 cursor.execute(sqlstatement) 1454 cursor.execute("""SELECT mark, type FROM recordedmarkup 1455 WHERE chanid=%s 1456 AND starttime=%s 1457 AND type=0 1458 ORDER BY mark""", (chanid, starttime)) 1459 1459 # get the resultset as a tuple 1460 1460 result = cursor.fetchall() 1461 1461 if cursor.rowcount > 0: … … 1475 1475 1476 1476 elif file.attributes["type"].value=="recording": 1477 1477 basename = os.path.basename(file.attributes["filename"].value) 1478 sqlstatement = """SELECT progstart, stars, cutlist, category, description, subtitle,1479 title, starttime, chanid1480 FROM recorded WHERE basename = '%s'""" % basename.replace("'", "\\'")1481 1482 1478 # connect 1483 1479 db = getDatabaseConnection() 1484 1480 # create a cursor 1485 1481 cursor = db.cursor() 1486 1482 # execute SQL statement 1487 cursor.execute(sqlstatement) 1483 cursor.execute("""SELECT progstart, stars, cutlist, category, 1484 description, subtitle, title, starttime, 1485 chanid 1486 FROM recorded 1487 WHERE basename=%s""", basename) 1488 1488 # get the resultset as a tuple 1489 1489 result = cursor.fetchall() 1490 1490 # get the number of rows in the resultset … … 1552 1552 chanid = record[8] 1553 1553 1554 1554 # find the cutlist if available 1555 sqlstatement = """SELECT mark, type FROM recordedmarkup1556 WHERE chanid = '%s' AND starttime = '%s'1557 AND type IN (0,1) ORDER BY mark""" % (chanid, starttime)1558 1555 cursor = db.cursor() 1559 1556 # execute SQL statement 1560 cursor.execute(sqlstatement) 1557 cursor.execute("""SELECT mark, type FROM recordedmarkup 1558 WHERE chanid=%s 1559 AND starttime=%s 1560 AND type IN(0,1) 1561 ORDER BY mark""", (chanid, starttime)) 1562 1561 1563 if cursor.rowcount > 0: 1562 1564 node = infoDOM.createElement("hascutlist") 1563 1565 node.appendChild(infoDOM.createTextNode("yes")) … … 1569 1571 1570 1572 if file.attributes["usecutlist"].value == "0" and addCutlistChapters == True: 1571 1573 # find the cut list end marks if available 1572 sqlstatement = """SELECT mark, type FROM recordedmarkup1573 WHERE chanid = '%s' AND starttime = '%s'1574 AND type = 0 ORDER BY mark""" % (chanid, starttime)1575 1574 cursor = db.cursor() 1576 1575 # execute SQL statement 1577 cursor.execute(sqlstatement) 1576 cursor.execute("""SELECT mark, type FROM recordedmarkup 1577 WHERE chanid=%s 1578 AND starttime=%s 1579 AND type=0 1580 ORDER BY mark""", (chanid, starttime)) 1578 1581 # get the resultset as a tuple 1579 1582 result = cursor.fetchall() 1580 1583 if cursor.rowcount > 0: … … 1593 1596 del cursor 1594 1597 1595 1598 elif file.attributes["type"].value=="video": 1596 filename = os.path.join(videopath, file.attributes["filename"].value.replace("'", "\\'"))1597 sqlstatement="""select title, director, plot, rating, inetref, year,1598 userrating, length, coverfile from videometadata1599 where filename='%s'""" % filename1600 1601 1599 # connect 1602 1600 db = getDatabaseConnection() 1603 1601 # create a cursor 1604 1602 cursor = db.cursor() 1605 1603 # execute SQL statement 1606 cursor.execute(sqlstatement) 1604 cursor.execute("""SELECT title, director, plot, rating, inetref, year, 1605 userrating, length, coverfile 1606 FROM videometadata 1607 WHERE filename LIKE %s""", '%'+file.attributes["filename"].value) 1607 1608 # get the resultset as a tuple 1608 1609 result = cursor.fetchall() 1609 1610 # get the number of rows in the resultset