在tweepy中回复推文

问题描述 投票:0回答:1

我的代码存在问题,无论我尝试什么,每次我回复一条推文时,它都只是作为定期状态更新发布在我的时间轴上。

这是代码段

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。似乎没有任何效果。我也没有使用metadata参数。我正在逐字逐句地关注文档。

python twitter tweepy
1个回答
0
投票

好的。供以后阅读的所有人

使用此in_reply_to_status_id=tweetid

请勿使用方括号。现在一切都正常运行

© www.soinside.com 2019 - 2024. All rights reserved.