Guess The Poke
And here is another post in the world's least visited blog according to scientific studies conducted at the University of the Road.
What's new? well, some!
let's start by saying that the project of going back to stream is taking shape and every now and then I started to go on ( come follow me live at www.twitch.tv/mariodose ), so far I have also created a kind of schedule.
mainly for now it will bring coding , video games and video parties of movies and TV series.
the main goal remains to create a high profile community that is not a tinder style dating center.
Then we get to the important point of the post, I have been working on and finished a hopefully interesting project.
after seeing on tik tok , yeah weird but tik tok has completely replaced reading the back of the baths when I'm sitting on the toilet , anyway I don't tergize on tik tok I saw this video of this guy who created a program that takes posts with multiple upvotes on different "funny" categories on reddit ,makes two screenshots, has a bot read them and puts a minecraft video underneath in the background and it goes viral.
well what can i say , interesting project and that can help me quietly to improve and study libraries that i completely ignore and.....should i say....project that really brought back the thrill , like the thrill? what is it? it's that thrill that keeps you glued to your pc to look for the solution to the problem and it goes all over your back when everything then gets solved...ah what a joy.
let's start from the beginning though, at first I didn't give even 2 cents to this project and left it to die in some unknown tab of my chrome, when one day while I was in the live stream of the legendary professor Andrea Pollini (www.twitch.tv/profandreapollini) when asked if there were any projects I proposed and liked the idea. All together we put ideas to do something similar but not the same and of course not copy code but just see maybe libraries and do everything ourselves.
In stream there was a lot of debate because we decided to work ethically. Rules. 1)don't use material you didn't own the rights to 2)nothing that could be NSFW and obviously ethically wrong. Eventually we came up with the idea of making a little program that sends a request to wikipedia on a page about the best 120 movies in history according to a news outlet, from there it takes one at random, makes a kind of plot summary and is shown on the screen while google gtts creates a text to speech of the text, then the video puts a counter to allow the viewer to try to guess the movie in question, then a QR code is generated that links back to the movie for those watching from broswer and the title is said to give the viewer a chance to check if they guessed right.
Everything perfect works , but now it's my turn. as much as you can help in a stream with ideas there is no chance to put your hand on the code , especially when the streamer , the professor , is clearly better than you at writing code , so there remains that "viewer" factor that suffers the code passively , so I decided I had to work in my own version completely on my own, without copying the professor's code, modifying the basic idea and choosing all the technologies by myself.
And here was the birth of GUESS THE POKE.
i unfortunately had to opt to use pokemon, a product that i don't own the rights to so everything i will do is not monetized but only for study purposes, as all the rights to pokemon belong to nintendo and game freak.
what does GUESS THE POKE consist of? basically it is a 2.0 and social version of the old interlude that used to be in the episodes of the first pokemon series , before the commercial an obscured pokemon would be shown on the screen which then following the commercial, before the second part of the episode the uncensored pokemon would be shown, to see if the kids had guessed it.
I decided to use different technologies but let's go slowly also just to explain the code and use one of Richard Feynman's many techniques to explain and in the process see if I actually understood the technology I used.
first I looked for a way to find a list of all the pokemon, it was very difficult because I couldn't find anything very useful so I thought to look for a csv with the list of all the pokemoins and fortunately I found one with address to the picture and pokedex link with description.
the goal at first was to retrieve from this line 1) name of the pokemon 2) link to the picture and link to the pokedex

nothing easier i opted for simple search and cut and sew, always easy , simple and reliable:
#take a random row from the csv
with open("database1.csv") as f:reader = csv.reader(f)chosen_row = random.choice(list(reader))
#print(chosen_row)
#get what we are interested in
name_pokemon = chosen_row[0]picture_pokemon = chosen_row[22]pokedex_info = chosen_row[-1]print(name_pokemon)print(picture_pokemon)print(pokedex_info)
(later we will find out that I will no longer use the pokemon desciption because the video with tts reading the text would create tik tok that would be too long and unimmediate for a perosna to understand as the video is in the "for you" I am not deleting just because the code if it works should not be touched and because in the future in version 2.0 I will want the description to be put as the first comment to the post).
once we have this data what to do?
well take pokemon description and image and put in a temporary file to keep in memory:
response = requests.get(picture_pokemon)img = image.open(bytesIO(response.content))
image_url = picture_pokemon #the image on the websave_name = 'temp.png' #local name to be savedurllib.request.urlretrieve(image_url, save_name)
url = pokedex_infor = requests.get(url, allow_redirects=True)
open('temp.HTML', 'wb').write(r.content)
with open('temp.HTML', 'r') as f:doc = BeautifulSoup(f, "html.parser")
result = doc.find(class_="version-x")
text = result.get_text()text = text.lstrip()
here, however, I was presented with a possible problem. what if the pokemon name was checked off in the description? simple 2 lines of nerdy code and here is the solution:
if name_pokemon in text:text.replace(name_pokemon, "The Pokemon")print(text)file_from_read = open("temp.txt", "w")file_from_read.write(text)file_from_read.close()
Perfect, now we have everything and can start working.
first thing to do? create a version (always transparent in png) of the temporary photo from before , but where we are going to replace all the colors.
here I wasted some time because I had problems with the fourth transparency value which I had completely ignored in RGBA technology so I got some advice from the official python community discord and then I wrote this code which so far seems to work although I had to compromise on the alpha of the transparency since it is not always the same:
img_da_maskerare = Image.open("temp.png")
width = img_from_maskerare.size[0]
height = img_from_maskerare.size[1]
for i in range(0,width):
for j in range(0,height):
data = img_from_maskerare.getpixel((i,j))
# RGBA = Red, Green, Blue, Alpha
# Alpha = 0 = transparent, 255 = opaque
# alpha > 200 means approximately opaque
if data[3] >= 200:
img_from_maskerare.putpixel((i,j),(00, 00, 00))
img_from_maskerare.save('temp_maskerad.png')the TTS part I deleted it because it is a part that I completely took out of the project and so now with everything ready and set up I switched to using moviepy, I admit that at first discouraged by the documentation done , in my opinion, very badly I tergiversato, but the moment I tried to use it I realized that it was super simple and in a few minutes I wrote just those 4 lines of code to make it work , I only had trouble figuring out the timing but later with very basic math and using my hands to count I got everything in timing:
background = VideoFileClip("media/Timeline1920.mov").set_duration(13)
video_blurredimg = ImageClip("temp_maskerad.png").set_duration(9)
video_respdimg = ImageClip("temp.png").set_duration(4)
file_definitive.write_videofile("media/tmp.mp4").fps("24").codec("libx264")
I would say that this project as a difficulty can safely be put on "easy/intermediate" category however it was really nice and I hope to soon have the time and desire to do part two where I will implement automation of uploading to social.
instead if you want to follow the profile on social here are the links to youtube and tiktok (the contents are different just so you don't have a carbon copy , after all it takes 30 seconds to generate a video).
https://www.youtube.com/channel/UChyZaS4-__PQraYJrBlDbmQ
https://www.tiktok.com/@guesspokemon
by the way amazing how in just 1-2 days they created a loyalty in the videos very interesting within a few hours on tik tok the videos reach 600-700 visits and then stop , on the contrary youtube can also stay for hours and days at 12 spect and then in a single hour make a bang at 2500, interesting , maybe when it will be all automated i will analyze the phenomenon of the month just to try to understand how the platforms can work.