def get_profile_photos(id_, start_dir, downloaded_users_file): dir_of_photos = os.path.join(start_dir, id_) if not os.path.exists(dir_of_photos): os.makedirs(dir_of_photos) images = Vk.get_profile_photos(id_) Internet.load_images(images, dir_of_photos, need_reload_file) with open(downloaded_users_file, 'a+') as downloaded_users: downloaded_users.seek(0) lines = downloaded_users.readlines() if not check_in_file(id_, lines): downloaded_users.write(id_ + '\n')
def get_profile_photos(id_, start_dir, downloaded_users_file, need_reload_file): dir_of_photos = os.path.join(start_dir, id_.__str__()) images = Vk.get_profile_photos(id_.__str__()) if 9 < len(images) < 1000: if not os.path.exists(dir_of_photos): os.makedirs(dir_of_photos) Internet.Internet.load_images(images.keys(), dir_of_photos, need_reload_file) with open(os.path.join(dir_of_photos, id_.__str__() + '.txt'), 'w+', encoding='utf-8') as info: for image, likes in images.items(): f = image.split('/')[-1] info.write(f + ',' + likes.__str__() + '\n') with open(downloaded_users_file, 'a+') as downloaded_users: downloaded_users.seek(0) lines = downloaded_users.readlines() if not Download_profiles.check_in_file(id_.__str__(), lines): downloaded_users.write(id_.__str__() + '\n') print('LOADED id = ' + id_.__str__())