Example #1
0
        public async Task CheckGettingPlaylistItems()
        {
            var manager = new YInfoRetriever();

            var fileProvaider = new JsonFileAuthProvider();

            fileProvaider.SetParams(@"D://client_secrets.json");

            manager.Authorize(fileProvaider).Wait();

            var sub = await manager.GetSubscriptions();

            if (!sub.Any())
            {
                return;
            }

            var channel = sub.First();

            var plList = await manager.GetPlayLists(channel.Snippet.ChannelId);

            if (!plList.Any())
            {
                return;
            }

            var pl = plList.First();

            var items = await manager.GetPlayListItems(pl.Id, CancellationToken.None);

            Assert.IsNotNull(items);
        }
Example #2
0
        /// <summary>
        ///     Connects to Youtube Auth 2.0 service
        /// </summary>
        private async Task Connect()
        {
            if (youRetriever.IsAuthorized)
            {
                youRetriever.Disconnect();
            }

            var keyReader = SimpleIoc.Default.GetInstance <IAuthProvider>();

            keyReader.SetParams(@"Resources/client_secrets.json");

            var result = await youRetriever.Authorize(keyReader);

            if (result)
            {
                Status      = "Authorizated succesfully";
                IsConnected = true;
                await GetSubscriptions();
            }
            else
            {
                Status      = "Authorizated failed";
                IsConnected = false;
            }
        }
Example #3
0
        public async Task CheckAuthorization_Succeed()
        {
            var manager = new YInfoRetriever();

            var fileProvaider = new JsonFileAuthProvider();

            fileProvaider.SetParams(@"D://client_secrets.json");

            await manager.Authorize(fileProvaider);

            Assert.IsTrue(manager.IsAuthorized);
        }
Example #4
0
        public async Task CheckGettingChannels()
        {
            var manager = new YInfoRetriever();

            var fileProvaider = new JsonFileAuthProvider();

            fileProvaider.SetParams(@"D://client_secrets.json");

            manager.Authorize(fileProvaider).Wait();

            var sub = await manager.GetSubscriptions();

            Assert.IsNotNull(sub);
        }
Example #5
0
        public async Task CheckIntersectionWithWatchedVideos()
        {
            var manager = new YInfoRetriever();

            var fileProvaider = new JsonFileAuthProvider();

            fileProvaider.SetParams(@"D://client_secrets.json");

            await manager.Authorize(fileProvaider);

            var sub = await manager.GetSubscriptions();

            if (!sub.Any())
            {
                return;
            }

            var channel = sub.First();

            var plList = await manager.GetPlayLists(channel.Snippet.ResourceId.ChannelId);

            if (!plList.Any())
            {
                return;
            }

            var pl = plList.First();

            var items = await manager.GetPlayListItems(pl.Id, CancellationToken.None);

            var me = await manager.GetOwnChannel();

            var watched = await manager.GetPlayListItems(me.ContentDetails.RelatedPlaylists.WatchHistory, CancellationToken.None);

            var someItersection = watched.Select(w => w.Snippet.ResourceId.VideoId).Intersect(items.Select(i => i.Snippet.ResourceId.VideoId));


            foreach (var item in someItersection)
            {
                Debug.Print(item);
            }
            Assert.IsTrue(someItersection.Any());
            Assert.IsNotNull(someItersection);
        }
Example #6
0
        public async void YInfoRetriever_Authorize_GetNull_ThrowEx()
        {
            Youtube.YInfoRetriever retriever = new YInfoRetriever();

            Assert.IsFalse(await retriever.Authorize(null));
        }
Example #7
0
        public async Task CheckAuthorization_Failed()
        {
            var manager = new YInfoRetriever();

            await manager.Authorize(null);
        }