#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password

import subprocess

from PyInstagramAPI import PyInstagramAPI

USERNAME = ''
PASSWORD = ''
FILE_PATH = '/path/to/video/file'
PUBLISH_TO_LIVE_FEED = False
SEND_NOTIFICATIONS = False

api = PyInstagramAPI(USERNAME, PASSWORD, debug=False)
assert api.login()

# first you have to create a broadcast - you will receive a broadcast id and an upload url here
assert api.createBroadcast()
broadcast_id = api.LastJson['broadcast_id']
upload_url = api.LastJson['upload_url']

# we now start a boradcast - it will now appear in the live-feed of users
assert api.startBroadcast(broadcast_id, sendNotification=SEND_NOTIFICATIONS)

ffmpeg_cmd = "ffmpeg -rtbufsize 256M -re -i '{file}' -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 720x1280 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv '{stream_url}'".format(
    file=FILE_PATH,
    stream_url=upload_url.replace(
        ':443',
        ':80',
Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password
# 
# example delete_media
# this example for how to delete self media feed
# have 2 parameter on method deleteMedia( MediaID, MediaType)

from PyInstagramAPI import PyInstagramAPI

# change this username & password
username = '******'
password = '******'

ig = PyInstagramAPI(username, password)

# login 
ig.login() 

# get Self user feed 
ig.getSelfUserFeed()

# get response json and assignment value to MediaList Variable
# dict type data 
MediaList = ig.LastJson 

# get first media for example delete media
Media = MediaList['items'][0]

# get media ID 
import os
import time
import random
from os import listdir
from os.path import isfile, join
from random import randint
from PyInstagramAPI import PyInstagramAPI

PhotoPath = "~/igphoto/"  # Change Directory to Folder with Pics that you want to upload
# 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 = PyInstagramAPI("login", "password")
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)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password

from PyInstagramAPI import PyInstagramAPI
import time
from datetime import datetime

user_id = ''

API = PyInstagramAPI("login", "password")
API.login()

API.getUsernameInfo(user_id)
API.LastJson
following = []
next_max_id = True
while next_max_id:
    print(next_max_id)
    # first iteration hack
    if next_max_id is True:
        next_max_id = ''
    _ = API.getUserFollowings(user_id, maxid=next_max_id)
    following.extend(API.LastJson.get('users', []))
    next_max_id = API.LastJson.get('next_max_id', '')

len(following)
unique_following = {f['pk']: f for f in following}
len(unique_following)
Ejemplo n.º 5
0
    """

    followers = []
    next_max_id = True
    while next_max_id:
        # first iteration hack
        if next_max_id is True:
            next_max_id = ''

        _ = api.getUserFollowers(user_id, maxid=next_max_id)
        followers.extend(api.LastJson.get('users', []))
        next_max_id = api.LastJson.get('next_max_id', '')
    return followers


if __name__ == "__main__":
    api = PyInstagramAPI("username", "password")
    api.login()

    # user_id = '1461295173'
    user_id = api.username_id

    # List of all followers
    followers = getTotalFollowers(api, user_id)
    print('Number of followers:', len(followers))

    # Alternatively, use the code below
    # (check evaluation.evaluate_user_followers for further details).
    followers = api.getTotalFollowers(user_id)
    print('Number of followers:', len(followers))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password

from PyInstagramAPI import PyInstagramAPI
import time
from datetime import datetime

media_id = '1477006830906870775_19343908'

# stop conditions, the script will end when first of them will be true
until_date = '2017-03-31'
count = 100

API = PyInstagramAPI("login", "password")
API.login()
API.getUsernameInfo()
has_more_comments = True
max_id = ''
comments = []

while has_more_comments:
    _ = API.getMediaComments(media_id, max_id=max_id)
    # comments' page come from older to newer, lets preserve desc order in full list
    for c in reversed(API.LastJson['comments']):
        comments.append(c)
    has_more_comments = API.LastJson.get('has_more_comments', False)
    # evaluate stop conditions
    if count and len(comments) >= count:
        comments = comments[:count]
Ejemplo n.º 7
0
"""
media = [  # Albums can contain between 2 and 10 photos/videos.
    {
        'type':
        'photo',
        'file':
        '/path/to/your/photo.jpg',  # Path to the photo file.
        'usertags': [
            {  # Optional, lets you tag one or more users in a PHOTO.
                'position': [0.5, 0.5],
                # WARNING: THE USER ID MUST BE VALID. INSTAGRAM WILL VERIFY IT
                # AND IF IT'S WRONG THEY WILL SAY "media configure error".
                'user_id': '123456789',  # Must be a numerical UserPK ID.
            },
        ]
    },
    {
        'type': 'photo',
        'file': '/path/to/your/photo.jpg',  # Path to the photo file.
    },
    # {
    #    'type'     : 'video',
    #    'file'     : '/path/to/your/video.mp4', # Path to the video file.
    #    'thumbnail': '/path/to/your/thumbnail.jpg'
    # }
]
captionText = 'caption 3'  # Caption to use for the album.
ig = PyInstagramAPI("login", "password")
ig.login()
ig.uploadAlbum(media, caption=captionText)
Ejemplo n.º 8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password

from PyInstagramAPI import PyInstagramAPI
import urllib

video_url = 'https://instagram.fmad3-2.fna.fbcdn.net/t50.2886-16/17157217_1660580944235536_866261046376005632_n.mp4'  # a valid instagram video
video_local_path = video_url.split("/")[-1]
thumbnail_url = "https://instagram.fmad3-2.fna.fbcdn.net/t51.2885-15/e15/17075853_1759410394387536_3927726791665385472_n.jpg"
thumbnail_local_path = thumbnail_url.split("/")[-1]

urllib.urlretrieve(video_url, video_local_path)
urllib.urlretrieve(thumbnail_url, thumbnail_local_path)

PyInstagramAPI = PyInstagramAPI("login", "password")
PyInstagramAPI.login()  # login
PyInstagramAPI.uploadVideo(video_local_path, thumbnail_local_path, caption="Tortuguero")
Ejemplo n.º 9
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password

from PyInstagramAPI import PyInstagramAPI

PyInstagramAPI = PyInstagramAPI("login", "password")
PyInstagramAPI.login()                        # login
mediaId = '1469246128528859784_1520706701'    # a media_id
recipients = []                             # array of user_ids. They can be strings or ints
PyInstagramAPI.direct_share(mediaId, recipients, text='aquest es es darrer')
Ejemplo n.º 10
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password

from PyInstagramAPI import PyInstagramAPI

PyInstagramAPI = PyInstagramAPI("login", "password")
PyInstagramAPI.login()  # login

photo_path = '/path/to/photo.jpg'
caption = "Sample photo"
PyInstagramAPI.uploadPhoto(photo_path, caption=caption)