Esempio n. 1
0
    def update(self):
        if self._uris:
            return self._uris

        logger.info('load albums')
        raw_albums = self.pws.GetUserFeed().entry
        for raw_album in raw_albums:
            album = self.new_photoset()
            album.raw_album = raw_album
            album.pws = self.pws
            album.update()
            self.add_photoset(album)
        
        logger.info('%s albums loaded'%len(self._uris))
Esempio n. 2
0
 def import_photos(self):
     photos = self.get_photos()
     if not self.title:
         raise ValueError('photo set must have a title')
     cwd = os.getcwd()
     album_path = '%s/%s'%(cwd,self.title)
     if not os.path.exists(album_path):
         os.mkdir(album_path)
     elif not os.path.isdir(album_path):
         raise Exception("%s is not a folder"%album_path)
     for photo in photos:
         photo_path = '%s/%s'%(album_path, photo.title)
         if os.path.isfile(photo_path):
             continue
         logger.info('start download %s'%photo.title)
         urllib.urlretrieve(photo.uri,
                            photo_path)
         logger.info('%s downloaded'%photo.title)
Esempio n. 3
0
    def get_photos(self):
        if self._photos:
            return self._photos

        photos = []
        raw_photos = self.pws.GetFeed(self.raw_album.GetPhotosUri()).entry
        for raw_photo in raw_photos:
            photo = core.Photo()
            photo.id = raw_photo.gphoto_id.text
            photo.uri = raw_photo.content.src
            photo.title = raw_photo.title.text
            photo.description = raw_photo.summary.text or ''
#            tags = self.pws.GetFeed(raw_photo.GetTagsUri()).entry
#            photo.tags = [tag.summary.text for tag in tags]
            photos.append(photo)

        self.add_photos(photos)

        logger.info('%s photos found in %s'%(len(raw_photos), self.uri))

        return self._photos
Esempio n. 4
0
 def login(self, username, password):
     logger.info('login')
     self.pws.ClientLogin(username, password)
     logger.info('logged in')