Advertisement
stuppid_bot

Untitled

Dec 11th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import vktools.utils as utils
  3. import Tkinter, tkFileDialog
  4. import os
  5. import re
  6. import sys
  7.  
  8. client_cfg = utils.load_cfg('client.json')
  9. client = utils.get_client(client_cfg)
  10. client.auth('login', 'password')
  11. root = Tkinter.Tk()
  12. # скрываем окно программы
  13. root.withdraw()
  14. # показываем только диалоговое окно
  15. images_directory = tkFileDialog.askdirectory(parent = root, initialdir = './', title = u'Выберите папку с изображениями')
  16. files = os.listdir(images_directory)
  17. # print files
  18. # фильтруем файлы по расширению
  19. images = [images_directory + '/' + f for f in files if re.match(r'.*\.(jpe?g|png|bmp|gif)$', f, re.I)]
  20. # создаем альбом
  21. print u'Имя альбома: '
  22. album_name = raw_input().decode(sys.stdin.encoding)
  23. album = client.api('photos.createAlbum', {'title': album_name})
  24. client.upload_photos(images, album['id'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement