本文整理汇总了Python中smugpy.SmugMug.subcategories_create方法的典型用法代码示例。如果您正苦于以下问题:Python SmugMug.subcategories_create方法的具体用法?Python SmugMug.subcategories_create怎么用?Python SmugMug.subcategories_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smugpy.SmugMug
的用法示例。
在下文中一共展示了SmugMug.subcategories_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SmugLine
# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import subcategories_create [as 别名]
#.........这里部分代码省略.........
for group in groups:
album_name = group[0]["AlbumName"]
album = self.get_or_create_album(album_name)
self._upload(group, album_name, album)
def upload_folder(self, source_folder, album_name, file_filter=IMG_FILTER):
album = self.get_or_create_album(album_name)
images = self.get_images_from_folder(source_folder, file_filter)
self._upload(images, album_name, album)
def account_folder_number(self, source_folder):
images = self.get_images_from_folder(source_folder, file_filter)
return len(images)
def upload_folder_structure(self, album_title, source_folder, file_filter, uploaded_files, total_files):
album_name = source_folder.replace("./", "").split("/", 1)[1]
subcategory_name = source_folder.replace("./", "").split("/", 1)[0]
categories = self.smugmug.categories_get()
category = None
for candidate_category in categories["Categories"]:
if candidate_category["Name"] == album_title:
category = candidate_category
if category is None:
category = self.smugmug.categories_create(Name=album)["Category"]
subcategories = self.smugmug.subcategories_get(CategoryID=category["id"])
subcategory = None
for candidate_subcategory in subcategories["SubCategories"]:
if candidate_subcategory["Name"] == subcategory_name:
subcategory = candidate_subcategory
if subcategory is None:
subcategory = self.smugmug.subcategories_create(Name=subcategory_name, CategoryID=category["id"])[
"SubCategory"
]
album = self.create_album(album_name, "unlisted", subcategory["id"])
images = self.get_images_from_folder(source_folder, file_filter)
self._upload(images, album_name, album, uploaded_files, total_files)
def download_album(self, album_name, dest_folder, file_filter=IMG_FILTER):
album = self.get_album_by_name(album_name)
if album is None:
print ("Album {0} not found".format(album_name))
return
images = self._get_images_for_album(album, file_filter)
self._download(images, dest_folder)
def _upload(self, images, album_name, album, uploaded_files, total_files):
images = self._remove_duplicates(images, album)
for image in images:
print ("[{0:03d}/{1:03d}] Uploading {2}".format(uploaded_files, total_files, image))
self.upload_file(album, image)
uploaded_files = uploaded_files + 1
def _download(self, images, dest_folder):
for img in images:
print ("downloading {0} -> {1}".format(img["FileName"], dest_folder))
filename = self.download_file(img["OriginalURL"], dest_folder, img["FileName"])
self.set_file_timestamp(filename, img)
def _get_remote_images(self, album, extras=None):
remote_images = self.smugmug.images_get(AlbumID=album["id"], AlbumKey=album["Key"], Extras=extras)
return remote_images