This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lego Stax's profile picture

Pastebin Download Program Fix

Started by Lego Stax, 19 September 2014 - 01:25 AM
Lego Stax #1
Posted 19 September 2014 - 03:25 AM
For those having the Duplicate entry '2147483647' for key 'PRIMARY' error in a file that you downloaded using the shell pastebin program, this program fixes that. Of course, it only has a download feature, as that is all that is required. I simply thought that I would provide a quick fix for those who are scouring the forums for it.

You can download it here, or you can copy the following code into the edit program:


local tArgs = { ... }
if #tArgs < 2 then
print(fs.getName(shell.getRunningProgram()).." <code> <path>")
return
end
if not fs.exists(tArgs[2]) then
-- Download
local response = http.get("http://pastebin.com/download.php?i="..tArgs[1])
if response then
  print("Success.")
  local data = response.readAll()
  local f = fs.open(tArgs[2], "w")
  f.write(data)
  f.close()
  print(tArgs[1].." has been saved to "..tArgs[2])
else
  print("Failure to download.")
end
else
print("File exists.")
end


The problem is simply that the shell pastebin program uses the URL: "http://pastebin.com/raw.php" whereas this program uses "http://pastebin.com/download.php"

Enjoy! :)/>
Edited on 19 September 2014 - 01:25 AM
colcrunch #2
Posted 19 September 2014 - 04:46 AM
I just did this and it is just getting all of the HTML, not the post.
Lego Stax #3
Posted 19 September 2014 - 02:49 PM
I just did this and it is just getting all of the HTML, not the post.
That's weird, it works for me.
Screeny:
Spoiler
I used this code: 3BpRCeFk for the download. You're welcome to try it yourself. I know that it works 100% for me.
Perhaps I should have kept this program to myself if it doesn't work for other people. Do you get the Duplicate entry '2147483647' for key 'PRIMARY' error in your pastebin downloads too?
Edited on 20 September 2014 - 09:33 PM
Lignum #4
Posted 19 September 2014 - 03:52 PM
I just did this and it is just getting all of the HTML, not the post.
Pastebin will redirect you to its homepage if the id you've entered is invalid. This means that if you enter an invalid id, you'll get pastebin's source code instead of the paste. I haven't tried it but that's probably what's happening.

In short, make sure that the paste id you've entered is valid. If it is, it's a problem with the program.
Edited on 19 September 2014 - 01:52 PM
Lyqyd #5
Posted 19 September 2014 - 03:54 PM
Raw.php is working again anyway.
Lego Stax #6
Posted 19 September 2014 - 09:58 PM
Raw.php is working again anyway.

Ah, okay. Well, if you want to lock this topic, then go right ahead. You have my consent.