当前位置: 首页>>代码示例>>Python>>正文


Python SmugMug.images_getURLs方法代码示例

本文整理汇总了Python中smugpy.SmugMug.images_getURLs方法的典型用法代码示例。如果您正苦于以下问题:Python SmugMug.images_getURLs方法的具体用法?Python SmugMug.images_getURLs怎么用?Python SmugMug.images_getURLs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在smugpy.SmugMug的用法示例。


在下文中一共展示了SmugMug.images_getURLs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from smugpy import SmugMug [as 别名]
# 或者: from smugpy.SmugMug import images_getURLs [as 别名]
class SmugMugClient:

    def __init__(self, api_key, gallery, link_type, nickname):
        self.smugmug = SmugMug(api_key=api_key, api_version="1.3.0", app_name="TwiMug")
        self.gallery = gallery
        self.link_type = link_type
        self.nickname = nickname

    def get_albums(self):
        albums = self.smugmug.albums_get(NickName=self.nickname)

        return albums

    def get_album_info(self, album_name):
        for album in self.get_albums()["Albums"]:
            if album["Title"] == album_name:
                return album

    def get_images_for_album(self, album_id, album_key):
        images = self.smugmug.images_get(AlbumID=album_id, AlbumKey=album_key)

        return images

    def get_image_urls(self, image_id, image_key):
        urls = self.smugmug.images_getURLs(ImageID=image_id, ImageKey=image_key)

        return urls

    def get_last_image_urls(self):
        last_image = self.get_last_image_info()
        urls = self.get_image_urls(last_image["id"], last_image["Key"])

        return urls

    def get_last_image_info(self):
        album = self.get_album_info(self.gallery)
        images = self.get_images_for_album(album["id"], album["Key"])
        last_image = images["Album"]["Images"][-1]

        return last_image

    def get_last_image_extended_info(self):
        last_image = self.get_last_image_info()
        extended_info = self.smugmug.images_getInfo(ImageID=last_image["id"], ImageKey=last_image["Key"])

        return extended_info["Image"]

    def get_last_image_url(self):
        urls = self.get_last_image_urls()

        return urls["Image"][self.link_type]

    def save_last_image_url(self):
        url = self.get_last_image_url()

        with open("last_image_url", "w") as file:
            file.write(url)

    def load_last_image_url(self):
        url = ""

        with open("last_image_url", "r") as file:
            url = file.readline()

        return url
开发者ID:dyon,项目名称:TwiMug,代码行数:67,代码来源:SmugMugClient.py


注:本文中的smugpy.SmugMug.images_getURLs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。