Contents 1 Description 2 Source location 3 How it work : Global workflow 4 How do the queries and responses look like ? Description This part of the code is used to get the metadata of the movies over Internet. Currently we only work with the public API of The Movie Database (TMDb). Source location Everything that concerns requesting the TMDb API is in the folder src/FetchMetadata. If we begin to have more API, we should create a Namespace for this and a src/Modules folder, but it would be currently a little overkilled. How it work : Global workflow The class Application owns a FetchMetadata object and asks it to get the metadata of some movies. Because Application doesn't know the status of FetchMetadata, it will only add the Movies which metadata should be obtained to a waiting queue. FetchMetadata take care of all the intelligence behind the queries, without knowing the detail of the queries. It only deals with Movies objects. During its construction, a FetchMetadataQuery is constructed. This is the only object that knows how the queries are build, and how the responses look like. The connexion to the API is initialized at this time by FetchMetadataQuery (during the construction): we get the urls to query for getting the posters, the available sizes and so on. Then, for each Movie of the queue of the FetchMetadata object: FetchMetadataQuery is asked to search all the movies having the title of the current Movie If it returns only one proposition: FetchMetadataQuery gets all the metadata of this precise movie, see 2. "If it returns 0 or more than one proposition": a FetchMetadataQuery is constructed and all the propositions are shown, so that the user can choose or write the title that should be searched. If the user searches a new title, we go back to 1, If the user choose a movie in the list, we get all its metadata, see 2. FetchMetadataQuery gets directly all the metadata of a given movie (based on its TMDb id). For each member of the crew (actor, director...) a People object is added to the Movie, containing only a TMDb id, a name and a type (or role), and to another waiting queue so that it can reliably get the metadata of each person. If there is a poster, a request is send to get it. For each People of the waiting queue, a request based on the TMDb id is sent. When the People waiting list is empty, it means that the Movie is completely hydrated, so it is returned to the FetchMetadata object, which saves it in the database, take the following element of its queue and goes back to 1. When the Movie queue is empty, a signal is sent to the Application object which will destroy the FetchMetadata object. How do the queries and responses look like ? See TMDB-json-responses Retrieved from "https://community.kde.org/index.php?title=Macaw-Movies/Development/3rd_party_API&oldid=42268" This page was last edited on 23 April 2015, at 14:49. Content is available under Creative Commons License SA 4.0 unless otherwise noted.