コード例 #1
0
ファイル: commands.go プロジェクト: bogem/vnehm
// 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)
}
コード例 #2
0
ファイル: commands.go プロジェクト: bogem/vnehm
// 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))
}
コード例 #3
0
ファイル: tracks_processor.go プロジェクト: bogem/vnehm
func NewConfiguredTracksProcessor() *TracksProcessor {
	return &TracksProcessor{
		DownloadFolder: config.Get("dlFolder"),
		ItunesPlaylist: config.Get("itunesPlaylist"),
	}
}
コード例 #4
0
ファイル: search.go プロジェクト: bogem/vnehm
func searchGetTracks(offset uint) ([]track.Track, error) {
	return client.Search(limit, offset, searchQuery, config.Get("token"))
}
コード例 #5
0
ファイル: commands.go プロジェクト: bogem/vnehm
func checkToken() {
	if config.Get("token") == "" {
		ui.Term("you aren't authorized. Please execute `vnehm auth` command to authorize", nil)
	}
}
コード例 #6
0
ファイル: get.go プロジェクト: bogem/vnehm
func getLastTracks(count uint) ([]track.Track, error) {
	return client.Audios(count, offset, config.Get("token"))
}
コード例 #7
0
ファイル: get.go プロジェクト: bogem/vnehm
// getTracksFromVKWall returns an id of post. It knows, what uri is
// correct VK link to post.
func getTracksFromVKWall(uri string) ([]track.Track, error) {
	ui.Println("Downloading audio(s) from the post")
	index := strings.Index(uri, "wall")
	postID := uri[index+len("wall"):]
	return client.WallAudios(postID, config.Get("token"))
}
コード例 #8
0
ファイル: list.go プロジェクト: bogem/vnehm
func listGetTracks(offset uint) ([]track.Track, error) {
	return client.Audios(limit, offset, config.Get("token"))
}