• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ping/instagram_private_api_extensions: An extension module to https://github.com ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ping/instagram_private_api_extensions

开源软件地址:

https://github.com/ping/instagram_private_api_extensions

开源编程语言:

Python 100.0%

开源软件介绍:

Instagram Private API Extensions

An extension module to instagram_private_api to help with common tasks such as posting a photo or video.

Release Docs Build Coverage

Features

  1. media: Edits a photo/video so that it complies with Instagram's requirements by:

    • Resizing
    • Cropping to fit the minimum/maximum aspect ratio
    • Generating the video thumbnail image
    • Clipping the video duration if it is too long
    • Changing the format/encoding
  2. pagination: Page through an api call such as api.user_feed().

  3. live: Download an ongoing IG live stream. Requires ffmpeg installed.

  4. replay: Download an IG live replay stream. Requires ffmpeg installed.

Documentation

Documentation is available at https://instagram-private-api-extensions.readthedocs.io/en/latest/

Install

Install with pip using

pip install git+https://[email protected]/ping/[email protected]

To update:

pip install git+https://[email protected]/ping/[email protected] --upgrade

To update with latest repo code:

pip install git+https://[email protected]/ping/instagram_private_api_extensions.git --upgrade --force-reinstall

Usage

Media

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)

Pagination

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))

Live

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')

Replay

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']))

Support

Make sure to review the contributing documentation before submitting an issue report or pull request.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap