def process_image(self, image_data): """ Takes the dictionary representing an image and saves it to an instance of the gallery.Image model. """ author_name = image_data['account_url'] if author_name: new = Image() new.title = image_data['title'] new.size = image_data['size'] new.hash = image_data['hash'] new.ext = image_data['ext'] # TODO: make sure all these methods are implemented correctly new.author = self.get_or_create_author(author_name) new.timestamp = self.parse_datetime(image_data['timestamp']) new.build_urls() new.save() else: print "Image %(hash)s didn't have an author" % image_data
def process_image(self, image_data): """ Takes the dictionary representing an image and saves it to an instance of the gallery.Image model. """ author_name = image_data['account_url'] if author_name: new = Image() new.title = image_data['title'] new.size = image_data['size'] new.hash = image_data['hash'] new.ext = image_data['ext'] # TODO: make sure all these methods are implemented correctly new.author = self.get_or_create_author(author_name) new.timestamp = self.parse_datetime(image_data['timestamp']) new.build_urls(hash) new.save() /* TO SAVE THE FILES IN DOWNLOADS FOLDER */ filename_charset = string.ascii_letters + string.digits file_save_dir = MEDIA_ROOT urllib.urlretrieve ("http://i.imgur.com/"+(new.hash),os.path.join(file_save_dir, (new.hash) + '.jpg'))