protected string BaseDownloadCover(DownloadingItem downloading, string coverUrl, string fileName) { // 更新状态显示 downloading.DownloadStatusTitle = DictionaryResource.GetString("WhileDownloading"); downloading.DownloadContent = DictionaryResource.GetString("DownloadingCover"); // 下载大小 downloading.DownloadingFileSize = string.Empty; // 下载速度 downloading.SpeedDisplay = string.Empty; // 查询、保存封面 StorageCover storageCover = new StorageCover(); string cover = storageCover.GetCover(downloading.DownloadBase.Avid, downloading.DownloadBase.Bvid, downloading.DownloadBase.Cid, coverUrl); if (cover == null) { return(null); } // 复制图片到指定位置 try { File.Copy(cover, fileName, true); // 记录本次下载的文件 if (!downloading.Downloading.DownloadFiles.ContainsKey(coverUrl)) { downloading.Downloading.DownloadFiles.Add(coverUrl, fileName); } return(fileName); } catch (Exception e) { Core.Utils.Debugging.Console.PrintLine($"{Tag}.DownloadCover()发生异常: {0}", e); LogManager.Error($"{Tag}.DownloadCover()", e); } return(null); }
/// <summary> /// 获取视频信息 /// </summary> /// <returns></returns> public VideoInfoView GetVideoView() { if (cheeseView == null) { return(null); } // 查询、保存封面 // 将SeasonId保存到avid字段中 // 每集封面的cid保存到cid字段,EpisodeId保存到bvid字段中 StorageCover storageCover = new StorageCover(); string coverUrl = cheeseView.Cover; string cover = storageCover.GetCover(cheeseView.SeasonId, "cheese", -1, coverUrl); // 获取用户头像 string upName; string header; if (cheeseView.UpInfo != null) { upName = cheeseView.UpInfo.Name; StorageHeader storageHeader = new StorageHeader(); header = storageHeader.GetHeader(cheeseView.UpInfo.Mid, cheeseView.UpInfo.Name, cheeseView.UpInfo.Avatar); } else { upName = ""; header = null; } // 为videoInfoView赋值 VideoInfoView videoInfoView = new VideoInfoView(); App.PropertyChangeAsync(new Action(() => { videoInfoView.CoverUrl = coverUrl; videoInfoView.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); videoInfoView.Title = cheeseView.Title; // 分区id // 课堂的type id B站没有定义,这里自定义为-10 videoInfoView.TypeId = -10; videoInfoView.VideoZone = DictionaryResource.GetString("Cheese"); videoInfoView.CreateTime = ""; videoInfoView.PlayNumber = Format.FormatNumber(cheeseView.Stat.Play); videoInfoView.DanmakuNumber = Format.FormatNumber(0); videoInfoView.LikeNumber = Format.FormatNumber(0); videoInfoView.CoinNumber = Format.FormatNumber(0); videoInfoView.FavoriteNumber = Format.FormatNumber(0); videoInfoView.ShareNumber = Format.FormatNumber(0); videoInfoView.ReplyNumber = Format.FormatNumber(0); videoInfoView.Description = cheeseView.Subtitle; videoInfoView.UpName = upName; if (header != null) { StorageHeader storageHeader = new StorageHeader(); videoInfoView.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); videoInfoView.UpperMid = cheeseView.UpInfo.Mid; } else { videoInfoView.UpHeader = null; } })); return(videoInfoView); }
/// <summary> /// 获取视频信息 /// </summary> /// <returns></returns> public VideoInfoView GetVideoView() { if (bangumiSeason == null) { return(null); } // 查询、保存封面 // 将SeasonId保存到avid字段中 // 每集封面的cid保存到cid字段,EpisodeId保存到bvid字段中 StorageCover storageCover = new StorageCover(); string coverUrl = bangumiSeason.Cover; string cover = storageCover.GetCover(bangumiSeason.SeasonId, "bangumi", -1, coverUrl); // 获取用户头像 string upName; string header; if (bangumiSeason.UpInfo != null) { upName = bangumiSeason.UpInfo.Name; StorageHeader storageHeader = new StorageHeader(); header = storageHeader.GetHeader(bangumiSeason.UpInfo.Mid, bangumiSeason.UpInfo.Name, bangumiSeason.UpInfo.Avatar); } else { upName = ""; header = null; } // 为videoInfoView赋值 VideoInfoView videoInfoView = new VideoInfoView(); App.PropertyChangeAsync(new Action(() => { videoInfoView.CoverUrl = coverUrl; videoInfoView.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); videoInfoView.Title = bangumiSeason.Title; // 分区id videoInfoView.TypeId = BangumiType.TypeId[bangumiSeason.Type]; videoInfoView.VideoZone = DictionaryResource.GetString(BangumiType.Type[bangumiSeason.Type]); videoInfoView.PlayNumber = Format.FormatNumber(bangumiSeason.Stat.Views); videoInfoView.DanmakuNumber = Format.FormatNumber(bangumiSeason.Stat.Danmakus); videoInfoView.LikeNumber = Format.FormatNumber(bangumiSeason.Stat.Likes); videoInfoView.CoinNumber = Format.FormatNumber(bangumiSeason.Stat.Coins); videoInfoView.FavoriteNumber = Format.FormatNumber(bangumiSeason.Stat.Favorites); videoInfoView.ShareNumber = Format.FormatNumber(bangumiSeason.Stat.Share); videoInfoView.ReplyNumber = Format.FormatNumber(bangumiSeason.Stat.Reply); videoInfoView.Description = bangumiSeason.Evaluate; videoInfoView.UpName = upName; if (header != null) { StorageHeader storageHeader = new StorageHeader(); videoInfoView.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); videoInfoView.UpperMid = bangumiSeason.UpInfo.Mid; } else { videoInfoView.UpHeader = null; } })); return(videoInfoView); }
/// <summary> /// 获取视频信息 /// </summary> /// <returns></returns> public VideoInfoView GetVideoView() { if (videoView == null) { return(null); } // 查询、保存封面 StorageCover storageCover = new StorageCover(); string coverUrl = videoView.Pic; string cover = storageCover.GetCover(videoView.Aid, videoView.Bvid, videoView.Cid, coverUrl); // 分区 string videoZone = string.Empty; var zoneList = Core.BiliApi.Zone.VideoZone.Instance().GetZones(); var zone = zoneList.Find(it => it.Id == videoView.Tid); if (zone != null) { var zoneParent = zoneList.Find(it => it.Id == zone.ParentId); if (zoneParent != null) { videoZone = zoneParent.Name + ">" + zone.Name; } else { videoZone = zone.Name; } } else { videoZone = videoView.Tname; } // 获取用户头像 string upName; string header; if (videoView.Owner != null) { upName = videoView.Owner.Name; StorageHeader storageHeader = new StorageHeader(); header = storageHeader.GetHeader(videoView.Owner.Mid, videoView.Owner.Name, videoView.Owner.Face); } else { upName = ""; header = null; } // 为videoInfoView赋值 VideoInfoView videoInfoView = new VideoInfoView(); App.PropertyChangeAsync(new Action(() => { videoInfoView.CoverUrl = coverUrl; videoInfoView.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); videoInfoView.Title = videoView.Title; // 分区id videoInfoView.TypeId = videoView.Tid; videoInfoView.VideoZone = videoZone; DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区 DateTime dateTime = startTime.AddSeconds(videoView.Pubdate); videoInfoView.CreateTime = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); videoInfoView.PlayNumber = Format.FormatNumber(videoView.Stat.View); videoInfoView.DanmakuNumber = Format.FormatNumber(videoView.Stat.Danmaku); videoInfoView.LikeNumber = Format.FormatNumber(videoView.Stat.Like); videoInfoView.CoinNumber = Format.FormatNumber(videoView.Stat.Coin); videoInfoView.FavoriteNumber = Format.FormatNumber(videoView.Stat.Favorite); videoInfoView.ShareNumber = Format.FormatNumber(videoView.Stat.Share); videoInfoView.ReplyNumber = Format.FormatNumber(videoView.Stat.Reply); videoInfoView.Description = videoView.Desc; videoInfoView.UpName = upName; if (header != null) { StorageHeader storageHeader = new StorageHeader(); videoInfoView.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); videoInfoView.UpperMid = videoView.Owner.Mid; } else { videoInfoView.UpHeader = null; } })); return(videoInfoView); }