我的代码有一个问题,无论我怎么做,每次我回复一条tweet,它都会在我的时间线上定期发布状态更新
下面是一段代码
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
不要使用方括号。现在一切正常
在玩它的时候,我还注意到你还应该提到你回复的tweet的作者,特别是如果你回复的是现有的回复,因为它仍然会以状态更新的形式发布。文档中的行:
相关问题 更多 >
编程相关推荐