Пример #1
0
        protected List <string> BaseDownloadSubtitle(DownloadingItem downloading)
        {
            // 更新状态显示
            downloading.DownloadStatusTitle = DictionaryResource.GetString("WhileDownloading");
            downloading.DownloadContent     = DictionaryResource.GetString("DownloadingSubtitle");
            // 下载大小
            downloading.DownloadingFileSize = string.Empty;
            // 下载速度
            downloading.SpeedDisplay = string.Empty;

            List <string> srtFiles = new List <string>();

            var subRipTexts = VideoStream.GetSubtitle(downloading.DownloadBase.Avid, downloading.DownloadBase.Bvid, downloading.DownloadBase.Cid);

            if (subRipTexts == null)
            {
                return(null);
            }

            foreach (var subRip in subRipTexts)
            {
                string srtFile = $"{downloading.DownloadBase.FilePath}_{subRip.LanDoc}.srt";
                try
                {
                    File.WriteAllText(srtFile, subRip.SrtString);

                    // 记录本次下载的文件
                    if (!downloading.Downloading.DownloadFiles.ContainsKey("subtitle"))
                    {
                        downloading.Downloading.DownloadFiles.Add("subtitle", srtFile);
                    }

                    srtFiles.Add(srtFile);
                }
                catch (Exception e)
                {
                    Core.Utils.Debugging.Console.PrintLine($"{Tag}.DownloadSubtitle()发生异常: {0}", e);
                    LogManager.Error($"{Tag}.DownloadSubtitle()", e);
                }
            }

            return(srtFiles);
        }