#self.debug('%s: process_url: adding album to database' % child.author) album_id = self.db.add_album( working_dir, child.author, url, postid, commid, ) else: album_id = None ImageUtils.create_subdirectories(path.join(working_dir, 'thumbs')) for media_index, media in enumerate(medias): # Construct save path: /user/post[-comment]-index-filename fname = ImageUtils.get_filename_from_url(media) fname = '%s-%02d-%s' % (base_fname, media_index, fname) saveas = path.join(working_dir, fname) # Download URL try: self.debug('%s: process_url: downloading #%d %s' % (child.author, media_index + 1, media)) ImageUtils.httpy.download(media, saveas) if path.getsize(saveas) == 503: raise Exception('503b = removed') except Exception, e: self.debug( '%s: process_url: failed to download #%d: %s, moving on' % (child.author, media_index + 1, str(e))) continue
child.author, url, postid, commid, ) else: album_id = None if self.db.get_config('save_thumbnails', default='true') == 'true': ImageUtils.create_subdirectories(path.join(working_dir, 'thumbs')) else: ImageUtils.create_subdirectories(working_dir) for media_index, media in enumerate(medias): # Construct save path: /user/post[-comment]-index-filename fname = ImageUtils.get_filename_from_url(media, media_type) fname = '%s-%02d-%s' % (base_fname, media_index, fname) saveas = path.join(working_dir, fname) # Download URL try: self.debug('%s: process_url: downloading #%d %s' % (child.author, media_index + 1, media)) headers = { 'Referer' : url } ImageUtils.httpy.download(media, saveas, headers=headers) if path.getsize(saveas) == 503: raise Exception('503b = removed') except Exception, e: self.debug('%s: process_url: failed to download #%d: %s, moving on' % (child.author, media_index + 1, str(e))) continue