-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainRmsDifference.py
executable file
·54 lines (43 loc) · 1.62 KB
/
mainRmsDifference.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import sys
import settings
import vkApiHelper
from Similar import findSimilarImages, getThumbnails
from VKDownloadImage import downloadImage
def main():
""" Main entry point for the script """
OWNER_ID = settings.VK['owner_id']
isResume = settings.VK['isResume']
albumBlackList = settings.VK['albumBlackList']
resumeAlbumID = settings.VK['resumeAlbumID']
vkApi = vkApiHelper.getVkApi()
albums = vkApi.photos.getAlbums(owner_id=OWNER_ID)
imgDir = './img/'
thumbDir = './thumb/'
thumbnailsSize = 32, 32
imgInfoFile = './imgInfo.json'
deleteImgDir = './deleteImg/'
deleteImgInfoFile = './deleteImgInfo.json'
for index, album in enumerate(albums['items']):
if isResume and album['id'] != resumeAlbumID:
continue
else:
isResume = False
if album['id'] in albumBlackList:
continue
vkApiHelper.clearTempData(imgDir, deleteImgDir, thumbDir,
imgInfoFile, deleteImgInfoFile)
print(album['id'])
# get photos list from album['id']
photos = vkApi.photos.get(owner_id=OWNER_ID,
album_id=album['id'],
photo_sizes='1')
error404List = downloadImage(photos['items'], imgDir,\
imgInfoFile, isBig=False)
vkApiHelper.deleteLostImages(vkApi, OWNER_ID, error404List)
getThumbnails(imgDir, thumbDir, thumbnailsSize)
findSimilarImages(thumbDir, OWNER_ID)
print('\nDELETE SIMILAR IMAGES!\n')
vkApiHelper.deleteVkImages(vkApi, OWNER_ID, deleteImgDir, deleteImgInfoFile)
if __name__ == '__main__':
sys.exit(main())