https://github.com/ping/instagram_private_api的扩展模块

instagram-private-api-extensions的Python项目详细描述


Instagram私有API扩展

instagram_private_api的扩展模块,用于帮助完成常见任务,如发布照片或视频。

ReleaseDocsBuildCoverage

功能

  1. ^{}:编辑照片/视频,使其符合Instagram的要求:

    • 调整大小
    • > >裁剪以适应最小/最大长宽比< / >
    • 生成视频缩略图图像
    • 如果视频持续时间过长,请将其剪短
    • 更改格式/编码
  2. ^{}:通过诸如api.user_feed()之类的api调用翻页。

  3. ^{}:下载正在进行的ig直播流。需要安装ffmpeg。

  4. ^{}:下载ig直播重播流。需要安装ffmpeg。

文档

文档可在https://instagram-private-api-extensions.readthedocs.io/en/latest/

安装

使用pip安装

pip install git+https://git@github.com/ping/instagram_private_api_extensions.git@0.3.8

要更新:

pip install git+https://git@github.com/ping/instagram_private_api_extensions.git@0.3.8 --upgrade

要使用最新的回购代码进行更新:

pip install git+https://git@github.com/ping/instagram_private_api_extensions.git --upgrade --force-reinstall

用法

Media

frominstagram_private_apiimportClient,MediaRatiosfrominstagram_private_api_extensionsimportmediaapi=Client('username','password')# post a photophoto_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 videovid_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 storyphoto_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 storyvid_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 memoryvid_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_pathwithopen(vid_saved_path,'rb')asvideo_fp:api.post_video(video_fp,vid_size,vid_duration,vid_thumbnail)

Pagination

frominstagram_private_api_extensionsimportpagination# page through a feeditems=[]forresultsinpagination.page(api.user_feed,args={'user_id':'123456'}):ifresults.get('items'):items.extend(results['items'])print(len(items))

Live

frominstagram_private_api_extensionsimportlivebroadcast=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()exceptKeyboardInterrupt:ifnotdl.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 manuallydl.stitch('my_video.mp4')

Replay

frominstagram_private_api_extensionsimportreplayuser_story_feed=api.user_story_feed('12345')broadcasts=user_story_feed.get('post_live_item',{}).get('broadcasts',[])forbroadcastinbroadcasts:dl=replay.Downloader(mpd=broadcast['dash_manifest'],output_dir='output_{}/'.format(broadcast['id']),user_agent=api.user_agent)# download and save to filedl.download('output_{}.mp4'.format(broadcast['id']))

支架

在提交问题报告或请求之前,请确保检查contributing documentation

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java通过两个整数数组对正整数和负整数进行排序   java无参数和默认构造函数混淆   java加载文件MD5的最快方法是什么?   java如何在变量声明中使用带“e”的float   java将项目导入到STS iMac   java在使用图像时旋转图像   java Break语句不起作用   java提供了错误类型Spring的id   java如何为多个变量设置相同的函数属性?   JavaMaven:如何添加编译阶段后生成的资源   java HashMap已损坏/性能问题   java Hibernate SQL中间表b/w父表和子表(不同类型)   java PDFbox找不到字体:/Helv   Java:向自实现的双链接列表添加排序函数   为使用Java BouncyCastle生成的X509Certificate提供密钥使用的安全性   java Hibernate在读写方面的性能   C#相当于Java的DataOutputStream?