Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- drivedown.lua
- local args = {...}
- if #args < 2 then
- print("Usage: drivedown <URL> <filename>")
- return
- end
- local url = args[1]
- local filename = args[2]
- -- Function to extract file ID from Google Drive URL
- local function getFileId(url)
- local id = url:match("drive.google.com/file/d/([%w_-]+)/")
- if not id then
- id = url:match("drive.google.com/file/d/([%w_-]+)/view")
- end
- return id
- end
- -- Function to download the file
- local function downloadFile(fileId, filename)
- local downloadUrl = "https://drive.google.com/uc?export=download&id=" .. fileId
- local response = http.get(downloadUrl)
- if response then
- local file = fs.open(filename, "wb")
- file.write(response.readAll())
- file.close()
- response.close()
- print("File downloaded successfully.")
- else
- print("Error downloading file.")
- end
- end
- local fileId = getFileId(url)
- if fileId then
- downloadFile(fileId, filename)
- else
- print("Invalid URL.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement