Python的Byte API包装器
项目描述
byte.co应用的Python包装器。
需要Python 3.6+。
注意:该项目在一周内(主要是发布的那周)构建,因此这不是**生产级**软件。
Byte没有为开发者提供官方的Web API,这很可能会违反服务条款。已从移动应用中找到端点。因此,此包装器可能随时会中断。不要依赖此包装器。
安装
- PyPi(推荐)
pip install pybyte
- Git仓库
git clone https://github.com/ms7m/py-byte cd py-byte python3 setup.py install
用法
>>> import pybyte
>>>
>>> byte = pybyte.Byte("7WMRREHUQRH4DBK7DQCV7YWL44")
>>>
>>> byte.me().username
'BotBottyFace220'
>>>
>>> my_timeline = byte.me().timeline()
>>>
>>> # no rate limit protection yet. do it at your own risk!
...
>>> import time
>>>
>>> for post in my_timeline.feed:
... print(f"Caption: {post.caption}")
... time.sleep(1)
... print(f"Author: {post.author.username}")
... print('\n')
...
Caption:
Author: BotMcBotFace2300
Caption: Nice
Author: BotMcBotFace2300
Caption:
Author: BotMcBotFace2300
Caption:
Author: BotMcBotFace2300
Caption: @peaks
Author: BotMcBotFace2300
# ...
>>>
>>>
>>> # Set your own username
...
>>> byte.me().username = "BotMcBotFace2300"
>>> byte.me().username
'BotMcBotFace2300'
>>>
>>> # Get Posts
...
>>> post = byte.get_post("4ZPUKLE5OZB7JJGIBLVMIYQLBU")
>>> post.caption
'@peaks '
>>> post.mentions
[<pybyte.user.ByteUser object at 0x10b33b550>]
>>>
>>> # rebyte / like posts
...
>>> post.rebyte()
True
>>> post.like()
True
>>>
>>> # comment posts
...
>>> post.comment("Haha!")
True
>>>
>>> # Upload Posts
...
>> byte.upload('sample.mp4', caption="haha too funny!")
>> # Automatically generate a thumbnail
>> byte.upload('sample.mp4', caption="haha too funny!", generate_thumbnail=True)
>> # Supply your own thumbnail!
>> byte.upload('sample.mp4', caption="haha too funny", providedThumbnail="ultraCoolthumbnail.jpg")
示例脚本
# Go through the global feed, comment and follow the author if they have < 10 followers
global_feed = byte.me().global_feed()
for post in global_feed.feed:
if post.author.followers['followerCount'] > 10:
post.comment("Hey man, thanks for making me laugh!")
post.like()
else:
continue
示例脚本
# Go through your posts and comment any post older than 3 days and has less than 200 likes
my_posts = byte.me().posts()
time_now = datetime.datetime.now()
for post in my_posts.feed:
if (time_now - post.date).days > 3:
if post.like_count < 200:
# i am not popular :(
post.comment("this post isn't making me popular")
else:
post.comment("Woohoo! I'm very popular!")
else:
# not old enough
continue
测试
即将推出
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码发行版
pybyte-0.1.8.tar.gz (33.6 kB 查看散列)
构建发行版
pybyte-0.1.8-py3-none-any.whl (31.9 kB 查看散列)