Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2011 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/771039 to your computer and use it in GitHub Desktop.
Save anonymous/771039 to your computer and use it in GitHub Desktop.
Example fo python-fotki
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import fotki
import getpass
# Без авторизации
u = fotki.User(username)
print u.get_title()
# С авторизацией
username = raw_input('User:')
password = getpass.getpass('Password:')
auth = fotki.Auth()
auth.set_token_by_password(username, password)
user = fotki.User(username, auth)
print user.get_title()
album = user.get_photo_collection()
print len(album)
print album.get_url()
photo = album.get_photo(0)
print photo.get_image_info()
print u'%s×%s' % photo.get_size()
photo.set_title('Фотка как фотка…')
photo.update_info()
photolist = album.get_photo_list()
## Загружает все фотографии пользователя
#for photo in photolist:
# f = open(photo.get_title() + '.jpeg', 'wb')
# f.write(photo.read())
# f.close()
f = open('test.jpeg')
new = album.create_photo(f.read())
new.set_title('Новая фотка!')
new.update_info()
print new.get_title()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment