def downloadImageAndSave(self, imageUrl): #imageUrl = 'http://imgstore.cdn.sogou.com/app/a/11220002/349351_s_90_2.webp' print imageUrl temp = imageUrl.split("/") temp.reverse() fileName= temp[0] filePath = get_absoulte_dir(self.WALLPAPER_DIR+'/'+fileName) print 'filePath', filePath new_file_path = filePath + '.png' #png_file = file(new_file_path,'r') if os.path.isfile(new_file_path): print 'exist ,skip download \n' else: img_res = get_content_from_url(imageUrl) f = file(filePath,'wb').write(img_res) util.convert_webp_to_png(filePath, new_file_path) return new_file_path
def downloadLargeImg(self, imgId, width, height): img_url = self.DOWNLOAD_URL % (imgId, width, height) img_res = get_content_from_url(img_url) large_img_save_dir = util.get_absoulte_dir(self.LARGE_DIR+'/%s' % imgId) f = file(large_img_save_dir,'wb').write(img_res) return large_img_save_dir