Пример #1
0
        public Queue <YouTubeVideo> getPlaylist(string name)
        {
            if (!playListsExists(name))
            {
                Console.WriteLine("No playlist with that name!");
                return(null);
            }

            Queue <YouTubeVideo> queue = new Queue <YouTubeVideo>();

            string[] lines = System.IO.File.ReadAllLines(@".\playlists\" + name + ".playlist");

            foreach (string line in lines)
            {
                queue.Enqueue(YouTubeVideo.fromString(line));
            }
            return(queue);
        }
Пример #2
0
        public void loadPlaylist(string name, string requester, AudioManager audioManager)
        {
            if (!playListsExists(name) && !name.Contains("www.youtube"))
            {
                audioManager.sendMessage("No such playlist exists!");
            }

            audioManager.sendMessage("Loading playlist...");
            Queue <YouTubeVideo> queue = new Queue <YouTubeVideo>();

            if (name.Contains("www.youtube"))
            {
                var    request = YouTubeVideo.auth().PlaylistItems.List("contentDetails");
                string id      = name.Substring(name.IndexOf("list=") + 1).Replace("ist=", "");
                Console.WriteLine(id);
                request.PlaylistId = id;
                var response = request.Execute();

                YouTubeVideo[] videos = new YouTubeVideo[response.Items.Count];
                int            i      = 0;
                foreach (var item in response.Items)
                {
                    videos[i++] = new YouTubeVideo("http://www.youtube.com/watch?v=" + item.ContentDetails.VideoId, requester);
                }

                foreach (YouTubeVideo video in videos)
                {
                    queue.Enqueue(video);
                }
            }
            else
            {
                string[] lines = System.IO.File.ReadAllLines(@".\playlists\" + name + ".playlist");

                foreach (string line in lines)
                {
                    queue.Enqueue(YouTubeVideo.fromString(line));
                }
            }
            audioManager.setQueue(queue);
            audioManager.sendMessage("Playlist loaded!");
        }