forked from tmhlsky/Instagram-API-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample-BulkUpload.py
More file actions
36 lines (31 loc) · 1.18 KB
/
Example-BulkUpload.py
File metadata and controls
36 lines (31 loc) · 1.18 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password
import os
import time
import random
from os import listdir
from os.path import isfile, join
from random import randint
from InstagramAPI import InstagramAPI
PhotoPath = "~/igphoto/" # Change Directory to Folder with Pics that you want to upload
IGUSER = "IGUsername" # Change to your Instagram USERNAME
PASSWD = "IGPassword" # Change to your Instagram Password
# Change to your Photo Hashtag
IGCaption = "Your Caption Here #hashtag"
os.chdir(PhotoPath)
ListFiles = [f for f in listdir(PhotoPath) if isfile(join(PhotoPath, f))]
print ("Total Photo in this folder:" + str (len(ListFiles)))
#Start Login and Uploading Photo
igapi = InstagramAPI(IGUSER,PASSWD)
igapi.login() # login
for i in range(len(ListFiles)):
photo = ListFiles[i]
print ("Progress :" + str([i+1]) + " of " + str(len(ListFiles)))
print ("Now Uploading this photo to instagram: " + photo)
igapi.uploadPhoto(photo,caption=IGCaption,upload_id=None)
# sleep for random between 600 - 1200s
n = randint(600,1200)
print ("Sleep upload for seconds: " + str(n))
time.sleep(n)