Ejemplo n.º 1
0
        /// <summary>
        /// 复制媒体信息
        /// </summary>
        /// <returns>复制成功/失败</returns>
        protected async Task <bool> CopyMedia(CrawlStatistics single)
        {
            if (single == null)
            {
                return(false);
            }

            //找文件
            var sourcePath = single.MediaType == MediaTypeEnum.image ?
                             Directory.GetFiles(ImagePath, $"*{single.UrlMd5}*", SearchOption.TopDirectoryOnly).FirstOrDefault()
                : Directory.GetFiles(VideoPath, $"*{single.UrlMd5}*", SearchOption.TopDirectoryOnly).FirstOrDefault();

            if (!File.Exists(sourcePath))
            {
                return(false);
            }
            if (sourcePath.Contains(RootPath))
            {
                //重复文件跳过下载
                _logger.Log(LogLevel.Info, $"相同文件,跳过复制:{single.UrlMd5}");
                return(true);
            }
            //复制
            FileHelper.CopyFile(sourcePath, sourcePath, true);
            _logger.Log(LogLevel.Info, $"成功复制历史文件,跳过下载:{single.UrlMd5}");
            await single.UpdateSuccess(DownloadStatusEnum.Skip);

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 是否与历史重复
        /// </summary>
        /// <param name="single"></param>
        /// <returns></returns>
        protected async Task <bool> HasHistorySame(CrawlStatistics single)
        {
            var same = await single.FindHistorySameByMd5();

            if (same == null)
            {
                return(false);
            }
            _logger.Log(LogLevel.Info, $"有历史重复文件,跳过下载:{single.UrlMd5}");
            await single.UpdateSuccess(DownloadStatusEnum.Skip);

            return(true);
        }