Ejemplo n.º 1
0
// initializeItunesPlaylist initializes itunesPlaylist value. If there is no
// itunesPlaylist set up, then itunesPlaylist set up to blank string. Blank
// string is the sign, what tracks should not to be added to iTunes.
//
// initializeItunesPlaylist sets blank string to config, if OS is darwin
func initializeItunesPlaylist(cmd *cobra.Command) {
	var playlist string

	if runtime.GOOS == "darwin" {
		if flagChanged(cmd.Flags(), "itunesPlaylist") {
			playlist = itunesPlaylist
		} else {
			playlist = config.Get("itunesPlaylist")
		}

		if playlist == "" {
			ui.Warning("you didn't set an iTunes playlist. Tracks won't be added to iTunes.")
		} else {
			playlistsList, err := applescript.ListOfPlaylists()
			if err != nil {
				ui.Term("couldn't get list of playlists", err)
			}
			if !strings.Contains(playlistsList, playlist) {
				ui.Term("playlist "+playlist+" doesn't exist. Please enter correct name.", nil)
			}
		}
	}

	config.Set("itunesPlaylist", playlist)
}
Ejemplo n.º 2
0
// initializePermalink initializes permalink value. If there is no permalink
// set up, then program is terminating.
func initializePermalink(cmd *cobra.Command) {
	var p string

	if flagChanged(cmd.Flags(), "permalink") {
		p = permalink
	} else {
		p = config.Get("permalink")
	}

	if p == "" {
		ui.Term("you didn't set a permalink. Use flag '-p' or set permalink in config file.\nTo know, what is permalink, read FAQ.", nil)
	} else {
		config.Set("permalink", p)
	}
}
Ejemplo n.º 3
0
Archivo: list.go Proyecto: bogem/nehm
func showListOfTracks(cmd *cobra.Command, args []string) {
	initializeConfig(cmd)
	config.Set("UID", client.UID(config.Get("permalink")))

	tp := tracksprocessor.NewConfiguredTracksProcessor()

	tm := ui.TracksMenu{
		GetTracks: listGetTracks,
		Limit:     limit,
		Offset:    offset,
	}
	downloadTracks := tm.Show()

	tp.ProcessAll(downloadTracks)
}
Ejemplo n.º 4
0
// initializeDlFolder initializes dlFolder value. If there is no dlFolder
// set up, then dlFolder is set to HOME env variable.
func initializeDlFolder(cmd *cobra.Command) {
	var df string

	if flagChanged(cmd.Flags(), "dlFolder") {
		df = dlFolder
	} else {
		df = config.Get("dlFolder")
	}

	if df == "" {
		ui.Warning("you didn't set a download folder. Tracks will be downloaded to your home directory.")
		df = os.Getenv("HOME")
	}

	config.Set("dlFolder", util.SanitizePath(df))
}
Ejemplo n.º 5
0
func NewConfiguredTracksProcessor() *TracksProcessor {
	return &TracksProcessor{
		DownloadFolder: config.Get("dlFolder"),
		ItunesPlaylist: config.Get("itunesPlaylist"),
	}
}
Ejemplo n.º 6
0
Archivo: get.go Proyecto: bogem/nehm
func getLastTracks(count uint) ([]track.Track, error) {
	uid := client.UID(config.Get("permalink"))
	return client.Favorites(count, offset, uid)
}
Ejemplo n.º 7
0
Archivo: list.go Proyecto: bogem/nehm
func listGetTracks(offset uint) ([]track.Track, error) {
	return client.Favorites(limit, offset, config.Get("UID"))
}