Infiltration
THEORY
Ethics
Observations
 
PRACTICE
Abandoned Sites
Boats
Churches
Drains/Catacombs
Hotels/Hospitals
Transit Tunnels
Utility Tunnels
Various
 
RESOURCES
Exploration Timeline
Infilnews
Infilspeak Dictionary
Usufruct Blog
Worldwide Links
Infiltration Forums home | search | login | register

Reply
Infiltration Forums > Private Boards Index > Tech Talk > Photo posting script(Viewed 1652 times)
makman location:
Rochester, NY
 
 |  | 
Photo posting script
< on 6/20/2010 4:11 PM >
Posted on Forum: UER ForumQuote
So, my usual workflow for posting photos here is:
1) Upload to Flickr as a set
2) Go through each photo and
2.1) Copy the image url
2.2) Paste into a thread as [eimg]http://flickr.com/whatever/123.jpg[/eimg]
3) Preview the page, and go resize each image using the [img=100,200][/img]syntax
4) Post

So, being the lazy bum I am, I threw together a little python script last night to do this for me. It's a really rough, prototypical thing, and has 0 error handling, but it works. You give it a username, a flickr set name, a maximum width, and tell it whether you want your [eimg]s wrapped in [url]s, and it gives you back a list like:

[url=http://farm5.static.flickr.com/4016/4715644312_d89d761d28_o.jpg][img=600,399]http://far m5.static.flickr.com/4016/4715644312_4c2f54aaf0_b.jpg[/eimg][/url]

[url=http://farm5.static.flickr .com/4050/4715645728_65dd74afd7_o.jpg][img=600,399]http://farm5.static.flickr.com/4050/4715645728_81f 98aeeaf_b.jpg[/img][/url]

[url=http://farm5.static.flickr.com/4070/4715667292_78133ac8be_o.jpg][im g=600,787]http://farm5.static.flickr.com/4070/4715667292_f3ec582760_b.jpg[/img][/url]

Anyway, all you need is Python and this guy's python flickr kit. I'm planning to eventually clean it up and give it a web interface at some point (right now the UI is just editing the variables in the script), but I figured people here might find it useful as it is if they're able to intall a python module and run a python program. Script:

import flickrapi

userName="macman5151"
setName="Summer Camp"
targetSize="Large"
maxWidth = 600;
makeLinks = False;

def formatToPrint(source,url,width,height):
newHeight=height
newWidth=width
if(maxWidth<width):
newHeight = int(height * ((1.0*maxWidth)/(width)))
newWidth = int(maxWidth)
img = "[img="+str(newWidth)+","+str(newHeight)+"]"+source+"[/img]"
result = "[url="+url+"]"+img+"[/url]"
return result if makeLinks else img

api_key = '7c0d60047e1d56575439268441bfcb26'
flickr = flickrapi.FlickrAPI(api_key)

userTree = flickr.people_findByUsername(username=userName)
userId = userTree.getchildren()[0].attrib['nsid']
setTree = flickr.photosets_getList(user_id=userId)
photosets = setTree.getchildren()[0].getchildren()

setId = -1;
for photoset in photosets:
title = photoset.find('title').text
if(setName==title):
setId = photoset.attrib['id']
break

photoset = flickr.photosets_getPhotos(photoset_id=setId).getchildren()[0]
height=-1
width=-1
url = ''
for photo in photoset.getchildren():
id = photo.attrib['id']
sizes = flickr.photos_getSizes(photo_id=id).getchildren()[0]
for size in sizes:
if(size.attrib['label']==targetSize):
width = int(size.attrib['width'])
height = int(size.attrib['height'])
source = size.attrib['source']
if(size.attrib['label']=='Original'):
url = size.attrib['source']
print formatToPrint(source,url,width,height)




Be careful, not safe.

"Urbex- so much fun that it should be illegal."
trent
I'm Trent! Get Bent!
 
location:
Drainwhale hunting
 
 |  |  | infinitedecay
Re: Photo posting script
<Reply # 1 on 6/21/2010 5:50 PM >
Posted on Forum: UER ForumQuote
Interesting. I might geek out with this later on this summer when I have time.



He who rules the underground, rules the city above.
Infiltration Forums > Private Boards Index > Tech Talk > Photo posting script(Viewed 1652 times)
Reply

Add a poll to this thread



This thread is in a public category, and can't be made private.

Powered by AvBoard AvBoard version 1.5 alpha
Page Generated In: 31 ms