Example #1
0
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("")
	}
}
Example #2
0
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)
}
Example #3
0
// EnsureConfig tries to load the config file. If there is no such file it will
// create one and exits.
func EnsureConfig() {
	err := config.CheckConfig()
	if err != nil && os.IsNotExist(err) {
		fmt.Println("It seems that there is no config file present at ", config.ConfigFile())
		fmt.Println("Writing a default one, please inspect it and restart GetMe.")
		config.WriteDefaultConfig()
		os.Exit(1)
	}

	if config.Config() == nil {
		os.Exit(1)
	}
}
Example #4
0
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
}
Example #5
0
func main() {
	flag.Parse()

	if version {
		fmt.Printf("Version %s\n", versionNumber)
		os.Exit(1)
	}

	loadConfig()
	config.SetLoggerOutput(config.Config().LogDir)

	config.SetLoggerTo(logLevel)

	if update {
		updateMedia()
	} else {
		addMedia()
	}
}
Example #6
0
	"strings"
	"text/tabwriter"
	"time"

	log "github.com/Sirupsen/logrus"

	"github.com/haarts/getme/config"
	"github.com/haarts/getme/sources"
	"github.com/haarts/getme/store"
	"github.com/haarts/getme/torrents"
)

// NOTE no log calls should appear here. That stuff should be handled in the
// underlying layer.

var conf = config.Config()

// EnsureConfig tries to load the config file. If there is no such file it will
// create one and exits.
func EnsureConfig() {
	err := config.CheckConfig()
	if err != nil && os.IsNotExist(err) {
		fmt.Println("It seems that there is no config file present at ", config.ConfigFile())
		fmt.Println("Writing a default one, please inspect it and restart GetMe.")
		config.WriteDefaultConfig()
		os.Exit(1)
	}

	if config.Config() == nil {
		os.Exit(1)
	}