Created
January 8, 2011 18:17
-
-
Save anonymous/771039 to your computer and use it in GitHub Desktop.
Example fo python-fotki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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