在 tweepy 中回复推文
replying to a tweet in tweepy
我的代码存在问题,无论我尝试什么,每次我回复推文时,它都只是作为定期状态更新发布在我的时间线上。
这是代码片段
class StreamListener(tweepy.StreamListener):
def on_status(self, status):
tweetid = status.id
tweetnouser = status.text.replace("@CarlWheezerBot", "")
username = '@'+status.user.screen_name
user_tweet = gTTS(text=tweetnouser, lang='en', slow=False)
# Saving the converted audio
user_tweet.save("useraudio/text2speech.mp3")
# importing the audio and getting the audio all mashed up
text2speech = AudioFileClip("useraudio/text2speech.mp3")
videoclip = VideoFileClip("original_video/original_cut.mp4")
editedAudio = videoclip.audio
# splicing the original audio with the text2speech
compiledAudio = CompositeAudioClip([editedAudio.set_duration(3.8), text2speech.set_start(3.8)])
videoclip.audio = compiledAudio
# saving the completed video fie
videoclip.write_videofile("user_video/edited.mp4", audio_codec='aac')
upload_result = api.media_upload("user_video/edited.mp4")
api.update_status( status='@CarlWheezerBot',in_reply_to_status_id=[tweetid], media_ids=[upload_result.media_id_string], auto_populate_reply_metadata=True)
我也试过没有任何状态,以及使用status.id_str。似乎没有任何效果。我也在没有元数据参数的情况下完成了它。我正在逐字逐句地关注文档。
好的。供以后阅读本文的所有人使用
使用这个in_reply_to_status_id=tweetid
不要使用方括号。现在一切正常
在玩它的时候,我还注意到你还应该提到你正在回复的推文的作者,特别是如果你正在回复现有的回复,因为它仍然 post 它作为状态更新。文档中的行:
in_reply_to_status_id – The ID of an existing status that the update is in reply to. Note: This parameter will be ignored unless the author of the Tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced Tweet, within the update.
我的代码存在问题,无论我尝试什么,每次我回复推文时,它都只是作为定期状态更新发布在我的时间线上。
这是代码片段
class StreamListener(tweepy.StreamListener):
def on_status(self, status):
tweetid = status.id
tweetnouser = status.text.replace("@CarlWheezerBot", "")
username = '@'+status.user.screen_name
user_tweet = gTTS(text=tweetnouser, lang='en', slow=False)
# Saving the converted audio
user_tweet.save("useraudio/text2speech.mp3")
# importing the audio and getting the audio all mashed up
text2speech = AudioFileClip("useraudio/text2speech.mp3")
videoclip = VideoFileClip("original_video/original_cut.mp4")
editedAudio = videoclip.audio
# splicing the original audio with the text2speech
compiledAudio = CompositeAudioClip([editedAudio.set_duration(3.8), text2speech.set_start(3.8)])
videoclip.audio = compiledAudio
# saving the completed video fie
videoclip.write_videofile("user_video/edited.mp4", audio_codec='aac')
upload_result = api.media_upload("user_video/edited.mp4")
api.update_status( status='@CarlWheezerBot',in_reply_to_status_id=[tweetid], media_ids=[upload_result.media_id_string], auto_populate_reply_metadata=True)
我也试过没有任何状态,以及使用status.id_str。似乎没有任何效果。我也在没有元数据参数的情况下完成了它。我正在逐字逐句地关注文档。
好的。供以后阅读本文的所有人使用
使用这个in_reply_to_status_id=tweetid
不要使用方括号。现在一切正常
在玩它的时候,我还注意到你还应该提到你正在回复的推文的作者,特别是如果你正在回复现有的回复,因为它仍然 post 它作为状态更新。文档中的行:
in_reply_to_status_id – The ID of an existing status that the update is in reply to. Note: This parameter will be ignored unless the author of the Tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced Tweet, within the update.