-- NBS File Converter
-- by MysticT

-- load nbs api
if not nbs then
	os.loadAPI("nbs")
	if not nbs then
		print("Error loading nbs api. Check you installed it correctly.")
		return
	end
end

-- Start program

-- get arguments
local tArgs = { ... }
if #tArgs ~= 2 then
	print("Usage: nbsconvert <file path> <save path>")
	return
end

-- load the song from the nbs file
print("Converting...")
local tSong, err = nbs.load(tArgs[1], true)
if tSong then
	print("File loaded")
	print("Title: ", tSong.name)
	print("Author: ", tSong.author)
	print("Original Author: ", tSong.original_author)
	print("Lenght: ", tSong.lenght)
else
	print("Error: ", err)
	return
end

-- save the converted song to a file
local ok, err = nbs.saveSong(tSong, tArgs[2])
if ok then
	print("\nFile saved to", tArgs[2])
else
	print("Error: ", err)
end