Advertisement
stuppid_bot

Untitled

Oct 8th, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. #-*-coding:u8-*-
  2. from vklib import *
  3. from utils import *
  4. from account import *
  5.  
  6. vk=VKClient(delay_time=1)
  7. vk.login(username, password)
  8.  
  9. def save_album(album_url, target_album_id):
  10.     m = re.search('album([^_]+)_(\d+)', album_url)
  11.     # print m.groups()
  12.     oid = m.group(1)
  13.     aid = m.group(2)
  14.     sys_albums={'0': 'profile', '00': 'wall', '000': 'saved'}
  15.     if aid in sys_albums:
  16.         aid = sys_albums[aid]
  17.     o = 0
  18.     c = 1000
  19.     print album_url
  20.     while 1:
  21.         r = vk.api('photos.get', rev=1, owner_id=oid, album_id=aid, offset=o, count=c)
  22.         print '%s/%s' % (o, r['count'])
  23.         for it in r['items']:
  24.             try:
  25.                 photo_id = vk.api('photos.copy', owner_id=oid, photo_id=it['id'])
  26.                 vk.api('photos.move', target_album_id=target_album_id, photo_id=photo_id)
  27.             except Exception, e:
  28.                 print e
  29.         o += c
  30.         if o >= r['count']:
  31.             break
  32.  
  33. links = [
  34.     'https://vk.com/album-16237051_129232048'
  35. ]
  36. my_album = 203817625
  37. for link in links:
  38.     try:
  39.         save_album(link, my_album)
  40.     except Exception, e:
  41.         print e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement