⬆️ ⬇️

Guess the movie on the trailer

Guess the movie on the trailer !

In search of inspiration in the works of the infamous competition for web developers 10k.aneventapart.com, which was first touched by the author in the last article , such a simple application was noticed. The short meaning - according to the trailer of the film to determine its year of release. The idea is simple, interesting, and starting from it you can come up with at least one more simple gaming application. Do you want details and / or you have not read the title of the article inattentively? - Then, welcome under cat.



According to the trailer of the film, it is permissible to guess various things - the director, the year of release, the full title of the work, etc. It is about guessing the name of the film on its trailer that will be discussed in this article. As a rule, the name of the film at the very beginning of the trailer does not appear, which creates prerequisites for the correct functioning of our application. To simplify the life of the user, we will not force him to enter any data into the text form manually - let him choose the correct answer, for example, from three options.



How it works?


The genius of the competition 10k.aneventapart.com is that an application that claims to win must be small and functional at the same time, otherwise it has no chance. One of the solutions to this contradiction is the use of various APIs, which kill several birds with one stone - the lack of storage of large amounts of data within the client application and the expansion of functionality through external requests only. The application, taken as a basis for our service, does just that. We will follow his example.

To start, a random number (year) is generated in the limits specified in the script (for example, from 1950 to 2011). Then this year is substituted into the query to the query.yahooapis.com service, which, in particular, allows parsing pages with a list of movie titles associated with a particular year. In this form, data about the films are stored for example in Wikipedia. (It should be noted that such a system is not flexible and depends on the format and HTML markup of the resource being parsed. Such is the fee for using third-party resources to load their data into their applications.)

Having found a sufficient number of movie titles, choose one random from them, corresponding to the correct movie title and two confusing ones. - Now you can search for the corresponding trailer on YouTube. We display the received information to the user.

Warning about possible shortcomings - the application is experimental and the design is not different, guessing Russian trailers also leaves much to be desired due to the relatively small number of Russian trailers in general and on YouTube in particular. This is especially noticeable for old films.

If someone needs javascript sources, not in a compressed form, on request in the comments or in a personal, I will provide the code “to the studio”.

Guess the movie !


')

Source: https://habr.com/ru/post/141988/



All Articles