Ticket #8115: mythburn2.diff

File mythburn2.diff, 8.6 KB (added by Raymond Wagner, 14 years ago)
  • mythburn.py

     
    804804    write( "Obtaining MythTV settings from MySQL database for hostname " + configHostname)
    805805
    806806    #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(
    809809                        'VideoStartupDir',
    810810                        'GalleryDir',
    811811                        'MusicLocation',
     
    838838                        'ISO639Language0',
    839839                        'ISO639Language1',
    840840                        'JobQueueCPU'
    841                         )) order by value"""
     841                        )) ORDER BY value"""
    842842
    843843    #write( sqlstatement)
    844844
     
    847847    # create a cursor
    848848    cursor = db.cursor()
    849849    # execute SQL statement
    850     cursor.execute(sqlstatement)
     850    cursor.execute(sqlstatement, configHostname)
    851851    # get the resultset as a tuple
    852852    result = cursor.fetchall()
    853853
     
    871871    db = getDatabaseConnection()
    872872    cursor = db.cursor()
    873873
    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))
    877877
    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))
    881880
    882881    db.close()
    883882    del db
     
    894893    db = getDatabaseConnection()
    895894    cursor = db.cursor()
    896895
    897     cursor.execute("DELETE from archiveitems;")
     896    cursor.execute("DELETE FROM archiveitems")
    898897
    899898    db.close()
    900899    del db
     
    14041403        # if this a myth recording we still need to find the chanid, starttime and hascutlist
    14051404        if file.attributes["type"].value=="recording":
    14061405            basename = os.path.basename(file.attributes["filename"].value)
    1407             sqlstatement  = """SELECT starttime, chanid FROM recorded
    1408                                WHERE basename = '%s'""" % basename.replace("'", "\\'")
    14091406
    14101407            db = getDatabaseConnection()
    14111408            cursor = db.cursor()
    1412             cursor.execute(sqlstatement)
     1409            cursor.execute("""SELECT starttime, chanid FROM recorded
     1410                              WHERE basename=%s""", basename)
     1411
    14131412            result = cursor.fetchall()
    14141413            numrows = int(cursor.rowcount)
    14151414
     
    14331432                chanid = record[1]
    14341433
    14351434                # find the cutlist if available
    1436                 sqlstatement  = """SELECT mark, type FROM recordedmarkup
    1437                                 WHERE chanid = '%s' AND starttime = '%s'
    1438                                 AND type IN (0,1) ORDER BY mark""" % (chanid, starttime)
    14391435                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
    14421442                if cursor.rowcount > 0:
    14431443                    node = infoDOM.createElement("hascutlist")
    14441444                    node.appendChild(infoDOM.createTextNode("yes"))
     
    14501450
    14511451                # find the cut list end marks if available to use as chapter marks
    14521452                if file.attributes["usecutlist"].value == "0" and addCutlistChapters == True:
    1453                     sqlstatement  = """SELECT mark, type FROM recordedmarkup
    1454                                     WHERE chanid = '%s' AND starttime = '%s'
    1455                                     AND type = 0 ORDER BY mark""" % (chanid, starttime)
    14561453                    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))   
    14591459                    # get the resultset as a tuple
    14601460                    result = cursor.fetchall()
    14611461                    if cursor.rowcount > 0:
     
    14751475
    14761476    elif file.attributes["type"].value=="recording":
    14771477        basename = os.path.basename(file.attributes["filename"].value)
    1478         sqlstatement  = """SELECT progstart, stars, cutlist, category, description, subtitle,
    1479                            title, starttime, chanid
    1480                            FROM recorded WHERE basename = '%s'""" % basename.replace("'", "\\'")
    1481 
    14821478        # connect
    14831479        db = getDatabaseConnection()
    14841480        # create a cursor
    14851481        cursor = db.cursor()
    14861482        # 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)
    14881488        # get the resultset as a tuple
    14891489        result = cursor.fetchall()
    14901490        # get the number of rows in the resultset
     
    15521552            chanid = record[8]
    15531553
    15541554            # find the cutlist if available
    1555             sqlstatement  = """SELECT mark, type FROM recordedmarkup
    1556                                WHERE chanid = '%s' AND starttime = '%s'
    1557                                AND type IN (0,1) ORDER BY mark""" % (chanid, starttime)
    15581555            cursor = db.cursor()
    15591556            # 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
    15611563            if cursor.rowcount > 0:
    15621564                node = infoDOM.createElement("hascutlist")
    15631565                node.appendChild(infoDOM.createTextNode("yes"))
     
    15691571
    15701572            if file.attributes["usecutlist"].value == "0" and addCutlistChapters == True:
    15711573                # find the cut list end marks if available
    1572                 sqlstatement  = """SELECT mark, type FROM recordedmarkup
    1573                                     WHERE chanid = '%s' AND starttime = '%s'
    1574                                     AND type = 0 ORDER BY mark""" % (chanid, starttime)
    15751574                cursor = db.cursor()
    15761575                # 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))
    15781581                # get the resultset as a tuple
    15791582                result = cursor.fetchall()
    15801583                if cursor.rowcount > 0:
     
    15931596        del cursor
    15941597
    15951598    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 videometadata
    1599                         where filename='%s'""" % filename
    1600 
    16011599        # connect
    16021600        db = getDatabaseConnection()
    16031601        # create a cursor
    16041602        cursor = db.cursor()
    16051603        # 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)
    16071608        # get the resultset as a tuple
    16081609        result = cursor.fetchall()
    16091610        # get the number of rows in the resultset