Example #1
0
// Title obtains information on a title id and presents it.
func Title(id string) {
	t, err := imdb.NewTitle(id)
	if err != nil {
		fmt.Println("NewTitle error", err)
		os.Exit(1)
	}
	fmt.Println(t.String())
}
Example #2
0
// FindTitle searches for a title and presents up to 10 results.
func FindTitle(q string) {
	r, err := imdb.FindTitle(q)
	if err != nil {
		fmt.Println("FindTitle error", err)
		os.Exit(1)
	}
	if len(r) == 0 {
		fmt.Println("No results found.")
		return
	}
	max := len(r)
	if max > 10 {
		max = 10
	}
	for i, tt := range r[:max] {
		t, err := imdb.NewTitle(tt.Id)
		if err != nil {
			fmt.Println("NewTitle error", err)
			os.Exit(1)
		}
		fmt.Printf("%2d. %s\n", i+1, t.String())
	}
}