public async Task SwitchCollectionType() { await Task.Run(() => { SetActivityResource(false, true); }); await Task.Run(() => { CurrentCollectionType = CurrentCollectionType == YoutubeVideoCollectionType.Playlist ? YoutubeVideoCollectionType.Channel : YoutubeVideoCollectionType.Playlist; if (CurrentCollectionType == YoutubeVideoCollectionType.Playlist) { PlaylistStyle = SelectedStyle; ChannelStyle = DefaultStyle; } else { PlaylistStyle = DefaultStyle; ChannelStyle = SelectedStyle; } YoutubeItems = YoutubeVideos?.Where(v => v.VideoCollectionType == CurrentCollectionType) .FirstOrDefault()?.YoutubeItems; }); SetActivityResource(); }
public static YoutubeVideos MostPopular(this YoutubeVideos videos) { var settings = videos.Settings.Clone(); settings.Chart = Chart.MostPopular; return(Videos(settings, videos.PartTypes.ToArray())); }
public HttpResponseMessage GetYouTubeVideos(bool?IsPaid, bool?Approved, int CustomerId, int PageIndex, int MaxCount) { var response = this.Request.CreateResponse(HttpStatusCode.OK); try { List <YoutubeVideos> list = new List <YoutubeVideos>(); var facebookPosts = _adCampaignService.GetYoutubeVideos(IsPaid, Approved, CustomerId, 0, int.MaxValue).ToList(); foreach (var fblink in facebookPosts) { YoutubeVideos fp = new YoutubeVideos(); fp.VideoLink = fblink.VideoLink; fp.CustomerId = fblink.CustomerId; fp.NoOfViews = fblink.NoOfViews; fp.IsPaid = fblink.IsPaid; fp.Approved = fblink.Approved; fp.Price = fblink.Price; fp.CreatedDate = fblink.CreatedDate; list.Add(fp); } return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "success", data = list })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "Some thing went wrong" })); } }
public static YoutubeVideos RequestId(this YoutubeVideos videos, params string[] ids) { var settings = videos.Settings.Clone(); settings.Id = settings.Id.AddItems(ids); return(Videos(settings, videos.PartTypes.ToArray())); }
public static YoutubeVideos RequestAllParts(this YoutubeVideos videos) { return(videos.RequestContentDetails() .RequestStatistics() .RequestStatus() .RequestLocalizations() .RequestPlayer() .RequestTopicDetails() .RequestRecordingDetails() .RequestLiveStreamingDetails() .RequestSnippet()); }
public YoutubeVideos AddUpdateYoutubeVideo(YoutubeVideos youtubeVideos) { if (youtubeVideos.Id > 0) { _youtubeRepository.Update(youtubeVideos); return(youtubeVideos); } else { youtubeVideos.CreatedDate = DateTime.Now; _youtubeRepository.Insert(youtubeVideos); return(youtubeVideos); } }
private async void PageLoad() { await Task.Run(() => { SetActivityResource(false, true); }); YoutubeConfiguration = new YoutubeConfiguration(); YoutubeConfiguration = await _youtubeDataServices.GetAsync(); if (YoutubeConfiguration == null) { SetActivityResource(); return; } CurrentCollectionType = YoutubeVideoCollectionType.Channel; PlaylistCollectionType = YoutubeVideoCollectionType.Playlist.ToCapital(); ChannelCollectionType = YoutubeVideoCollectionType.Channel.ToCapital(); foreach (var videoCollection in YoutubeConfiguration.YoutubeVideoCollection) { var videoCollectionIdApiUrl = ""; if (YoutubeVideoCollectionType.Channel == videoCollection.VideoCollectionType) { ChannelExists = !string.IsNullOrEmpty(videoCollection.VideoCollectionApiKey); videoCollectionIdApiUrl = string.Format(YoutubeConfiguration.VideoChannelApiUrl, videoCollection.VideoCollectionApiKey, YoutubeConfiguration.UserApiKey); } else if (YoutubeVideoCollectionType.Playlist == videoCollection.VideoCollectionType) { PlaylistExists = !string.IsNullOrEmpty(videoCollection.VideoCollectionApiKey); videoCollectionIdApiUrl = string.Format(YoutubeConfiguration.VideoPlaylistApiUrl, videoCollection.VideoCollectionApiKey, YoutubeConfiguration.UserApiKey); } var stringList = await GetVideoIdStringAsync(videoCollectionIdApiUrl, videoCollection.VideoCollectionType); var result = await GetVideosDetailsAsync(stringList, YoutubeConfiguration.VideoDetailApiUrl, YoutubeConfiguration.UserApiKey); YoutubeVideos.Add(new YoutubeVideo() { VideoCollectionType = videoCollection.VideoCollectionType, YoutubeItems = result }); } await SwitchCollectionType(); }
public HttpResponseMessage AddYoutTubeVideo(YoutubeVideos youtubeVideos) { var response = this.Request.CreateResponse(HttpStatusCode.OK); try { var customerguid = Request.Headers.GetValues("CustomerGUID").FirstOrDefault(); if (customerguid != null) { var cust = _customerService.GetCustomerByGuid(Guid.Parse(customerguid)); if (youtubeVideos.CustomerId != cust.Id) { return(Request.CreateResponse(HttpStatusCode.Unauthorized, new { code = 0, Message = "something went wrong" })); } } if (youtubeVideos.VideoLink == "") { return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "Invalid Url", data = "" })); } youtubeVideos.CustomerId = youtubeVideos.CustomerId; youtubeVideos.NoOfViews = 0; youtubeVideos.Price = 0; youtubeVideos.IsPaid = false; youtubeVideos.Deleted = false; youtubeVideos.CreatedDate = DateTime.Now; youtubeVideos.Approved = false; var youtubevideo = _adCampaignService.AddUpdateYoutubeVideo(youtubeVideos); var c = JsonConvert.SerializeObject(youtubevideo, new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }); return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "success", data = c })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { code = 0, Message = "Some thing went wrong" })); } }
public static YoutubeVideos RequestRecordingDetails(this YoutubeVideos videos) { return(videos.RequestPart(PartType.RecordingDetails)); }
public static YoutubeVideos RequestTopicDetails(this YoutubeVideos videos) { return(videos.RequestPart(PartType.TopicDetails)); }
public static IEnumerable <YoutubeVideo> TakePages(this YoutubeVideos videos, int pageCount) { return(videos.Take(videos.ResultsPerPage.GetValueOrDefault(ResultsPerPage) * pageCount)); }
public static YoutubeVideos RequestPlayer(this YoutubeVideos videos) { return(videos.RequestPart(PartType.Player)); }
public static YoutubeVideos RequestLocalizations(this YoutubeVideos videos) { return(videos.RequestPart(PartType.Localizations)); }
public static YoutubeVideos RequestStatus(this YoutubeVideos videos) { return(videos.RequestPart(PartType.Status)); }
public static YoutubeVideos RequestContentDetails(this YoutubeVideos videos) { return(videos.RequestPart(PartType.ContentDetails)); }
public static YoutubeVideos RequestPart(this YoutubeVideos videos, PartType partType) { return(Videos(videos.Settings.Clone(), videos.PartTypes.Append(partType).ToArray())); }
public static IEnumerable <YoutubeVideo> TakePage(this YoutubeVideos videos) { return(videos.TakePages(1)); }
public static YoutubeVideos RequestSnippet(this YoutubeVideos videos) { return(videos.RequestPart(PartType.Snippet)); }
public static YoutubeVideos RequestLiveStreamingDetails(this YoutubeVideos videos) { return(videos.RequestPart(PartType.LiveStreamingDetails)); }