コード例 #1
0
ファイル: main.go プロジェクト: gitter-badger/getme
func main() {
	store, err := store.Open(config.Config().StateDir)
	if err != nil {
		fmt.Println("Error opening state")
		os.Exit(1)
	}
	defer store.Close()

	for _, v := range store.Shows() {
		fmt.Printf("Show: %s\n", v.Title)
		fmt.Printf("Pending seasons: ")
		for _, season := range v.PendingSeasons() {
			fmt.Printf("%d, ", season.Season)
		}
		fmt.Println("")
		fmt.Println("Pending episodes:")
		for _, episode := range v.PendingEpisodes() {
			fmt.Printf(
				"%02dx%02d - %s\n",
				episode.Season(),
				episode.Episode,
				episode.Title,
			)
		}
		fmt.Println("")
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: gitter-badger/getme
func updateMedia() {
	store, err := store.Open(config.Config().StateDir)
	if err != nil {
		fmt.Println("We've failed to open the data store.")
		log.WithFields(log.Fields{
			"err": err,
		}).Error("We've failed to open the data store.")
		return
	}
	defer store.Close()

	ui.Update(store)
}
コード例 #3
0
ファイル: main.go プロジェクト: gitter-badger/getme
func handleShow(show *sources.Show) error {
	store, err := store.Open(config.Config().StateDir)
	if err != nil {
		fmt.Println("We've failed to open the data store.")
		log.WithFields(log.Fields{
			"err": err,
		}).Error("We've failed to open the data store.")
		return err
	}
	defer store.Close()

	// Fetch the seasons/episodes associated with the found show.
	persistedShow := store.NewShow(show.Source, show.ID, show.URL, show.Title)
	err = ui.Lookup(persistedShow)
	if err != nil {
		fmt.Println("We've encountered a problem looking up seasons for the show.")
		log.WithFields(log.Fields{
			"err": err,
		}).Error("We've encountered a problem looking up seasons for the show.")
		return err
	}

	if len(persistedShow.Episodes()) == 0 {
		fmt.Println("No episodes could be found for show.")
		log.WithFields(log.Fields{
			"show": persistedShow.Title,
		}).Info("No episodes could be found for show.")
		return nil
	}

	err = store.CreateShow(persistedShow)
	if err != nil {
		fmt.Println("Show already exists. Remove it or search for something else. If you want to update it do: getme -u")
		log.WithFields(log.Fields{
			"err":  err,
			"show": persistedShow.Title,
		}).Fatal("Show already exists.")
	}

	if !noDownload {
		downloadTorrents(persistedShow)
	}

	return nil
}