Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3720

Randomizing Sentences In Python

$
0
0

I not long ago finished my project which comments on a video based on a keyword on YouTube, it will pick a random comment using the random library.The program has been acting strange when "randomizing" the comments to add to theYouTube videos. I'm starting to think I may need to improve the randomness, the fact being thatit has chosen the 4th comment (out of 9) 7 times, and the 9th one 3 times. Both of theseresults occur after each other, in other words, it is sending the same message in a rowwhen it's meant to pick randomly and not repeat.Is there any way I can increase how random this is? If you know, please do tell me, I will appreciate it a bunch!

PS: This is more of stopping it from repeating the same sentence on YouTube.

code:

if __name__ == "__main__":    from googleapiclient.errors import HttpError    import random    import time    import sys    # Comments are getting loaded    comments = load_comments('Comments.txt')    # Getting the number of comments you want to add    number_of_comments = int(input('Enter the number of comments: '))    count, cycle, videoid_store = 0, 1, []    # Getting the keyword    keyword = input('Enter the Keyword: ')    # This loop keeps running until all comments have been added    youtube = authentication()    while count < number_of_comments:        print("Searching for videos ..  (Cycle:%d)" %cycle)        time.sleep(10)        random.shuffle(comments)

Viewing all articles
Browse latest Browse all 3720

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>