forked from Julian-O/Instagram-API-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulk_photo_upload.py
More file actions
40 lines (31 loc) · 1.17 KB
/
Copy pathbulk_photo_upload.py
File metadata and controls
40 lines (31 loc) · 1.17 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
37
38
39
40
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Instructions:
# - Create a directory that only contains photos to upload, and edit it into PHOTO_PATH.
# - Edit CAPTION to be your favourite caption.
#
# Warning makes change to test account.
from os import listdir
from os.path import isfile, join
import time
from random import randint
from InstagramAPI import InstagramAPI, credentials
# Change Directory to Folder with pictures that you want to upload
PHOTO_PATH = "~/igphoto/"
CAPTION = "Your Caption Here #hashtag"
def main():
file_list = [f for f in listdir(PHOTO_PATH) if isfile(join(PHOTO_PATH, f))]
# Start Login and Uploading Photo
api = InstagramAPI(credentials.USERNAME, credentials.PASSWORD)
api.login()
for i, photo in enumerate(file_list):
print("Progress : %s of %s" % (i + 1, len(file_list)))
print("Now uploading this photo to Instagram: %s" % photo)
api.upload_photo(photo, caption=CAPTION, upload_id=None)
# sleep for random between 600 - 1200s
sleep_time = randint(600, 1200)
print("Sleep upload for %s seconds." % sleep_time)
time.sleep(sleep_time)
if __name__ == '__main__':
main()