Exemplo n.º 1
0
def insert_movie(path,
                 name,
                 category=None,
                 genre=None,
                 year=None,
                 cover_path=None,
                 director=None):
    db = DatabaseConnector()
    db.execute(_CREATE_MOVIES)
    added_on = db.generate_timestamp()
    if name is None:
        name = os.path.splitext(os.path.split(path)[-1])[0]
    query = "INSERT OR IGNORE INTO movies (path, category, name, cover_path, \
                director, genre, year, added_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"

    db.execute(query, (
        path,
        category,
        name,
        cover_path,
        director,
        genre,
        year,
        added_on,
    ))
    db.commit()
    db.close_connection()
Exemplo n.º 2
0
def insert_audiobook(path, category=None, name=None, author=None, year=None):
    db = DatabaseConnector()
    db.execute(_CREATE_AUDIOBOOKS)
    added_on = db.generate_timestamp()
    if name is None:
        name = os.path.splitext(os.path.split(path)[-1])[0]
    query = "INSERT OR IGNORE INTO audiobooks (path, category, name, author, \
                            year, added_on) VALUES (?, ?, ?, ?, ?, ?)"
    db.execute(query, (path, category, name, author, year, added_on,))
    db.commit()
    db.close_connection()
Exemplo n.º 3
0
def insert_movie(path, name, category=None, genre=None, year=None, cover_path=None, director=None):
    db = DatabaseConnector()
    db.execute(_CREATE_MOVIES)
    added_on = db.generate_timestamp()
    if name is None:
        name = os.path.splitext(os.path.split(path)[-1])[0]
    query = "INSERT OR IGNORE INTO movies (path, category, name, cover_path, \
                director, genre, year, added_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
    db.execute(query, (path, category, name, cover_path, director, genre, year, added_on,))
    db.commit()
    db.close_connection()
Exemplo n.º 4
0
def insert_many_tracks(tracks_list):
    db = DatabaseConnector()
    db.execute(_CREATE_MUSIC)
    added_on = db.generate_timestamp()
    for idx, track in enumerate(tracks_list):
        values = _get_metadata(track[0])  # path as the first item
        if not values:
            continue
        tracks_list[idx] = values + [track[0], track[1], added_on]
    query = "INSERT OR IGNORE INTO music (year, genre, artist, album, track_number, \
                    title, path, directory, added_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
    db.executemany(query, tracks_list)
    db.commit()
    db.close_connection()
Exemplo n.º 5
0
def insert_track(path, directory):
    values = _get_metadata(path)
    if not values:
        return False
    db = DatabaseConnector()
    db.execute(_CREATE_MUSIC)
    values.append(path)
    values.append(directory)
    values.append(db.generate_timestamp())
    query = "INSERT OR IGNORE INTO music (year, genre, artist, album, track_number, \
                    title, path, directory, added_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
    db.execute(query, values)
    db.commit()
    db.close_connection()
Exemplo n.º 6
0
def insert_many_tracks(tracks_list):
    db = DatabaseConnector()
    db.execute(_CREATE_MUSIC)
    added_on = db.generate_timestamp()
    for idx, track in enumerate(tracks_list):
        values = _get_metadata(track[0])  # path as the first item
        if not values:
            continue
        tracks_list[idx] = values + [track[0], track[1], added_on]
    query = "INSERT OR IGNORE INTO music (year, genre, artist, album, track_number, \
                    title, path, directory, added_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"

    db.executemany(query, tracks_list)
    db.commit()
    db.close_connection()
Exemplo n.º 7
0
def insert_track(path, directory):
    values = _get_metadata(path)
    if not values:
        return False
    db = DatabaseConnector()
    db.execute(_CREATE_MUSIC)
    values.append(path)
    values.append(directory)
    values.append(db.generate_timestamp())
    query = "INSERT OR IGNORE INTO music (year, genre, artist, album, track_number, \
                    title, path, directory, added_on) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"

    db.execute(query, values)
    db.commit()
    db.close_connection()
Exemplo n.º 8
0
def insert_audiobook(path, category=None, name=None, author=None, year=None):
    db = DatabaseConnector()
    db.execute(_CREATE_AUDIOBOOKS)
    added_on = db.generate_timestamp()
    if name is None:
        name = os.path.splitext(os.path.split(path)[-1])[0]
    query = "INSERT OR IGNORE INTO audiobooks (path, category, name, author, \
                            year, added_on) VALUES (?, ?, ?, ?, ?, ?)"

    db.execute(query, (
        path,
        category,
        name,
        author,
        year,
        added_on,
    ))
    db.commit()
    db.close_connection()