Beispiel #1
0
func main() {
	flag.Parse()

	if len(flag.Args()) != 1 {
		fmt.Println("Usage : list_series substring")
		return
	}

	// GetSeries does not require either an API key or an account id.
	tvdb, err := thetvdb.New("", "")
	if err != nil {
		fmt.Println("Error :", err)
		return
	}

	fmt.Printf("Fetching series ... ")
	series, err := tvdb.GetSeries(flag.Args()[0])
	if err != nil {
		fmt.Println("Error retrieving series :", err)
		return
	} else {
		fmt.Println("Ok")
		for _, serie := range series {
			fmt.Println(serie.Id, serie.Name)
		}
	}
}
Beispiel #2
0
func main() {
	flag.Parse()

	if len(*theTVDBAccountId) == 0 || len(*theTVDBApiKey) == 0 {
		fmt.Println("Both --account_id and --api_key must be provided.")
		return
	}

	tvdb, err := thetvdb.New(*theTVDBApiKey, *theTVDBAccountId)
	if err != nil {
		fmt.Println("Error :", err)
		return
	}

	fmt.Printf("Fetching user favorites ... ")
	userFavorites, err := tvdb.GetUserFavorites()
	if err != nil {
		fmt.Println("Error retrieving favorites :", err)
		return
	} else {
		fmt.Println("Ok")
		fmt.Println("Number of favorites :", len(userFavorites))
	}

	var foundEnded = false
	for _, seriesId := range userFavorites {
		series, err := tvdb.GetSeriesById(seriesId)
		if err != nil {
			fmt.Println("Error getting series data :", err)
		} else {
			if series.Status == "Ended" {
				foundEnded = true
				fmt.Printf("Removing series name : %q (%s)\n", series.Name, series.Status)
				tvdb.RemoveUserFavorite(series.Id)
			}
		}
	}

	if !foundEnded {
		fmt.Println("No ended series found.")
	}
}