The imdb package offers methods to browse imdb and get data about entities. Generated Docs
Here's a short guide of the available methods and it's usage. All options are passed in the optional field of each function.
Let's start by importing the imdb package
import "github.com/Jisin0/filmigo/imdb"
Now let's create a new imdb client, all methods are called through this client.
client := imdb.NewClient()
Options
- DisableCaching : Indicates wether data should not be cached.
- CacheExpiration : Duration for which cache is valid. Defaults to 5 hours.
These functions use imdb's api and are superfast. You can search for titles. names or both.
You can search for titles i.e Movies and Shows using the SearchTitles method.
client.SearchTitles("inception")
You can search for names using the SearchNames method.
client.SearchNames("keanu")
You can search for titles and names using the SearchAll method.
client.SearchAll("mad")
Use this function to get a movie using it's imdb id. We'll use tt1375666 for this example.
client.GetMovie("tt1375666")
Use this function to get a person using their imdb id. We'll use nm0000206 for this example.
client.GetPerson("nm0000206")
Imdb offers an advanced search page that allows filtering people and titles based on a wide variety of parameters.
We'll search for all action movies in this examples.
First lets import the constants package.
import "github.com/Jisin0/filmigo/imdb/constants"
Now lets create our request options.
opts := imdb.AdvancedSearchTitleOpts{
Types: []string{constants.TitleTypeMovie},
Genres: []string{constants.TitleGenreAction},
}
Then make the request.
results, err := client.AdvancedSearchTitle(&opts)
if err!=nil{
panic(err)
}
We'll search for people who starred in inception using it's id.
Lets create our request options.
opts := imdb.AdvancedSearchNameOpts{
Titles: []string{"tt1375666"},
}
Then make the request.
results, err := client.AdvancedSearchName(&opts)
if err!=nil{
panic(err)
}