當前位置: 首頁>>代碼示例>>Python>>正文


Python FlickrAPI.photos_setTags方法代碼示例

本文整理匯總了Python中flickrapi.FlickrAPI.photos_setTags方法的典型用法代碼示例。如果您正苦於以下問題:Python FlickrAPI.photos_setTags方法的具體用法?Python FlickrAPI.photos_setTags怎麽用?Python FlickrAPI.photos_setTags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flickrapi.FlickrAPI的用法示例。


在下文中一共展示了FlickrAPI.photos_setTags方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from flickrapi import FlickrAPI [as 別名]
# 或者: from flickrapi.FlickrAPI import photos_setTags [as 別名]

#.........這裏部分代碼省略.........
    posted = rsp.photo[0].dates[0]['posted']
    lastupdate = rsp.photo[0].dates[0]['lastupdate']
    return (format, mode, commMeta, desc, title, taglist, 
            license, owner, ownerNSID, url, int(posted), int(lastupdate))

  def setPerm(self, photoId, mode, comm_meta="33"):
    log.debug("id: %s, mode: %s, comm_meta=%s", photoId, mode, comm_meta)
    public = mode&1 #Set public 4(always), 1(public). Public overwrites f&f
    #Set friends and family 4(always), 2(family), 1(friends) 
    friends = mode>>3 & 1
    family = mode>>4 & 1
    if len(comm_meta)<2: 
      # This wd patch string index out of range bug, caused 
      # because some photos may not have comm_meta value set.
      comm_meta="33"
    rsp = self.fapi.photos_setPerms(auth_token=self.authtoken,
                                    is_public=str(public),
                                    is_friend=str(friends), 
                                    is_family=str(family), 
                                    perm_comment=comm_meta[0],
                                    perm_addmeta=comm_meta[1], 
                                    photo_id=photoId)
    if not rsp:
      log.error("couldn't set permission for photo %s; got error %s",
                photoId, rsp.errormsg)
      return False
    log.info("permissions have been set for photo %s", photoId)
    return True

  def setTags(self, photoId, tags):
    log.debug("id: %s, tags: %s", photoId, tags)
    templist = [ '"%s"'%(a,) for a in string.split(tags, ',')] + ['flickrfs']
    tagstring = ' '.join(templist)
    rsp = self.fapi.photos_setTags(auth_token=self.authtoken, 
                                   photo_id=photoId, tags=tagstring)
    if not rsp:
      log.error("couldn't set tags for %s; got error %s",
                photoId, rsp.errormsg)
      return False
    return True
  
  def setMeta(self, photoId, title, desc):
    log.debug("id: %s, title: %s, desc: %s", photoId, title, desc)
    rsp = self.fapi.photos_setMeta(auth_token=self.authtoken, 
                                   photo_id=photoId, title=title, 
                                   description=desc)
    if not rsp:
      log.error("couldn't set meta info for photo %s; got error",
                photoId, rsp.errormsg)
      return False
    return True

  def getLicenses(self):
    log.debug("started")
    rsp = self.fapi.photos_licenses_getInfo()
    if not rsp:
      log.error("couldn't retrieve licenses; got error %s", rsp.errormsg)
      return None
    licenseDict = {}
    for l in rsp.licenses[0].license:
      licenseDict[l['id']] = l['name']
    keys = licenseDict.keys()
    keys.sort()
    sortedLicenseList = []
    for k in keys:
      # Add tuple of license key, and license value.
開發者ID:Xirg,項目名稱:flickrfs-old,代碼行數:70,代碼來源:transactions.py


注:本文中的flickrapi.FlickrAPI.photos_setTags方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。