-- Function to run a shell command local function runShellCommand(command) local success, result = pcall(shell.run, command) if success then print(result) else print("Error executing command: " .. (result or "Unknown error")) end end -- Function to download and convert audio to .dfpwm local function downloadAndConvert(youtubeURL) -- Command to download audio and convert to .dfpwm format -- This assumes you have a script or tool capable of handling the download and conversion local downloadCommand = string.format( 'wget "%s" -O "audio.wav" && wav2dfpwm audio.wav audio.dfpwm', youtubeURL ) runShellCommand(downloadCommand) end -- Function to write .dfpwm file to tape local function writeToTape(filename) -- Ensure the file exists if not fs.exists(filename) then print("Error: File not found.") return end -- Run the tape write command local tapeCommand = string.format('tape write %s', filename) runShellCommand(tapeCommand) -- Optionally delete the file after writing if fs.exists(filename) then fs.delete(filename) print("File " .. filename .. " deleted from disk.") end end -- Main function local function main() -- Get YouTube URL from user print("Enter the YouTube URL:") local youtubeURL = read() -- Download and convert the audio downloadAndConvert(youtubeURL) -- Write the converted audio to tape writeToTape("audio.dfpwm") end -- Run the main function main()