Package screenlets :: Package plugins :: Module Flickr
[hide private]
[frames] | no frames]

Source Code for Module screenlets.plugins.Flickr

 1  # This application is released under the GNU General Public License  
 2  # v3 (or, at your option, any later version). You can find the full  
 3  # text of the license under http://www.gnu.org/licenses/gpl.txt.  
 4  # By using, editing and/or distributing this software you agree to  
 5  # the terms and conditions of this license.  
 6  # Thank you for using free softwa 
 7   
 8  # Flickr module by Helder Fraga aka whise <helder.fraga@hotmail.com> 
 9   
10   
11  from urllib import urlopen 
12  import Proxy 
13   
14 -class Flickr:
15 16 url_list = {} 17 18
19 - def __init__(self):
20 pass
21
22 - def get_image_list(self,url):
23 """Returns a Tuple containing images links and webpage links of a flickr url""" 24 list_a = [] 25 self.url_list = {} 26 proxies = Proxy.Proxy().get_proxy() 27 sourcetxt = urlopen(url,proxies=proxies).read() 28 while sourcetxt.find("Photo" + chr(34)) != -1: 29 image = sourcetxt[sourcetxt.find("Photo" + chr(34))+7:] 30 sourcetxt = image 31 sourceimage = image[image.find("a href=" + chr(34))+8:] 32 sourceimage = sourceimage[:sourceimage.find(chr(34)) ].strip() 33 realimage = image[image.find("mg src=" + chr(34))+8:] 34 realimage = realimage[:realimage.find(chr(34)) ].strip() 35 imageurl = 'http://www.flickr.com' + sourceimage 36 list_a.append(realimage) 37 self.url_list[realimage] = imageurl 38 return list_a
39 40
41 - def save_image(self,url,path):
42 """Saves the image from url in path""" 43 proxies = Proxy.Proxy().get_proxy() 44 sourcetxt = urlopen(url,proxies=proxies).read() 45 fileObj = open( path,"w") #// open for for write 46 fileObj.write(sourcetxt) 47 fileObj.close()
48