Ejemplo n.º 1
0
func main() {
	infrastructure.ProcessSconsifyrc()

	fmt.Println("Sconsify - your awesome Spotify music service in a text-mode interface.")
	events := sconsify.InitialiseEvents()

	go mock.Initialise(events)

	go testSequence()
	ui := ui.InitialiseConsoleUserInterface(events)
	sconsify.StartMainLoop(events, ui, false)
	println(output.String())
}
Ejemplo n.º 2
0
func main() {
	infrastructure.ProcessSconsifyrc()

	providedUsername := flag.String("username", "", "Spotify username.")
	providedWebApi := flag.Bool("web-api", false, "Use Spotify WEB API for more features. It requires web authorization.")
	providedUi := flag.Bool("ui", true, "Run Sconsify with Console User Interface. If false then no User Interface will be presented and it'll shuffle tracks.")
	providedPlaylists := flag.String("playlists", "", "Select just some Playlists to play. Comma separated list.")
	providedPreferredBitrate := flag.String("preferred-bitrate", "320k", "Preferred bitrate: 96k, 160k, 320k (default).")
	providedNoUiSilent := flag.Bool("noui-silent", false, "Silent mode when no UI is used.")
	providedNoUiRepeatOn := flag.Bool("noui-repeat-on", true, "Play your playlist and repeat it after the last track.")
	providedNoUiShuffle := flag.Bool("noui-shuffle", true, "Shuffle tracks or follow playlist order.")
	providedDebug := flag.Bool("debug", false, "Enable debug mode.")
	askingVersion := flag.Bool("version", false, "Print version.")
	flag.Parse()

	if *askingVersion {
		fmt.Println("Version: " + version)
		fmt.Println("Git commit: " + commit)
		fmt.Println("Build date: " + buildDate)
		os.Exit(0)
	}

	if *providedDebug {
		infrastructure.InitialiseLogger()
		defer infrastructure.CloseLogger()
	}

	fmt.Println("Sconsify - your awesome Spotify music service in a text-mode interface.")
	username, pass := credentials(providedUsername)
	events := sconsify.InitialiseEvents()

	var client *webspotify.Client
	if *providedWebApi {
		client = webapi.Auth(spotifyClientId, authRedirectUrl)
	}

	go spotify.Initialise(client, username, pass, events, providedPlaylists, providedPreferredBitrate)

	if *providedUi {
		ui := ui.InitialiseConsoleUserInterface(events, true)
		sconsify.StartMainLoop(events, ui, false)
	} else {
		var output ui.Printer
		if *providedNoUiSilent {
			output = new(ui.SilentPrinter)
		}
		ui := ui.InitialiseNoUserInterface(events, output, providedNoUiRepeatOn, providedNoUiShuffle)
		sconsify.StartMainLoop(events, ui, true)
	}
}
Ejemplo n.º 3
0
func main() {
	infrastructure.ProcessSconsifyrc()

	providedUsername := flag.String("username", "", "Spotify username.")
	providedWebApi := flag.Bool("web-api", false, "Use Spotify WEB API for more features. It requires web authorization.")
	providedUi := flag.Bool("ui", true, "Run Sconsify with Console User Interface. If false then no User Interface will be presented and it'll shuffle tracks.")
	providedPlaylists := flag.String("playlists", "", "Select just some Playlists to play. Comma separated list.")
	providedPreferredBitrate := flag.String("preferred-bitrate", "320k", "Preferred bitrate: 96k, 160k, 320k (default).")
	providedNoUiSilent := flag.Bool("noui-silent", false, "Silent mode when no UI is used.")
	providedNoUiRepeatOn := flag.Bool("noui-repeat-on", true, "Play your playlist and repeat it after the last track.")
	providedNoUiShuffle := flag.Bool("noui-shuffle", true, "Shuffle tracks or follow playlist order.")
	providedWebApiCacheToken := flag.Bool("web-api-cache-token", true, "Cache the web-api token as plain text in ~/.sconsify until its expiration.")
	providedWebApiCacheContent := flag.Bool("web-api-cache-content", true, "Cache some of the web-api content as plain text in ~/.sconsify.")
	providedDebug := flag.Bool("debug", false, "Enable debug mode.")
	askingVersion := flag.Bool("version", false, "Print version.")
	providedCommand := flag.String("command", "", "Execute a command in the server: replay, play_pause, next")
	providedServer := flag.Bool("server", true, "Start a background server to accept commands.")
	flag.Parse()

	if *askingVersion {
		fmt.Println("Version: " + version)
		fmt.Println("Git commit: " + commit)
		if i, err := strconv.ParseInt(buildDate, 10, 64); err == nil {
			fmt.Println("Build date: " + time.Unix(i, 0).UTC().String())
		}
		fmt.Println("Go version: " + runtime.Version())
		os.Exit(0)
	}

	if *providedDebug {
		infrastructure.InitialiseLogger()
		defer infrastructure.CloseLogger()
	}

	if *providedCommand != "" {
		rpc.Client(*providedCommand)
		return
	}

	fmt.Println("Sconsify - your awesome Spotify music service in a text-mode interface.")
	username, pass := credentials(providedUsername)
	events := sconsify.InitialiseEvents()

	initConf := &spotify.SpotifyInitConf{
		WebApiAuth:         *providedWebApi,
		PlaylistFilter:     *providedPlaylists,
		PreferredBitrate:   *providedPreferredBitrate,
		CacheWebApiToken:   *providedWebApiCacheToken,
		CacheWebApiContent: *providedWebApiCacheContent,
		SpotifyClientId:    spotifyClientId,
		AuthRedirectUrl:    authRedirectUrl,
	}
	go spotify.Initialise(initConf, username, pass, events)

	if *providedServer {
		go rpc.StartServer(events)
	}

	if *providedUi {
		ui := simple.InitialiseConsoleUserInterface(events, true)
		sconsify.StartMainLoop(events, ui, false)
	} else {
		var output noui.Printer
		if *providedNoUiSilent {
			output = new(noui.SilentPrinter)
		}
		ui := noui.InitialiseNoUserInterface(events, output, providedNoUiRepeatOn, providedNoUiShuffle)
		sconsify.StartMainLoop(events, ui, true)
	}
}