My projects: Which movie to watch
By: Štefan Prokop
Tags: Symfony, Puppeteer, Series, Projects, Movies

Writing my own projects is something I like to do in my free time. Sometimes I have a sudden idea for a small project which I write on my bucket list and when I have time I will bring it to life. One of these projects is Which movie to watch.

Which movie to watch — home page

About Which movie to watch

The main goal of Which movie to watch is to find the best movie for you that you might want to see. You can find it on https://which-movie-to-watch.backenders.eu/. Imagine you want to watch a movie after a long and hard day. How do you choose what to watch? You can use this website for it. There are around 15.000 movies that are waiting for you (half of them are from the year 2019).

Which movie to watch — movie detail

Each movie has its own detail page. You can find a movie name, description, rating, categories, runtime, poster and trailer there. The trailer is the core feature of this project because you don’t want to read about the movie, better is to watch the trailer.

Below the detail and on the home page you can find the top rated movies and newly released movies.

All of the movies are “randomly” selected for you. If you don’t want to see the selected movie, you can easily click the blue arrow button and generate a new one. You can also list movies through the categories.

Which series to watch

Which series to watch — home page

The project Which series to watch is very similar to the Which movies to watch. The only difference is there are series instead of movies. You can find it here https://which-series-to-watch.backenders.eu/.

Both pages have the same functionalities and both are localized for Czechia and English speaking countries.

Technical info

When I’m making a new project I’m thinking about two important questions for me. How much time am I willing to invest into the development? Are there some technologies I would like to try or learn? The first question is the most important for me because I’m developing all of my projects in my free time and without any financial support. On the other hand oftentimes there are some things I have never worked with before. This time it was puppeteer.

Technologies

I used PHP framework Symfony 5. Because it’s a modern web framework that is easy to use. I have a lot of experience with it and it’s “all in one” — you don’t need to create backend and frontend separately. It’s easy and fast to start / initialize the project and it’s cheap and easy to deploy it. The last version of Symfony I used before I switched to Node.js was 2.x so it was something “new” for me. I like Symfony and I can recommend it. I like the project structure or boilerplate, it‘s simple and well organized. Symfony is used by many companies and developers so you will find answers to your questions on stackoverflow or other forums quite easily. Also because of the huge community there are a lot of bundles which you can install and use. I also like the dependency injection feature which is new for me, I mean the classes are registered as a service automatically.

There were no problems on the frontend side because there is nothing special. On the backend side I would like to mention the “random movie generate” function. It’s the MySQL rand() function but there some additional filters and orders like movie release date, rating, if the movie has a trailer and categories. The other thing is the project is written as a bundle so it’s easy to include / install it to “whatever” Symfony project.

The question is — where did I get the movies from? I found a dataset on the internet with ~50k movies. I processed this huge file with Node.js streams. All the movies have the name, description, poster URL but there wasn’t the trailer URL. I found a web page where it was easy for me to get these trailer URLs but I needed to scrape the website.

I wanted to use Symfony DomCrawler but there was a problem with asynchronous tasks. The trailer URL was rendered via JavaScript so the DomCrawler didn’t return it. Then I wrote a simple JavaScript script where I used puppeteer for this job. There was no problem with puppeteer and I successfully got the trailer URLs. In the beginning I was quite confused how to use puppeteer’s selectors and expressions but it was because I saw it for the first time — I wasn’t able to use it before I read something about it in the docs. I also had some problems with the waitFor function and some cases like there is no trailer URL / trailer div / 404 and 50X errors and stuff like this. I ran the script. After hundreds of successes I started to receive errors and that was the time to kill the process, fix it and start again.

Summary

~65 hrs of development (~10 hrs — frontend, ~55 hrs — backend)

I learned puppeteer 🎉

I improved my Node.js streams knowledge

I learned how to do and use a bundle in Symfony 5

I got to know the MySQL rand() function

Conclusion

Both projects support Czech and English languages. But it’s not a problem to add translations for other countries. You can find and try them on https://which-movie-to-watch.backenders.eu/ and https://which-series-to-watch.backenders.eu/.

If you have any questions, ideas what to improve / add or bug reports don’t hesitate to contact me.

You can also check my GitHub and LinkedIn.