Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweet images instead of text #94

Merged
merged 8 commits into from
Oct 9, 2020
Merged

Conversation

Ares358
Copy link
Collaborator

@Ares358 Ares358 commented Oct 9, 2020

Solves #90

Changes made to get_tweet.py :
-updated get_tweet() so that it returns a random tweet each time it is called from within a loop. Before that it returned the same tweet if called from another script.

Changes made to generateImage.py :
-it now takes a random tweet from get_tweet.py and adds it on the images.
-default x and y co-ordinates changed so that the tweet appears in center of the image.
-could be imported into another script and used to generate an array of images via the "run(x)" function which generates x images with random tweets.

Changes made to tweet.py:
-The program uploads an image instead of the tweet. Another parameter could be passed to upload image WITH a tweet.

NOTE: It assumes that the generated images have the naming convention "post_{no}.png" and are all located in the same directory as the tweet.py file. It also assumes that there exists atleast 1 image with the above mentioned naming convention in the directory. If not, the script will enter an infinite loop when get_img_random() is called.

updated get_tweet() so that it returns a random tweet each time it is called from within a loop.
The program now gets a random tweet from get_tweet.py and prints it on a random image from img_bg.
The function "run" takes "x" as a parameter and repeats the above mentioned process for x no of times.
The program uploads an image instead of the tweet. Another parameter could be passed to upload image WITH a tweet.
It assumes that the generated images have the naming convention "post_{no}.png" and are all located in the same directory as the tweet.py file.
It also assumes that there exists atleast 1 image with the above mentioned naming convention in the directory.
tweet.py Outdated Show resolved Hide resolved
"No image exists in working directory" and infinite loop issue resolved. 

The program now scans and initializes the array "arr" containing image names and tweets every hr with 1 image from the array.
get_img_random() is obsolete now, hence is commented out.
updated to include both, post_{no} and post_{no+'a'} files into the array `arr` containing filenames
Copy link
Owner

@VickiLanger VickiLanger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. I'm excited to see this in production


Don't forget to follow the bot on Twitter to see the hard work you put in.

@VickiLanger VickiLanger merged commit a3e2df8 into VickiLanger:production Oct 9, 2020
Comment on lines +96 to +99
run()

if __name__ == "__main__":
main()
Copy link
Collaborator Author

@Ares358 Ares358 Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 4 lines should be replaced with these 2 lines

if __name__ == "__main__":
run()

run() already calls for main() at line 88

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants