Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
instagram-private-api-extensions
Advanced tools
An extension module for https://github.com/ping/instagram_private_api
An extension module to instagram_private_api to help with common tasks such as posting a photo or video.
media
: Edits a photo/video so that it complies with Instagram's requirements by:
pagination
: Page through an api call such as api.user_feed()
.
live
: Download an ongoing IG live stream. Requires ffmpeg installed.
replay
: Download an IG live replay stream. Requires ffmpeg installed.
Documentation is available at https://instagram-private-api-extensions.readthedocs.io/en/latest/
Install with pip using
pip install git+https://git@github.com/ping/instagram_private_api_extensions.git@0.3.8
To update:
pip install git+https://git@github.com/ping/instagram_private_api_extensions.git@0.3.8 --upgrade
To update with latest repo code:
pip install git+https://git@github.com/ping/instagram_private_api_extensions.git --upgrade --force-reinstall
from instagram_private_api import Client, MediaRatios
from instagram_private_api_extensions import media
api = Client('username', 'password')
# post a photo
photo_data, photo_size = media.prepare_image(
'pathto/my_photo.jpg', aspect_ratios=MediaRatios.standard)
api.post_photo(photo_data, photo_size, caption='Hello World!')
# post a video
vid_data, vid_size, vid_duration, vid_thumbnail = media.prepare_video(
'pathto/my_video.mp4', aspect_ratios=MediaRatios.standard)
api.post_video(vid_data, vid_size, vid_duration, vid_thumbnail)
# post a photo story
photo_data, photo_size = media.prepare_image(
'pathto/my_photo.jpg', aspect_ratios=MediaRatios.reel)
api.post_photo_story(photo_data, photo_size)
# post a video story
vid_data, vid_size, vid_duration, vid_thumbnail = media.prepare_video(
'pathto/my_video.mp4', aspect_ratios=MediaRatios.reel)
api.post_video_story(vid_data, vid_size, vid_duration, vid_thumbnail)
# post a video without reading the whole file into memory
vid_saved_path, vid_size, vid_duration, vid_thumbnail = media.prepare_video(
'pathto/my_video.mp4', aspect_ratios=MediaRatios.standard,
save_path='pathto/my_saved_video.mp4', save_only=True)
# To use save_only, the file must be saved locally
# by specifying the save_path
with open(vid_saved_path, 'rb') as video_fp:
api.post_video(video_fp, vid_size, vid_duration, vid_thumbnail)
from instagram_private_api_extensions import pagination
# page through a feed
items = []
for results in pagination.page(api.user_feed, args={'user_id': '123456'}):
if results.get('items'):
items.extend(results['items'])
print(len(items))
from instagram_private_api_extensions import live
broadcast = api.broadcast_info('1234567890')
dl = live.Downloader(
mpd=broadcast['dash_playback_url'],
output_dir='output_{}/'.format(broadcast['id']),
user_agent=api.user_agent)
try:
dl.run()
except KeyboardInterrupt:
if not dl.is_aborted:
dl.stop()
finally:
# combine the downloaded files
# Requires ffmpeg installed. If you prefer to use avconv
# for example, omit this step and do it manually
dl.stitch('my_video.mp4')
from instagram_private_api_extensions import replay
user_story_feed = api.user_story_feed('12345')
broadcasts = user_story_feed.get('post_live_item', {}).get('broadcasts', [])
for broadcast in broadcasts:
dl = replay.Downloader(
mpd=broadcast['dash_manifest'],
output_dir='output_{}/'.format(broadcast['id']),
user_agent=api.user_agent)
# download and save to file
dl.download('output_{}.mp4'.format(broadcast['id']))
Make sure to review the contributing documentation before submitting an issue report or pull request.
FAQs
An extension module for https://github.com/ping/instagram_private_api
We found that instagram-private-api-extensions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.