public static async Task <IChannel> GetChannelNetAsync(string channelID, SiteType site) { ChannelPOCO poco = null; try { switch (site) { case SiteType.YouTube: poco = await YouTubeSite.GetChannelFullNetAsync(channelID).ConfigureAwait(false); break; case SiteType.RuTracker: poco = await CommonFactory.CreateRutrackerSite().GetChannelNetAsync(channelID).ConfigureAwait(false); break; case SiteType.Tapochek: poco = await CommonFactory.CreateTapochekSite().GetChannelNetAsync(channelID).ConfigureAwait(false); break; } IChannel channel = CreateChannel(poco); return(channel); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static IChannel CreateChannel(ChannelPOCO poco, string dirPath = null) { SiteType site = poco.Site; IChannel channel = null; switch (site) { case SiteType.YouTube: channel = new YouChannel { ID = poco.ID, Title = poco.Title, SubTitle = poco.SubTitle, // .WordWrap(80); Thumbnail = poco.Thumbnail, CountNew = poco.Countnew, UseFast = poco.UseFast }; if (poco.Items != null) { foreach (VideoItemPOCO item in poco.Items) { channel.AddNewItem(VideoItemFactory.CreateVideoItem(item, site)); } } if (poco.Playlists != null) { foreach (PlaylistPOCO playlist in poco.Playlists) { channel.ChannelPlaylists.Add(PlaylistFactory.CreatePlaylist(playlist, site)); } } break; case SiteType.RuTracker: channel = null; break; case SiteType.Tapochek: channel = null; break; } if (channel == null) { throw new Exception(poco.ID); } if (dirPath != null) { channel.DirPath = dirPath; } channel.ChannelItemsCollectionView = CollectionViewSource.GetDefaultView(channel.ChannelItems); return(channel); }
public async Task GetFullChannel() { ChannelPOCO channel = await YouTubeSite.GetChannelFullNetAsync("UCeXeMXzjt21uv5tonZHtOrA").ConfigureAwait(false); int count = await YouTubeSite.GetChannelItemsCountNetAsync("UCeXeMXzjt21uv5tonZHtOrA").ConfigureAwait(false); Assert.IsTrue(channel.Items.Count == count); Assert.IsTrue(channel.Items.Any()); Assert.IsTrue(channel.Playlists.Any()); }
public async Task GetChannelNetAsync() { ChannelPOCO res = await YouTubeSite.GetChannelNetAsync("UCE27j85FZ8-aZOn6D8vWMWg").ConfigureAwait(false); Assert.AreEqual(res.Title, "Vlad RT"); }