def test_location_complete_pk(self): source = Location(name='Daily Surf Supply', external_id=533689780360041, external_id_source='facebook_places') result = self.api.location_complete(source) self.assertIsInstance(result, Location) self.assertEqual(result.pk, 533689780360041)
def test_upload_video_story(self): media_pk = self.api.media_pk_from_url( "https://www.instagram.com/p/Bk2tOgogq9V/") path = self.api.video_download(media_pk) self.assertIsInstance(path, Path) caption = 'Test video caption' adw0rd = self.api.user_info_by_username('adw0rd') self.assertIsInstance(adw0rd, User) mentions = [StoryMention(user=adw0rd)] links = [StoryLink(webUri='https://adw0rd.com/')] hashtags = [StoryHashtag(hashtag=self.api.hashtag_info('dhbastards'))] locations = [ StoryLocation(location=Location( pk=150300262230285, name='Blaues Wunder (Dresden)', )) ] try: buildout = StoryBuilder(path, caption, mentions, Path('./examples/background.png')).video(1) story = self.api.video_upload_to_story( buildout.path, caption, mentions=buildout.mentions, links=links, hashtags=hashtags, locations=locations, ) self.assertIsInstance(story, Story) self.assertTrue(story) finally: cleanup(path) self.assertTrue(self.api.story_delete(story.id))
def test_upload_photo_story(self): media_pk = self.api.media_pk_from_url( "https://www.instagram.com/p/B3mr1-OlWMG/") path = self.api.photo_download(media_pk) self.assertIsInstance(path, Path) caption = 'Test photo caption' adw0rd = self.api.user_info_by_username('adw0rd') self.assertIsInstance(adw0rd, User) mentions = [StoryMention(user=adw0rd)] links = [StoryLink(webUri='https://adw0rd.com/')] hashtags = [StoryHashtag(hashtag=self.api.hashtag_info('dhbastards'))] locations = [ StoryLocation(location=Location( pk=150300262230285, name='Blaues Wunder (Dresden)', )) ] try: story = self.api.photo_upload_to_story( path, caption, mentions=mentions, links=links, hashtags=hashtags, locations=locations, ) self.assertIsInstance(story, Story) self.assertTrue(story) finally: cleanup(path) self.assertTrue(self.api.story_delete(story.id))
def test_location_complete_external_id(self): source = Location(name='Blaues Wunder (Dresden)', lat=51.0536111111, lng=13.8108333333) result = self.api.location_complete(source) self.assertIsInstance(result, Location) self.assertEqual(result.external_id, 150300262230285) self.assertEqual(result.external_id_source, 'facebook_places')
def test_location_complete_lat_lng(self): source = Location( pk=150300262230285, name='Blaues Wunder (Dresden)', ) result = self.api.location_complete(source) self.assertIsInstance(result, Location) self.assertEqual(result.lat, 51.0536111111) self.assertEqual(result.lng, 13.8108333333)
# Creating a bot from instagrapi and login in into the instagram account bot = Client() bot.login(USERNAME, PASSWORD) """ Getting informations about 2 users with their Instagram user Id Instagram user Id can be get by running "print(bot.user_info_by_username(username))" User id is a integer: "123456789" """ usr1_id = bot.user_info(XXXXXXXXXXX) usr2_id = bot.user_info(XXXXXXXXXXX) # Create Usertag objet to pin on the post tag = [Usertag(user=usr1_id, x=0, y=1), Usertag(user=usr2_id, x=1, y=1)] # List of Path to images to post album_path = ["Image/Panorama.jpg", "Image/imageToPost.jpg"] # Caption of the post text = "Pays : " + str(country) + "\nLatitude : {}, Longitude : {}".format(lat, lon) + \ "\nImage from google map posted by my bot.\nBot made by @usr1 and @usr1\n#googlemap #googleearth #googlestreetview "\ "#google #bot #photo #paysage #picture #landscape #beautifull #programmation #code #programming #globe #earth #panorama #360 "\ "#litleplanet #tinyplanet #ia #random" # Creating of the location of the pictures loc = bot.location_complete(Location(name=country, lat=lat, lng=lon)) # Uploading the album to Instagram bot.album_upload(album_path, caption=text, location=loc, usertags=tag) print("Images published!")