first I'm sorry for my english!!I have a problem with my code because I want it to automatically upload an image to my Instagram profile but it doesn't work because it repeats the same photo over and over but I don't want that to happen!!Can someone help me please?? (the code take the pictures from a folder and choose them randomly
import random
from instabot import Bot
import os, glob
from pathlib import Path
import shutil
cookie_del = glob.glob("config/*cookie.json")
os.remove(cookie_del[0])
bot = Bot()
sent_photos = []
def upload(path):
bot.login(username= '', password='')
bot.upload_photo(path, caption=' ')
sent_photos.append(path)
while True:
group_of_items = os.listdir("C:/Users/user/Desktop/teste/PICS")
num_selet = 1
list_of_random = random.sample(group_of_items, num_selet)
first_random = list_of_random[0]
path = "C:/Users/user/Desktop/teste/PICS/" + str(first_random)
if path in sent_photos:
continue
else:
upload(path)