I based this script off the script in the screenshot tutorial, and another ImageShack script I found online.
It takes a screenshot, uploads it to ImageShack and copies the resulting URL to the clipboard
It does however require a few packages installed to NAND: xclip, curl, python-datetime
Easily installed by enabling wifi and running
They take less than 500kb in total so it shouldn't be a problem.
Accounts are supported using the regkey you received in the email when you first registered on ImageShack.
Best used in conjunction with the hotkeys tutorial: http://www.gp32x.de/board/index.php?/topic/54248-guide-hotkeys-ftw/
Script:
Copy the blob of text, save it somewhere as imgup.py (with UNIX line endings!), and use it like this (in a terminal):
Or, if you want to copy it to the NAND for easier usage:
It can then be run with:
...and easily added as a hotkey as well using the same command
I cooked this up quickly mainly for my own usage (and was annoyed by not being able to do anything without installing additional packages) but I thought other people might be interested in it.
It has zero error checking, so if anyone wants to add that or make other improvements to the script feel free to post your changes here.
It takes a screenshot, uploads it to ImageShack and copies the resulting URL to the clipboard
It does however require a few packages installed to NAND: xclip, curl, python-datetime
Easily installed by enabling wifi and running
Code:
sudo opkg update
sudo opkg install xclip curl python-datetime
Accounts are supported using the regkey you received in the email when you first registered on ImageShack.
Best used in conjunction with the hotkeys tutorial: http://www.gp32x.de/board/index.php?/topic/54248-guide-hotkeys-ftw/
Script:
Code:
#!/usr/bin/python
import sys, os, datetime
#Define globals.
tmp = "temp.data" #Temporary file filename.
img = "" #Image filename.
ext = "" #File extension.
imageshackregcode = "" #Regcode from the registration email. Leave blank if you don't want to use an account.
screenshotdir = "/media/PANDORASD/screenshots/" #Dir to save the screenshot in
#Define functions.
def uploadsingle():
filename = datetime.datetime.now().strftime("%y%m%d-%H%M%S") + ".png"
img = screenshotdir + filename
os.system("fbgrab \"" + img + "\"")
os.system("notify-send \"Uploading " + img + "\" -t 3000")
if imageshackregcode == "":
os.system("curl -H Expect: -F fileupload=\"@" + img + "\" -F xml=yes -# \"http://www.imageshack.us/index.php\" > " + tmp)
else:
os.system("curl -H Expect: --cookie \"myimages=" + imageshackregcode + ";\" -F fileupload=\"@" + img + "\" -F xml=yes -# \"http://www.imageshack.us/index.php\" > " + tmp)
file = open(tmp, "r")
content = file.read()
#Get the image link.
start = content.find("<image_link>")
end = content.find("</image_link>")
link = content[start + 12 : end]
os.system("echo -n " + link + " | xclip -selection clipboard")
os.system("notify-send \"Image Link copied to clipboard\" -t 5000")
#Process command line arguments and execute program.
uploadsingle()
os.system("rm " + tmp) #Remove temporary file.
Copy the blob of text, save it somewhere as imgup.py (with UNIX line endings!), and use it like this (in a terminal):
Code:
python /path/to/imgup.py
Code:
sudo cp /path/to/imgup.py /usr/bin/imgup
sudo chmod ugo+x /usr/bin/imgup
Code:
imgup
I cooked this up quickly mainly for my own usage (and was annoyed by not being able to do anything without installing additional packages) but I thought other people might be interested in it.
It has zero error checking, so if anyone wants to add that or make other improvements to the script feel free to post your changes here.
Last edited by a moderator: