InstaLiveCLI package

Submodules

InstaLiveCLI.InstaLiveCLI module

class InstaLiveCLI.InstaLiveCLI.InstaLiveCLI(username='', password='', settings='', auth='', saved=False)

Bases: object

API_URL = 'https://i.instagram.com/api/v1/'
DEVICE_SETS = {'android_release': '9.0', 'android_version': '28', 'app_version': '136.0.0.34.124', 'cpu': 'samsungexynos9810', 'device': 'SM-G965F', 'dpi': '640dpi', 'manufacturer': 'samsung', 'model': 'star2qltecs', 'resolution': '1440x2560', 'version_code': '208061712'}
IG_SIG_KEY = '4f8732eb9ba7d1c8e8897a75d6474d4eb3f5279137431b2aafb71fafe2abe178'
LastJson = None
LastResponse = None
SIG_KEY_VERSION = '4'
USER_AGENT = 'Instagram 136.0.0.34.124 Android (28/9.0; 640dpi; 1440x2560; samsung; star2qltecs; armani; samsungexynos9810; en_US)'
add_post_live_to_igtv(description, title)
broadcastMessage = ''
broadcast_id = None
cookie_jar = None
create_broadcast()

Creating broadcast live

broadcast_id, stream_server, stream_key will be saved on Class Variable.
Returns:if broadcast created
Return type:bool
delete_post_live()

Deleting video after broadcast is stopped

Returns:If video successfully deleted
Return type:bool
end_broadcast()

Stopping current broadcast from API

Returns:if broadcast is stopped
Return type:bool
export_settings(filename)

Exporting all the settings to json file

Parameters:filename (str) – filename, for example: “settings.json”
generate_UUID(t: bool = True, seed=None)

generating UUID

Parameters:
  • t (bool, optional) – if you want return raw uuid. Defaults to True.
  • seed (str, optional) – seed string. Defaults to None.
Returns:

UUID1 string

Return type:

str

generate_device_id(seed)

generate unique device id from seed

Parameters:seed (str) – seed string
Returns:unique formatted device id
Return type:str
generate_signature(data, skip_quote=False)
get_broadcast_status()

Returning current broadcast info status if exists

Returns:broadcast status
Return type:str
get_code_challenge_required(path, choice=0)

send code challenge choice choices: 0 - SMS, 1 - EMAIL :param path: api path :type path: str :param choice: choice challenge . Defaults to 0. :type choice: int, optional

get_comments()

Getting all comments on live broadcast

Returns:list of comments
Return type:dict
get_post_live_thumbnails()
get_viewer_list()

Get all of viewers from broadcast

Returns:Returns two list user, and ids
Return type:list
import_settings(filename)

Import and load settings from json file

Parameters:filename (str) – filename, for example: “settings.json”
Returns:settings configuration
Return type:dict
isLoggedIn = False
is_cli = False
is_running = False
last_comment_ts = 1
last_csrf_token = None
live_info()

Printing broadcast information to the console

Broadcast ID, Server URL, Stream Key, Viewer Count, Status Broadcast.

load_cookies(cookie_string)

Loads cookie from Cookiestring to Cookie jar and then import it to session’s cookiejar

Parameters:cookie_string (str) – cookies string
load_settings(cached_auth)

load all the settings from python dictionary

Parameters:cached_auth (dict) – settings configuration
login(force=False)

Login to api

becareful if you want to use force, it might rate limit, even worst banned you if you send too many times.
Parameters:force (bool, optional) – forcing to send login requests. Defaults to False.
Returns:if logged in
Return type:bool
mute_comments()

Mute current broadcast comments

Returns:if current comment muted
Return type:bool
password = None
previewHeight = 1920
previewWidth = 1080
rank_token = None
s = <requests.sessions.Session object>
save_settings = False
sendNotification = True
send_comment(msg)

Sending comment to broadcast

Parameters:msg (str) – message to send
Returns:if comment sent
Return type:bool
send_request(endpoint, post=None, login=False, headers: dict = {})

Sending requests to instagram API

Parameters:
  • endpoint (str) – API endpoint instagram
  • post (dict, optional) – data for post to api. Defaults to None.
  • login (bool, optional) – [description]. Defaults to False.
Raises:

Exception – Failing send requests

Returns:

if requests is success

Return type:

bool

set_code_challenge_required(path, code)

setting code challenge

Parameters:
  • path (str) – path api
  • code (str) – code challenge
set_proxy(proxy=None)

Set proxy to session

Parameters:proxy (string, optional) – user:password@ip:port. Defaults to None.
set_user(username, password)

Set user to class variable instance

Parameters:
  • username (str) – Username of your Instagram
  • password (str) – Password of your Instagram
settings

Helper property that extracts the settings that you should cache in addition to username and password.

Returns:all the settings and cookies
Return type:dict
share_to_story = False
start()

Starting CLI APP

start_broadcast()

Starting current broadcast

Returns:If broadcast is started
Return type:bool
stop()
stream_key = None
stream_server = None
token = None
two_factor(code='')

sending verification if there’s two factor neeeded

Returns:if two factor passed
Return type:bool
two_factor_identifier = None
two_factor_last_number = None
two_factor_required = False
unmute_comment()

Unmute current broadcast comments

Returns:if current comment unmuted
Return type:bool
upload_live_thumbnails()
username = None
username_id = None
uuid = None
wave(user_id)

Waving to specific user_id

Parameters:user_id (str) – id of user you want to wave
Returns:if user waved
Return type:bool

InstaLiveCLI.http module

class InstaLiveCLI.http.ClientCookieJar(cookie_string=None, policy=None)

Bases: http.cookiejar.CookieJar

Custom CookieJar that can be pickled to/from strings

auth_expires
dump(force_cookies=None)

pickle cookie_jar to strings

Parameters:force_cookies (cookie_jar, optional) – cookie_jar session. Defaults to None.
Returns:pickled cookie_jar strings
Return type:str
expires_earliest

For backward compatibility

InstaLiveCLI.util module

InstaLiveCLI.util.from_json(json_object)

Converting and encode bytes value from json object

Parameters:json_object (dict) – json dictionary
Returns:json_object
Return type:dict
InstaLiveCLI.util.to_json(python_object)

Converting bytes value on object to json

Parameters:python_object (dict) – A dict that contain bytes types on value
Raises:TypeError – If json is not serializable
Returns:Returns decoded bytes value
Return type:dict

Module contents