Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Logging in...");

            PandoraHelpers.Session(async client =>
            {
                client.Settings.Endpoint = PandoraEndpoints.Tuner.HttpUri;

                Console.WriteLine("Finished logging in.");

                var query = Environment.GetEnvironmentVariable("PANDORUM_QUERY") ?? "Taylor Swift";
                Console.WriteLine($"Searching for {query}...");

                var results = await client.Stations.Search(query);
                var seed    = results.Artists.First();

                Console.WriteLine("Creating a new station...");
                Console.WriteLine($"Using seed: {seed.GetType()}, {seed}");

                var created = await client.Stations.Create(seed);
                Console.WriteLine($"Successfully created {created}!");

                try
                {
                    var newName = "_-_-_- Radio";
                    Console.WriteLine($"Renaming to {newName}");
                    created = await client.Stations.Rename(created, newName);
                    Console.WriteLine("Done.");

                    Console.WriteLine("Getting expanded info...");
                    var expanded = await client.Stations.ExpandInfo(created);

                    WriteProperties(expanded, Console.Out);
                    WriteProperties(expanded.Feedback, Console.Out);
                    WriteProperties(expanded.Music, Console.Out);
                }
                finally
                {
                    Console.WriteLine("Deleting the newly created station...");
                    await client.Stations.Delete(created);
                    Console.WriteLine("Successfully deleted!");
                }
            });
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            PandoraHelpers.Session(async client =>
            {
                client.Settings.Endpoint = PandoraEndpoints.Tuner.HttpUri;

                Console.WriteLine("Retrieving a list of stations...");
                var list     = await client.Stations.List();
                var quickMix = list.Single(s => s.IsQuickMix);

                Console.WriteLine("Getting extended info on QuickMix...");
                var expanded = await client.Stations.ExpandInfo(quickMix);
                Console.WriteLine(JsonConvert.SerializeObject(expanded, Formatting.Indented));

                Console.WriteLine("Getting extended info on some other station...");
                var station = list.FirstOrDefault(s => s.Name == "The Hills Radio") ?? list.First(s => !s.IsQuickMix);
                expanded    = await client.Stations.ExpandInfo(station);
                Console.WriteLine(JsonConvert.SerializeObject(expanded, Formatting.Indented));
            });
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            PandoraHelpers.Session(async client =>
            {
                client.Settings.Endpoint = PandoraEndpoints.Tuner.HttpUri;

                if (Environment.GetEnvironmentVariable("PANDORUM_GENRE_TEST") != "false")
                {
                    Console.WriteLine("Testing genreStations API...");

                    var checksum = await client.Stations.Genres.Checksum();
                    Console.WriteLine($"Checksum: {checksum}");

                    var list = await client.Stations.Genres.List();
                    // TODO: Category should implement IGrouping
                    // Return type may want to implement ILookup
                    foreach (var category in list)
                    {
                        Console.WriteLine(category.Name);
                        foreach (var station in category)
                        {
                            Console.WriteLine(station);
                        }
                    }
                }

                // TODO: Add conditional here
                {
                    Console.WriteLine("Creating new test station...");
                    var query = Environment.GetEnvironmentVariable("PANDORUM_GENRE_QUERY") ?? "Pop";

                    var results = await client.Stations.Search(query);
                    Console.WriteLine("Finished searching.");

                    var genre = results.Genres.First();
                    Console.WriteLine($"Calling createStation with genre {genre}...");

                    var station = await client.Stations.Create(genre);

                    try
                    {
                        Console.WriteLine("Adding another artist seed...");
                        var query2 = Environment.GetEnvironmentVariable("PANDORUM_ARTIST_QUERY") ?? "Jason Derulo";
                        Console.WriteLine($"Searching for {query2}");

                        var results2 = await client.Stations.Search(query2);
                        var artist   = results2.Artists.First();

                        Console.WriteLine($"Adding {artist} to the mix...");
                        var removable = await client.Stations.AddSeed(station, artist);

                        Console.WriteLine("Adding a song seed...");
                        var query3 = Environment.GetEnvironmentVariable("PANDORUM_SONG_QUERY") ?? "Counting Stars";
                        Console.WriteLine($"Searching for: {query3}");

                        var results3 = await client.Stations.Search(query3);
                        var song     = results3.Songs.FirstOrDefault(s => s.ArtistName == "One Republic") ?? results3.Songs.First();
                        Console.WriteLine($"Adding seed {song} to the station...");

                        var removable2 = await client.Stations.AddSeed(station, song);
                        Console.WriteLine("Finished.");
                        // Console.WriteLine($"artUrl of song: {removable2.ArtUrl}");
                        // Console.WriteLine($"dateCreated: {removable2.DateCreated}");

                        Console.WriteLine("Finally! Getting extended info...");
                        var expanded = await client.Stations.ExpandInfo(station);
                        Debug.Assert(expanded.GetType() == typeof(ExpandedStation)); // should not subclass

                        foreach (var property in typeof(ExpandedStation).GetRuntimeProperties())
                        {
                            try
                            {
                                Console.WriteLine($"{property} = {property.GetValue(expanded)}");
                            }
                            catch { }
                        }

                        var removable3 = expanded.Music.Genres.First();
                        Console.WriteLine($"Removing genre {removable3}...");
                        await client.Stations.RemoveSeed(removable3);
                        Console.WriteLine("Finished!");

                        Console.WriteLine("Re-retrieving extended info to reflect the results...");
                        expanded = await client.Stations.ExpandInfo(expanded);

                        foreach (var property in expanded.GetType().GetRuntimeProperties())
                        {
                            try
                            {
                                Console.WriteLine($"{property} = {property.GetValue(expanded)}");
                            }
                            catch { }
                        }
                    }
                    finally
                    {
                        Console.WriteLine("Deleting the test station...");
                        await client.Stations.Delete(station);
                    }
                }
            });
        }