Exemple #1
0
//
// UNUSED FUNCTIONS
// getInfo formats details for the current track
func getInfo(conn *mpd.Client, s *Status) {
	song, _ := conn.CurrentSong()
	s.Title = song["Title"]
	filename := path.Base(song["file"])
	directory := path.Dir(song["file"])
	var searchParams string

	if song["Title"] != "" {
		s.Info = map[int]map[string]string{
			1: {
				"Artist": song["Artist"],
			},
			2: {
				"Album": song["Album"] + " (" + song["Date"] + ")",
			},
		}
		searchParams = song["Artist"] + " music " + song["Title"]
	} else {
		s.Info = map[int]map[string]string{
			1: {
				"Folder": directory,
			},
		}
		searchParams = filename
	}
	encQuery := url.QueryEscape(searchParams)
	tldr := "https://www.youtube.com/embed?fs=0&controls=0&listType=search&list="
	s.YouTube = tldr + encQuery
}
Exemple #2
0
// getListing stores other tracks from same folder as current track
func getListing(conn *mpd.Client, s *Status) {
	song, _ := conn.CurrentSong()
	filename := path.Base(song["file"])
	directory := path.Dir(song["file"])
	thisDir, _ := conn.ListInfo(directory)
	var listing = make([]NowList, len(thisDir))

	for i := 0; i < len(thisDir); i++ {
		m := thisDir[i]
		p := m["file"]
		t := m["title"]
		d := path.Dir(p)
		f := path.Base(p)
		if f == "." || f == "" {
			continue
		}
		if t != "" {
			if f == filename {
				listing[i].Current = true
				listing[i].Album = m["album"]
			}
			listing[i].Artist = m["artist"]
			listing[i].Label = t
		} else {
			if f == filename {
				listing[i].Current = true
				listing[i].Album = d
			}
			listing[i].Artist = m["artist"]
			listing[i].Label = f
		}
	}
	s.List = listing
}
Exemple #3
0
// getPlaylist stores other tracks from current playlist
func getPlaylist(conn *mpd.Client, s *Status) {
	var first, last int
	status, ror := conn.Status()
	er(ror)
	curPos, _ := strconv.Atoi(status["song"])
	if curPos > 19 {
		first = curPos - 20
	} else {
		first = 0
	}
	last = curPos + 20
	playlist, ror := conn.PlaylistInfo(first, last)
	er(ror)

	var listing = make([]NowList, len(playlist))
	for i := 0; i < len(playlist); i++ {
		item := playlist[i]
		iPos, _ := strconv.Atoi(item["Pos"])
		filepath := item["file"]
		t := item["title"]
		d := path.Dir(filepath)
		f := path.Base(filepath)
		if f == "." || f == "" {
			continue
		}
		if t != "" {
			if curPos == iPos {
				listing[i].Current = true
				listing[i].Album = item["album"]
			}
			listing[i].Artist = item["artist"]
			listing[i].Label = t
		} else {
			if curPos == iPos {
				listing[i].Current = true
				listing[i].Album = d
			}
			listing[i].Artist = item["artist"]
			listing[i].Label = f
		}
	}
	s.List = listing
}