Ejemplo n.º 1
0
def movieExists(title, path):
    dbMovieID = None
    try:
        con, cursor = openDB(MODBPATH, 'Movies')

        title = stringUtils.invCommas(title)

        cursor.execute(
            "SELECT id, title FROM movies WHERE title LIKE '{}';".format(
                title))
        dbMovie = cursor.fetchone()

        if dbMovie is None:
            path = fileSys.completePath(
                path) if DATABASE_MYSQL == "false" else fileSys.completePath(
                    path).replace('\\', '\\\\')
            path = stringUtils.invCommas(path)
            cursor.execute(
                "INSERT INTO movies (title, filePath) VALUES ('{}', '{}');".
                format(title, path))
            con.commit()
            dbMovieID = cursor.lastrowid
        else:
            dbMovieID = dbMovie[0]
    finally:
        cursor.close()
        con.close()

    return dbMovieID
Ejemplo n.º 2
0
def showExists(title, path):
    dbShowID = None
    try:
        con, cursor = openDB(SHDBPATH, 'TVShows')

        title = stringUtils.invCommas(title)

        cursor.execute(
            "SELECT id, showTitle FROM shows WHERE showTitle LIKE '{}';".
            format(title))
        dbShow = cursor.fetchone()

        if dbShow is None:
            path = fileSys.completePath(
                path) if DATABASE_MYSQL == "false" else fileSys.completePath(
                    path).replace('\\', '\\\\')
            path = stringUtils.invCommas(path)
            cursor.execute(
                "INSERT INTO shows (showTitle, filePath) VALUES ('{}', '{}');".
                format(title, path))
            con.commit()
            dbShowID = cursor.lastrowid
        else:
            dbShowID = dbShow[0]
    finally:
        cursor.close()
        con.close()

    return dbShowID
Ejemplo n.º 3
0
def musicDatabase(strAlbumName,
                  strArtistName,
                  strSongTitle,
                  strPath,
                  strURL,
                  iTrack,
                  iDuration,
                  strArtPath,
                  tFileModTime=None):
    strPath = fileSys.completePath(os.path.join(STRM_LOC, strPath))

    # Write to music db and get id's
    iRoleID = writeRole("Artist")
    iPathID = writePath(strPath)
    iArtistID = writeArtist(strArtistName)
    iGenreID = writeGenre('osmosis')
    iAlbumID = writeAlbums(strAlbumName, strArtistName)
    iSongID = writeSong(iPathID, iAlbumID, strArtistName, strSongTitle,
                        iDuration, iTrack, tFileModTime)
    iSongArtistID = writeSongArtist(iArtistID, iSongID, 1, strArtistName, 0)
    writeSongGenre(iGenreID, iSongID)
    writeAlbumArtist(iArtistID, iAlbumID, strArtistName)
    writeThump(iArtistID, "artist", "thumb", strArtPath)
    writeThump(iAlbumID, "album", "thumb", strArtPath)

    if DATABASE_MYSQL == "false":
        if not xbmcvfs.exists(MusicDB_LOC):
            createMusicDB()
    elif not valDB('Music'):
        createMusicDB()

    writeIntoSongTable(strSongTitle, iSongID, strArtistName, strAlbumName,
                       iAlbumID, strPath, iPathID, strURL, iRoleID, iArtistID,
                       iSongArtistID, "F")