本文整理匯總了Python中ImageUtils.ImageUtils.get_filename_from_url方法的典型用法代碼示例。如果您正苦於以下問題:Python ImageUtils.get_filename_from_url方法的具體用法?Python ImageUtils.get_filename_from_url怎麽用?Python ImageUtils.get_filename_from_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImageUtils.ImageUtils
的用法示例。
在下文中一共展示了ImageUtils.get_filename_from_url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: enumerate
# 需要導入模塊: from ImageUtils import ImageUtils [as 別名]
# 或者: from ImageUtils.ImageUtils import get_filename_from_url [as 別名]
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