def post_photos(self): directory = ('/home/rod/Desktop/myprojects/Python-Projects/environments/Wallpapers') for filename in os.listdir(directory): image = directory +'/' + filename with client(username, password) as cli: text = input('Enter description and #hashtag for your upload: ') cli.upload(image, text)
def upload(): quantity = 0 username = e_login.get() password = e_password.get() progress = Progressbar(window, orient=HORIZONTAL, length=100, mode='determinate') progress["maximum"] = length_onlyfiles progress.place(y=190, x=197) with client(username, password) as cli: while quantity < length_onlyfiles: file_da_caricare = (filename + "/" + onlyfiles[quantity]) info_file1 = str(quantity + 1) info_quantity = str(length_onlyfiles) info_file2 = ("[" + info_file1 + "/" + info_quantity + "] " + file_da_caricare) print(info_file2) time.sleep(1) cli.upload(file_da_caricare) quantity += 1 global gaythanos bo2 = str(quantity + 1) gaythanos = ("Uploading... " + "[" + bo2 + "/" + info_quantity + "] ") progress['value'] = quantity
def upload_stories(image): username = '******' password = '******' image = image with client(username, password) as cli: cli.upload(image, story=True)
def insta_post(): try: talkback("you got it boss") username = '' #your username password = '' #your password talkback("do you wanna upload an image?") ch = input("Do you wanna upload an image?: ") if ch.lower() == 'yes': img_url = "" talkback("What's the name of the image file?") image_name = input("Enter image name: ") image = img_url + image_name else: image = '' talkback("Do you wish to add a text?") ch = input("Enter here: ") if ch.lower() == 'yes': text = input("Enter text here: ") talkback("You can add hashtags if you want") tags = input("Enter hashtags: ") text = text + '\r\n' + tags with client(username, password) as cli: cli.upload(image, text) talkback("it's posted!, anything else i can do for you?") except Exception: pass
def generate_post(post_meta, post_online=False) -> None: '''This uploads a selected image and caption to instagram''' username = config.INSTA_UNAME password = config.INSTA_PASS image_file = post_meta['Image'] print(image_file) image_caption = post_meta['Caption'] print(image_file) print('caption: ----- ') print(image_caption) print('--------------') print(username, password) if post_online == True: with client(username, password, write_cookie_file=False) as cli: try: cli.upload(image_file, image_caption) except: print('Issue: unable to upload at this time!') #append to previous posts used_image_file = open(config.PREV_POSTS, 'a') used_image_file.write(f"{image_file},{datetime.now()}\n") used_image_file.close() #remove the image file so that it can't be included in the next round of image collection os.remove(image_file)
def tool_login(self, account: str, password: str) -> InstapyCli: cookie_file = ('{}/COOKIE_FOR_{}'.format( self.current_path, account)).replace(".", "") + '.json' return client(account, password, cookie_file=cookie_file, write_cookie_file=True)
def postInstagram(image_prefix, post_details): """Function to post to Instagram.""" post_image_id = post_details["image_id"] + ".jpg" post_message = post_details["text"] post_lat = post_details["location_lat"] post_long = post_details["location_long"] image_file_path = r"/home/bot/projects/social_post_bot/images" # Get all files file_list = os.listdir(image_file_path) # Get the image to post for i in file_list: if i.startswith(image_prefix + post_image_id): # Go to the directory os.chdir(image_file_path) post_image = i break os.chdir(r"/home/bot/projects/social_post_bot") with client(ig_username, ig_password) as cli: ig = cli.api() print(ig.current_user()) post_response = cli.upload(post_image, post_message) media_content = post_response["media"] ig_code = media_content["code"] preview_link = (f"https://www.instagram.com/p/{ig_code}") return preview_link
def clicked(): des = txt.get() print(image_name," with ", des) with client(user_name, pwd) as cli: cli.upload(image_name, des) pass messagebox.showinfo('Message title', 'Upload done!')
def instapost(): with open('images/post.txt', 'r') as file: data = file.read().replace('\n', '') with client(username, password) as cli: cli.upload(image, data) shutil.move("images/post.jpg", "posted/post.jpg") shutil.move("images/post.txt", "posted/post.txt")
def addAccount(name, password, lan, other_data, loginInstance): #,coockie): global CurrentSocialNetwork isNotSameAcc = True coockie = None for acc in data_accounts[CurrentSocialNetwork]: if acc['nickname'] == name: with client(name, password, acc['coockie']) as cli: coockie = cli.get_cookie() loginInstance.save_session_to_file(PATH_SESSIONS_INSTALOADER + name + '.se') acc['password'] = password acc['language'] = lan acc['fullName'] = other_data['fullName'] acc['biography'] = other_data['biography'] acc['imgUrl'] = other_data['imgUrl'] acc['session'] = PATH_SESSIONS_INSTALOADER + name + '.se' acc['coockie'] = coockie #Saving image response = requests.get(other_data['imgUrl']) ima = Image.open(BytesIO(response.content)) ima = ima.resize((32, 32), Image.ANTIALIAS) ima.save(PATH_PROFILE_PICS + name + '.png') isNotSameAcc = False break if (isNotSameAcc): loginInstance.save_session_to_file(PATH_SESSIONS_INSTALOADER + name + '.se') data_accounts[CurrentSocialNetwork].append({ 'nickname': name, 'password': password, 'language': lan, 'fullName': other_data['fullName'], 'biography': other_data['biography'], 'imgUrl': other_data['imgUrl'], 'session': PATH_SESSIONS_INSTALOADER + name + '.se' #, #'coockie': coockie }) #Saving image locally response = requests.get(other_data['imgUrl']) ima = Image.open(BytesIO(response.content)) ima = ima.resize((32, 32), Image.ANTIALIAS) ima.save(PATH_PROFILE_PICS + name + '.png') updateAccountsData() updateTreeView()
def post_to_insta(INSTAGRAM_USERNAME, INSTAGRAM_PASSWORD, post_text, post_image): image = post_image text = post_text with client(INSTAGRAM_USERNAME, INSTAGRAM_PASSWORD) as cli: cli.upload(image, text)
def upload_files_to_insta(files=[]): if len(files) == None: return else: with client(fb_graph['INSTA_USERNAME'], fb_graph['INSTA_PASSWORD']) as cli: for file in files: cli.upload(file, '')
def post(): with client(username, password, cookie_file=cookie_file, write_cookie_file=True) as cli: # cookies = cli.get_cookie() print(image, text) cli.upload(image, text)
def Upload(): i = 0 for files in os.listdir(path): image = path + "/poza_" + str(i) + ".png " text1 = '"And so the adventure begins." by me :p :))' time.sleep(a) with client(username, password) as cli: cli.upload(image, text1) i += 1
def postBot(image, description): """A bot that receives images and its descriptions and upload at the Instagram account.""" username = '******' password = '******' with client(username, password) as cli: cli.upload(image, description)
def Upload(): i = 0 for files in os.listdir(path): image = path + "/poza_" + str(i) + ".jpg " text1 = s with client(username, password) as cli: cli.upload(image, text1) i += 1
def inst_stories(self): if len(self.media_filenames) < 1: return True else: with client(self.insta_user, self.insta_pass) as cli: for i in range(0, len(self.media_filenames)): cli.upload(self.media_filenames[i], story=True) time.sleep(5) return True
def uploadreddit(): with open('data/description', 'r') as descfile: descriptio = descfile.read() username = username1 password = password1 image = 'data/rand' cookie = 'COOKIE FROM IG.JSON FILE' text = descriptio with client(username, password, cookie) as cli: cli.upload(image, text)
def send_to_ig(quoteid): if quoteid is None: print("Quote didn't get generated!") else: print(f"Uploading {quoteid} to IG...") with client(config['ig_username'], config['ig_password']) as cli: try: cli.upload(quoteid, config['post_text']) print("Uploaded to IG!") except Exception as e: print(f"Failed to upload to IG: {e}") exit()
def post(self): # todo iterate through through the pics in Arvel folder image = ( '/home/tehuti/Documents/GPMIGinfo/GPMpics/Photos/AllPhotos/02-IG .jpg' ) with open('/home/tehuti/PycharmProjects/GPMIG/quotes.txt') as quotes: quotes_list = quotes.read().splitlines() num = random.randrange(1, 23) caption = dedent("{}" + "{}").format(quotes_list.pop(num), self.hashtags) with client(self.username, self.password) as cli: cli.upload(image, caption)
def post_to_insta(entry, image_url, departure_city): # some long running task here username = '******' password = '******' pattern = r'\-*(\d+)x(\d+)\.(.*)$' replacement = r'.\3' cookie_file = 'flyfordeals.json' # default: `USERNAME_ig.json` with client(username, password, cookie_file=cookie_file) as cli: no_ratio_image_url = re.sub(pattern, replacement, image_url) try: # cli.upload(no_ratio_image_url, entry["title"], story=True) cli.upload(no_ratio_image_url, entry["title"] + '. \n To purchase or see more deals visit the link in bio. \n #{0} #flycheap #cheapflights #travelmore #flymoreforless #vacation #flyfordeals'.format(departure_city.replace(" ", ""))) except IOError: pass
def upload(): dirfiles = os.listdir(directory) dirfiles.sort( key=lambda f: int(''.join(filter(str.isdigit, f)))) #sorting files with client(username, password) as ig: for i in range( 0, 2 ): #change the maximum value of range to the number of photos you need to upload daily pic = os.path.join(directory, dirfiles[i]) ig.upload(pic, text) #uploading os.remove(pic) #deleting the uploaded image from the folder print("Successfully Uploaded On %s" % datetime.date.today())
def publish_post(post): title = post.title intro = post.intro comment = post.insta_comment tags = post.insta_tags search_key = post.search_key if comment: caption = comment + "\n\n" else: caption = "Blog post:\n\n" caption = caption + title + "\n" + intro + "\n\n" caption = caption + "Click the link in my bio and scroll to this image or from the menu search for: " + search_key if tags: caption = caption + "\n\n" + tags image = post.banner_image image_path = image.title rendition_url = image.get_rendition('max-1080x1080').url s3_url = 'https://lkbw.s3.amazonaws.com/images/' cf_url = 'https://d1e9v6y517kw0o.cloudfront.net/' image_url = rendition_url.replace(s3_url, cf_url) opener = urllib.request.build_opener() opener.addheaders = [( 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36' )] urllib.request.install_opener(opener) urllib.request.urlretrieve(image_url, image_path) username = settings.INSTA_KEY.split('|')[0] password = settings.INSTA_KEY.split('|')[1] cookie_file = settings.INSTA_KEY.split('|')[2] cookie_path = cookie_file with client(username, password, cookie_file=cookie_path, write_cookie_file=True) as cli: cli.upload(image_path, caption) now = datetime.now(pytz.timezone("America/Chicago")) post.insta_instant = now post.save_revision().publish() os.remove(image_path) return None
def listener(messages): for m in messages: print(m.text) cliente = Algorithmia.client('simtcMfVcIi2EcFstBQAJlyiiKe1') algo = cliente.algo( 'shashankgutha/WebsiteLinksRecommenderForkeywords/1.0.1') algo.set_options(timeout=300) # optional print( algo.pipe(m.text).result[0]['abstract'] + ' know more in ' + algo.pipe(m.text).result[0]['url']) text = (algo.pipe(m.text).result[0]['abstract'] + ' know more in ' + algo.pipe(m.text).result[0]['url']) r = requests.get( "https://api.qwant.com/api/search/images", params={ 'count': 50, 'q': m.text, 't': 'images', 'safesearch': 1, 'locale': 'en_US', 'uiv': 4 }, headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36' }) response = r.json().get('data').get('result').get('items') urls = [r.get('media') for r in response] print(random.choice(urls)) input = {"image": random.choice(urls)} cliente = Algorithmia.client('simtcMfVcIi2EcFstBQAJlyiiKe1') algo = cliente.algo('util/SmartImageDownloader/0.2.18') algo.set_options(timeout=300) # optional save = algo.pipe(input).result save = save['savePath'] localAbsPath = cliente.file(str(save[0])).getFile().name username = '******' password = '******' image = localAbsPath text = text + "#jiujitsu #mma #legends #oss #gentleart" with client(username, password) as cli: cli.upload(image, text)
def two_minute_job(): # quote = main.getQuote() # image = main.toImage(quote[0], quote[1]) # print("started") username = "******" password = "******" # with open("USERNAME_ig.json", "r") as f: # cookie = json.loads(f.read()) # f.close() cookie = '{"uuid": "cbc0359c-7801-11ea-8513-a86bad6c7cdf", "device_id": "android-4eb22ad58b6111e9", "ad_id": "6636790d-369b-2ad4-22a1-f17d0f99cfc5", "session_id": "cbc0359d-7801-11ea-8513-a86bad6c7cdf", "cookie": {"__class__": "bytes", "__value__": "gAN9cQBYDgAAAC5pbnN0YWdyYW0uY29tcQF9cQJYAQAAAC9xA31xBChYCQAAAGNzcmZ0b2tlbnEF\nY2h0dHAuY29va2llamFyCkNvb2tpZQpxBimBcQd9cQgoWAcAAAB2ZXJzaW9ucQlLAFgEAAAAbmFt\nZXEKWAkAAABjc3JmdG9rZW5xC1gFAAAAdmFsdWVxDFggAAAAQVI4SnVzaFJqUEpaT2Q5N1NuMEx1\nUmxXaThMYWo2ZlNxDVgEAAAAcG9ydHEOTlgOAAAAcG9ydF9zcGVjaWZpZWRxD4lYBgAAAGRvbWFp\nbnEQWA4AAAAuaW5zdGFncmFtLmNvbXERWBAAAABkb21haW5fc3BlY2lmaWVkcRKIWBIAAABkb21h\naW5faW5pdGlhbF9kb3RxE4hYBAAAAHBhdGhxFGgDWA4AAABwYXRoX3NwZWNpZmllZHEViFgGAAAA\nc2VjdXJlcRaIWAcAAABleHBpcmVzcRdK4wFrYFgHAAAAZGlzY2FyZHEYiVgHAAAAY29tbWVudHEZ\nTlgLAAAAY29tbWVudF91cmxxGk5YBwAAAHJmYzIxMDlxG4lYBQAAAF9yZXN0cRx9cR11YlgDAAAA\ncnVycR5oBimBcR99cSAoaAlLAGgKWAMAAABydXJxIWgMWAMAAABQUk5xImgOTmgPiWgQWA4AAAAu\naW5zdGFncmFtLmNvbXEjaBKIaBOIaBRoA2gViGgWiGgXTmgYiGgZTmgaTmgbiWgcfXEkWAgAAABI\ndHRwT25seXElTnN1YlgDAAAAbWlkcSZo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BBYDgAAAC5pbnN0YWdyYW0uY29tcUtoEohoE4hoFGgDaBWIaBaIaBdOaBiIaBlOaBpO\naBuJaBx9cUxYCAAAAEh0dHBPbmx5cU1Oc3ViWAkAAABzZXNzaW9uaWRxTmgGKYFxT31xUChoCUsA\naApoTmgMWCEAAAAxNDM1MTgzNjI5NiUzQXZod2NpY2ZhVkJhZ3c4JTNBMTZxUWgOTmgPiWgQWA4A\nAAAuaW5zdGFncmFtLmNvbXFSaBKIaBOIaBRoA2gViGgWiGgXSmNTbGBoGIloGU5oGk5oG4loHH1x\nU1gIAAAASHR0cE9ubHlxVE5zdWJ1c3Mu\n"}, "created_ts": 1586175971}' hashtags = '#love #instagram #like4like #followme #picoftheday #follow #instadaily #instagood #motivation #instacool #inspirational #dailyquotes #successquotes #quotes #quoteoftheday #instaquotes' caption = 'Hourly quotes. \nfollow for more \n\[email protected] \n\n' + hashtags with client(username, password, cookie=cookie) as cli: cli.upload("up.png", caption)
def post(): #in .bash_profile, write, "export username="******", and, "export password="******"" username = os.environ['INSTA_USERNAME'] password = os.environ['INSTA_PASSWORD'] mypath = "/Users/Carlos/Projects/Life-Hacks/Insta_scheduler/future_posts/*.JPG" #insert path to folder with photos you want to post #make sure all images in fill have same ending like JPG, jpeg, png, etc image_paths = glob.glob(mypath) #will iterate and store all image paths in folder print(image_paths) insta_post_descriptions = ["TBT to spring break with the day one fam"] #associate a description with your photo, check order with print statement in 15 future_posts = zip(image_paths, insta_post_descriptions) #creates a dictionary with photo and description # print(future_posts) with client(username, password) as cli: for photo, description in future_posts: cli.upload(photo, description) break #break allows the posting of one photo at a time instead of all in folder print("success")
def post_instagram(): username = "******" password = "******" cookie_file = username + "_ig.json" uploadImage = compile_new_image() caption = postEntry.get(1.0, END) hash_tags = "\n \n #retrogaming #gameboy #computerscience" text = caption + hash_tags file_name = "Images/upload.png" uploadImage.save(file_name, "PNG", icc_profile=profile) try: with client(username, password, cookie_file=cookie_file, write_cookie_file=True) as cli: print("Sending") cli.upload(file_name, text) messagebox.showinfo("Upload", "Your post is has been uploaded.", parent=window) except: messagebox.showinfo("Upload", "Your post failed to upload.", parent=window)
def instatest(request): from instapy_cli import client import ssl ssl._create_default_https_context = ssl._create_unverified_context username = '******' #your username password = '******' #your password image = 'minettaImage_h3pc9Np.jpeg' #here you can put the image directory text = '' #Here you can put your caption for the post' + '\r\n' + 'you can also put your hashtags #pythondeveloper #webdeveloper' with client(username, password) as cli: cli.upload(image, text) context = {} ####COMMENTS TO CHECK GIT CHANGES MADE 4:43PM##### #### AND NOW THESE ARE NEW COMMENTS MADE 4:58PM##### return render(request, 'instatest.html', context=context)
def clone1(): os.chdir('ins/') files = os.listdir() dirs = [f for f in files if os.path.isdir(f)] rando = random.sample(dirs, 1) rando = str(rando)[2:-2] instalo = 'instaloader ' + str(rando) + ' --no-metadata-json -F' os.system(instalo) os.chdir(str(rando)) randpattern = '*.jpg' OUTPUTS = random.choice(glob.glob(randpattern)) OUTPUT = str(OUTPUTS)[:23] with open(str(OUTPUT) + '.txt', 'r') as descfile: descriptio = descfile.read() username = username1 password = password1 image = OUTPUTS text = descriptio with client(username, password) as cli: cli.upload(image, text)
def publish_image(post): caption = post.insta_comment image = post.insta_image image_path = image.title rendition_url = image.get_rendition('max-1080x1080').url s3_url = 'https://lkbw.s3.amazonaws.com/images/' cf_url = 'https://d1e9v6y517kw0o.cloudfront.net/' image_url = rendition_url.replace(s3_url, cf_url) opener = urllib.request.build_opener() opener.addheaders = [( 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36' )] urllib.request.install_opener(opener) urllib.request.urlretrieve(image_url, image_path) username = settings.INSTA_KEY.split('|')[0] password = settings.INSTA_KEY.split('|')[1] cookie_file = settings.INSTA_KEY.split('|')[2] cookie_path = cookie_file with client(username, password, cookie_file=cookie_path, write_cookie_file=True) as cli: cli.upload(image_path, caption) now = datetime.now(pytz.timezone("America/Chicago")) post.insta_instant = now post.save_revision().publish() os.remove(image_path) return None