You are not logged in.

#1 2008-03-24 04:20:30

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

ImageShack Uploader Script

I think this would be useful to you all as it painlessly uploads your images to imageshack and prints out a link to the image and a link that can be copy/pasted into forums for a clickable thumbnail. It's 100% written by me in Python. Requires cURL. It also shows a nice progress bar so you can see how far your upload has gone. Hope this helps!

Mirror 1: http://pastebin.com/f2d746452 Copy and paste into a file called imgupload.py

Mirror 2:

#!/usr/bin/python

import sys, os

#Define globals.
tmp = "temp.data" #Temporary file filename.
img = "" #Image filename.
ext = "" #File extension.

#Define functions.
def uploadsingle():
    print("Uploading: " + img)
    os.system("curl -H Expect: -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]

    #Get the thumbnail link.
    start = content.find("<thumb_link>")
    end = content.find("</thumb_link>")
    forum_link = content[start + 12 : end]

    print("Image link:\t\t" + link)
    print("Link for forums:\t[url= + link + ][img]" + forum_link + "[/img][/url]")

def uploadall(extension):
    print("Uploading: *." + extension)
    outfile = open("links.txt", "a")
    list = os.listdir("./")
    for fname in list:
        if fname.endswith(ext):
            print("Uploading: " + fname)
            os.system("curl -H Expect: -F fileupload=\"@" + fname + "\" -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]
            #Get the thumbnail link.
            start = content.find("<thumb_link>")
            end = content.find("</thumb_link>")
            forum_link = content[start + 12 : end]
            #Append link data to the outfile.
            outfile.write("File: " + fname + "\n")
            outfile.write("Image link:\t\t" + link + "\n")
            outfile.write("Link for forums:\t[url= + link + ][img]" + forum_link + "[/img][/url]\n\n")
            os.system("rm " + tmp) #Remove temporary file.

#Process command line arguments and execute program.
if sys.argv[1] == "all":
    ext = sys.argv[2]
    uploadall(ext)
else:
    img = sys.argv[1]
    uploadsingle()

os.system("rm " + tmp) #Remove temporary file.

Last edited by solarwind (2008-12-23 18:30:40)

Offline

#2 2008-03-26 08:18:43

mienensuchkind
Member
Registered: 2007-01-21
Posts: 61

Re: ImageShack Uploader Script

wouldnt call that "a nice progress bar", it totally screws up my terminal.... the percentage numbers would be enough... furthermore, it doesnt return the links to me:

curl: (55) select/poll returned error
Image link:       
Link for forums:

EDIT: this time it worked, thank you very much! (the first error was probably connected to my bad connection)

Last edited by mienensuchkind (2008-03-26 08:21:15)

Offline

#3 2008-03-26 10:37:32

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: ImageShack Uploader Script

Are you the same author of this?

If so, and even if not so, is it possible to have the option of using http://xs.to, for example, instead of imageshack? The reason why I don't like imageshack is that it's painfully slow. Xs seems quite faster.

Thanks for your work smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#4 2008-03-26 20:36:42

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: ImageShack Uploader Script

finferflu wrote:

Are you the same author of this?

If so, and even if not so, is it possible to have the option of using http://xs.to, for example, instead of imageshack? The reason why I don't like imageshack is that it's painfully slow. Xs seems quite faster.

Thanks for your work smile

I am not the author of the script in the AUR. I have never seen it in my life. I'll try to add xs.to support.

Offline

#5 2008-10-02 02:38:36

dmz
Member
Registered: 2008-08-27
Posts: 866
Website

Re: ImageShack Uploader Script

Very nice. I'll take a look.

Offline

#6 2008-10-02 03:45:36

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: ImageShack Uploader Script

dmz wrote:

Very nice. I'll take a look.

I made one for petaimg too. If you want, I can post it.

Offline

#7 2008-10-02 03:47:10

dmz
Member
Registered: 2008-08-27
Posts: 866
Website

Re: ImageShack Uploader Script

solarwind wrote:
dmz wrote:

Very nice. I'll take a look.

I made one for petaimg too. If you want, I can post it.

Sure, I am trying to modify it a bit for my needs. smile

Offline

#8 2008-10-02 04:33:13

wirenik
Member
Registered: 2008-08-22
Posts: 134

Re: ImageShack Uploader Script

Wow, sweet script! One thing...

$ mv imgupload.py imgup
# chmod +x imgup
# mv imgup /usr/bin

...will make it so you can just type

$ imgup pic.img

from anywhere and upload it, so you don't have to run the Python interpreter all the time.

Once again, thanks. This is really awesome!

Last edited by wirenik (2008-10-02 04:33:34)


moljac024: No one really knows what happens inside /dev/null... it could be a gateway to another universe....
dunc: If it is, the people who live there must be getting pretty annoyed by now with all the junk we send them.

Offline

#9 2008-11-23 12:03:44

andywxy
Member
From: Winnipeg, Canada
Registered: 2007-09-27
Posts: 36

Re: ImageShack Uploader Script

Nice script!

And I wanna know how can I colorize the out put info of this script? I do not know anything about python.... sad

Last edited by andywxy (2008-11-23 12:04:01)

Offline

#10 2008-11-23 18:46:29

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: ImageShack Uploader Script

Take a look at how I do it in https://launchpad.net/fidefrag

Offline

#11 2008-12-03 19:18:31

bioe007
Member
Registered: 2007-11-12
Posts: 56

Re: ImageShack Uploader Script

solarwind nice work

Offline

#12 2008-12-23 07:46:03

weasel8
Member
Registered: 2008-12-15
Posts: 149

Re: ImageShack Uploader Script

FYI, the script can't be found at the link Solarwind posted anymore. You can find it here: http://aur.archlinux.org/packages/image … ack-upload

EDIT: Er, just kidding, this one's different. sad

Last edited by weasel8 (2008-12-23 19:28:56)

Offline

#13 2008-12-23 18:16:39

elmer_42
Member
From: /na/usa/ca
Registered: 2008-10-11
Posts: 427

Re: ImageShack Uploader Script

I was inspired by this script to make an uploader to my favorite image website, kimag.es. It will display a progress bar as it uploads and then spit out the uploaded URL. To use, run `sh kup.sh pic.png`. Here it is, in all it's one-lined glory:

curl -# -F userfile=@$1 http://kimag.es/index.php?action=upload|grep http://arch.kimag.es/share|cut -c112-150

[ lamy + pilot ] [ arch64 | wmii ] [ ati + amd ]

Offline

#14 2008-12-23 18:32:15

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: ImageShack Uploader Script

weasel8 wrote:

FYI, the script can't be found at the link Solarwind posted anymore. You can find it here: http://aur.archlinux.org/packages/image … ack-upload

No you can't find it there, that one's your script, this one's mine xD

I updated link and posted code right on the post. Thanks for letting me know of dead link.

Offline

#15 2008-12-23 18:36:38

arch0r
Member
From: From the Chron-o-John
Registered: 2008-05-13
Posts: 597

Re: ImageShack Uploader Script

great script elmar, thx a lot for your effort. added it to my .bashrc :>

imgup () {
curl -# -F userfile=@$1 http://kimag.es/index.php?action=upload|grep http://arch.kimag.es/share|cut -c112-150
}

imgup screen.png

Last edited by arch0r (2008-12-23 18:37:29)

Offline

#16 2008-12-23 19:28:37

weasel8
Member
Registered: 2008-12-15
Posts: 149

Re: ImageShack Uploader Script

solarwind wrote:
weasel8 wrote:

FYI, the script can't be found at the link Solarwind posted anymore. You can find it here: http://aur.archlinux.org/packages/image … ack-upload

No you can't find it there, that one's your script, this one's mine xD

I updated link and posted code right on the post. Thanks for letting me know of dead link.

Yeah, I realized that after trying it myself...oops. Thanks for fixing the link though, I love this script. big_smile

Offline

#17 2009-01-16 00:14:23

linkmaster03
Member
Registered: 2008-12-27
Posts: 269

Re: ImageShack Uploader Script

For anyone wondering, his PetaIMG upload script is here: http://bazaar.launchpad.net/~x-solarwin … aUpload.py

PetaIMG looks like a really nice ImageShack replacement. Thanks solarwind.

Offline

#18 2009-01-16 00:34:01

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: ImageShack Uploader Script

linkmaster03 wrote:

For anyone wondering, his PetaIMG upload script is here: http://bazaar.launchpad.net/~x-solarwin … aUpload.py

PetaIMG looks like a really nice ImageShack replacement. Thanks solarwind.

It is definately more flexible but I have had problems with it in the past (sometimes the images won't upload or they will upload but not display). ImageShack has some limitations but it has NEVER failed me. It also creates a nice thumbnail automaticlly for you so you can easily copy/paste the link to paste in a forum post. But you could just as easily create a thumbnail with imagemagick.

Offline

#19 2009-01-16 00:47:14

tigim
Member
Registered: 2009-01-11
Posts: 14

Re: ImageShack Uploader Script

linkmaster03 wrote:

For anyone wondering, his PetaIMG upload script is here: http://bazaar.launchpad.net/~x-solarwin … aUpload.py

PetaIMG looks like a really nice ImageShack replacement. Thanks solarwind.

This is awesome! Thanks big_smile

Offline

#20 2009-01-16 00:54:45

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: ImageShack Uploader Script

tigim wrote:
linkmaster03 wrote:

For anyone wondering, his PetaIMG upload script is here: http://bazaar.launchpad.net/~x-solarwin … aUpload.py

PetaIMG looks like a really nice ImageShack replacement. Thanks solarwind.

This is awesome! Thanks big_smile

Just out of curiosity, does it still work?

Offline

#21 2009-01-16 01:42:00

linkmaster03
Member
Registered: 2008-12-27
Posts: 269

Re: ImageShack Uploader Script

Yes I just used it.

Offline

#22 2009-03-27 10:52:36

Mo
Member
Registered: 2007-01-18
Posts: 92

Re: ImageShack Uploader Script

You may also want to try

curl -s -F userfile=@$1 http://kimag.es/index.php?action=upload | grep http://arch.kimag.es/share | cut -c112-150 | xclip

You can access the adress with middle mouse button then. Great to use it as a custom action e.g. in thunar smile.

Edit: For those who like CTRL+V over middle mouse button:

curl -s -F userfile=@$1 http://kimag.es/index.php?action=upload | grep http://arch.kimag.es/share | cut -c112-150 | xclip -selection clipboard

You might also want to use xsel instead of xclip.

Last edited by Mo (2009-03-27 11:07:41)

Offline

#23 2009-03-29 13:01:01

linkmaster03
Member
Registered: 2008-12-27
Posts: 269

Re: ImageShack Uploader Script

Yeah using xclip with it makes it 20 times better.

Offline

#24 2009-04-23 21:26:41

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,676

Re: ImageShack Uploader Script

elmer_42 wrote:

I was inspired by this script to make an uploader to my favorite image website, kimag.es. It will display a progress bar as it uploads and then spit out the uploaded URL. To use, run `sh kup.sh pic.png`. Here it is, in all it's one-lined glory:

curl -# -F userfile=@$1 http://kimag.es/index.php?action=upload|grep http://arch.kimag.es/share|cut -c112-150

doesn't work anymore, donno why hmm, any one can help fix it ?


This silver ladybug at line 28...

Offline

#25 2009-04-23 21:37:19

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,676

Re: ImageShack Uploader Script

I guess....maybe something to do with this line in the page source ? ::

<input type="hidden" value="1" id="numval" />

This silver ladybug at line 28...

Offline

Board footer

Powered by FluxBB