Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Parsing hypster...");
            var playlist = new HypsterPlaylist(playlistLink);
            var youtube  = new Youtube();

            Task.Run(async() =>
            {
                Console.WriteLine("Signing into youtube...");
                await youtube.Login();
                Console.WriteLine("Uploading the playlist...");
                await youtube.InsertPlaylist(playlist, "hey");
            }).GetAwaiter().GetResult();

            Console.WriteLine("Done. Press any key to continue...");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public async Task InsertPlaylist(HypsterPlaylist playlist, string description = "", bool makePrivate = true)
        {
            var newPlaylist = new Playlist();

            newPlaylist.Snippet             = new PlaylistSnippet();
            newPlaylist.Snippet.Title       = playlist.Name;
            newPlaylist.Snippet.Description = description;
            newPlaylist.Status = new PlaylistStatus();
            newPlaylist.Status.PrivacyStatus = makePrivate ? "private" : "public";
            newPlaylist = await yt.Playlists.Insert(newPlaylist, "snippet,status").ExecuteAsync();

            foreach (var songId in playlist.SongIds)
            {
                var video = new PlaylistItem();
                video.Snippet                    = new PlaylistItemSnippet();
                video.Snippet.PlaylistId         = newPlaylist.Id;
                video.Snippet.ResourceId         = new ResourceId();
                video.Snippet.ResourceId.Kind    = "youtube#video";
                video.Snippet.ResourceId.VideoId = songId;
                video = await yt.PlaylistItems.Insert(video, "snippet").ExecuteAsync();

                Console.Write('.');
            }
        }