/// <summary> /// return true if success. /// </summary> /// <returns></returns> public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source) { var client = JryVideoCore.Current.GetTheTVDBClient(); if (client == null) { return(false); } var role = (VideoRole)source; var tvdb = this.TheTVDBItem; if (tvdb != null && !tvdb.TheTVDBId.IsNullOrWhiteSpace()) { if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.TheTVDB, tvdb.TheTVDBId), role)) { return(true); } } var imdb = this.ImdbItem.GetValidImdbId(); if (imdb != null) { if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.Imdb, imdb), role)) { return(true); } } return(false); }
/// <summary> /// return true if success. /// </summary> /// <returns></returns> public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source) { var video = (JryVideoInfo)source; if (video.DoubanId == null) { return(false); } return(await Task.Run(async() => { var builder = CoverBuilder.CreateVideo(video); var requests = (await DoubanHelper.TryGetMovieInfoAsync(video.DoubanId))?.GetMovieCoverRequest().ToArray(); if (requests == null) { return false; } if (requests.Length == 0) { return false; } builder.Requests.AddRange(requests); return await this.manager.BuildCoverAsync(builder); })); }
public CoverBuilder(ICoverParent coverParent) { this.Id = coverParent.CoverId; if (this.Id == null) { throw new ArgumentNullException(); } }
private async void Manager_CoverParentRemoving(object sender, ICoverParent e) { var id = e.CoverId; if (id != null) { Debug.WriteLine($"remove cover [{id}] from {e.GetType().Name}[ {e.Id}] over {sender.GetType().Name}"); await this.RemoveAsync(id); } }
private void ConnectToCover(string rootObjectId, ICoverParent obj) { var coverId = obj.CoverId; if (coverId == null) { return; } CoverRef cover; if (this.covers.TryGetValue(coverId, out cover)) { cover.CoverParents.Add(new CoverParentRef(obj)); } }
/// <summary> /// return true if success. /// </summary> /// <param name="dataCenter"></param> /// <param name="source"></param> /// <returns></returns> public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source) { var client = JryVideoCore.Current.GetTheTVDBClient(); if (client == null) { return(false); } this.coverManager = dataCenter.CoverManager; return(await this.AutoGenerateCoverAsync(client, this.source.InfoView.Source) || await this.AutoGenerateCoverOverTheTVDBIdAsync(client, this.source.InfoView.SeriesView.Source.TheTVDBId, this.source.InfoView.Source.Index.ToString()) || await this.AutoGenerateCoverAsync(client, this.source.InfoView.SeriesView.Source)); }
/// <summary> /// return true if success. /// </summary> /// <param name="dataCenter"></param> /// <param name="source"></param> /// <returns></returns> public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source) { var item = (Artist)source; var doubanId = item.DoubanId; if (string.IsNullOrWhiteSpace(doubanId)) { return(false); } var info = await DoubanHelper.TryGetArtistInfoAsync(doubanId); if (info == null) { return(false); } var url = info.GetLargeImageUrl(); var coverBuilder = CoverBuilder.CreateArtist(item); coverBuilder.Uri.Add(url); return(await dataCenter.CoverManager.BuildCoverAsync(coverBuilder)); }
/// <summary> /// return true if success. /// </summary> /// <returns></returns> public async Task<bool> GenerateAsync(DataCenter dataCenter, ICoverParent source) { var client = JryVideoCore.Current.GetTheTVDBClient(); if (client == null) return false; var role = (VideoRole)source; var tvdb = this.TheTVDBItem; if (tvdb != null && !tvdb.TheTVDBId.IsNullOrWhiteSpace()) { if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.TheTVDB, tvdb.TheTVDBId), role)) { return true; } } var imdb = this.ImdbItem.GetValidImdbId(); if (imdb != null) { if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.Imdb, imdb), role)) { return true; } } return false; }
/// <summary> /// return true if success. /// </summary> /// <param name="dataCenter"></param> /// <param name="source"></param> /// <returns></returns> public async Task<bool> GenerateAsync(DataCenter dataCenter, ICoverParent source) { var client = JryVideoCore.Current.GetTheTVDBClient(); if (client == null) return false; this.coverManager = dataCenter.CoverManager; return await this.AutoGenerateCoverAsync(client, this.source.InfoView.Source) || await this.AutoGenerateCoverOverTheTVDBIdAsync(client, this.source.InfoView.SeriesView.Source.TheTVDBId, this.source.InfoView.Source.Index.ToString()) || await this.AutoGenerateCoverAsync(client, this.source.InfoView.SeriesView.Source); }
public CoverParentRef(ICoverParent obj) { this.Id = obj.Id; this.Type = obj.GetType().Name; }
private void ConnectToCover(string rootObjectId, ICoverParent obj) { var coverId = obj.CoverId; if (coverId == null) return; CoverRef cover; if (this.covers.TryGetValue(coverId, out cover)) { cover.CoverParents.Add(new CoverParentRef(obj)); } }
public static async Task <CoverEditorViewModel> FromAsync(CoverManager manager, ICoverParent coverParent) { var viewModel = new CoverEditorViewModel { coverId = coverParent.CoverId }; if (viewModel.coverId == null) // since cover id equal id, new object may contain null cover id. { throw new ArgumentNullException(); } else { var cover = await manager.FindAsync(viewModel.coverId); if (cover == null) { viewModel.CreateMode(); } else { viewModel.ModifyMode(cover); } } return(viewModel); }
public CoverBuilder(ICoverParent coverParent) { this.Id = coverParent.CoverId; if (this.Id == null) throw new ArgumentNullException(); }
protected void OnCoverParentRemoving(ICoverParent parent, object sender = null) => this.CoverParentRemoving?.Invoke(sender ?? this, parent);