コード例 #1
0
 private static JArray GetColumns(VideoData vd)
 {
     return(new JArray
            (
                vd.DataDir.Name,
                vd.UID,
                vd.FilenameBase,
                vd.Title,
                vd.ShouldTranscodeAndCacheVideo().ToString(),
                vd.IsCachedVideo.ToString(),
                vd.IsCachedPreview.ToString(),
                vd.IsCachedThumbnail.ToString(),
                vd.ExternalOrderIndex?.ToString() ?? "(null)",
                vd.PathVideo,
                vd.PathJSON ?? "(null)",
                vd.PathTOML ?? "(null)",
                vd.PathThumbnail,
                vd.PathDescription ?? "(null)",
                string.Join("\n", vd.PathSubtitles),
                vd.CacheVideoFile ?? "(null)",
                vd.CachePreviewFile ?? "(null)",
                FilesizeUtil.BytesToString(vd.Filesize),
                (vd.CacheVideoSize == 0)     ? "" : FilesizeUtil.BytesToString(vd.CacheVideoSize),
                (vd.CachePreviewSize == 0)   ? "" : FilesizeUtil.BytesToString(vd.CachePreviewSize),
                (vd.CacheThumbnailSize == 0) ? "" : FilesizeUtil.BytesToString(vd.CacheThumbnailSize),
                vd.UploadDate ?? "(null)",
                vd.Duration?.ToString() ?? "(null)",
                vd.WebpageURL ?? "(null)",
                vd.Extractor ?? "(null)"
            ));
 }
コード例 #2
0
 private static JObject FormatBytes(long bytes)
 {
     return(new JObject
            (
                new JProperty("raw", bytes),
                new JProperty("type", "bytes"),
                new JProperty("format", FilesizeUtil.BytesToString(bytes))
            ));
 }
コード例 #3
0
        private static async Task <List <JObject> > ListCacheFiles()
        {
            var result = new List <JObject>();

            if (Program.Args.CacheDir == null)
            {
                return(result);
            }

            var vidcache = new List <VideoData>();

            foreach (var dd in Program.Args.DataDirs)
            {
                vidcache.AddRange((await Program.GetData(dd)).Videos.Values);
            }

            var di = new DirectoryInfo(Program.Args.CacheDir);

            foreach (var file in di.GetFiles().OrderBy(p => p.Name.ToLower()))
            {
                var linkPreviewFile   = vidcache.FirstOrDefault(p => DirectoryExtension.PathEquals(file.FullName, p.CachePreviewFile));
                var linkThumbnailFile = vidcache.FirstOrDefault(p => DirectoryExtension.PathEquals(file.FullName, p.CacheThumbnailFile));
                var linkVideoFile     = vidcache.FirstOrDefault(p => DirectoryExtension.PathEquals(file.FullName, p.CacheVideoFile));

                string linkType = null;
                if (linkPreviewFile != null)
                {
                    linkType = "preview";
                }
                if (linkThumbnailFile != null)
                {
                    linkType = "thumbnail";
                }
                if (linkVideoFile != null)
                {
                    linkType = "video";
                }

                var linkSource = linkVideoFile ?? linkThumbnailFile ?? linkPreviewFile;

                var o = new JObject
                        (
                    new JProperty("path", file.FullName),
                    new JProperty("filename", file.Name),
                    new JProperty("directory", file.DirectoryName),
                    new JProperty("readonly", file.IsReadOnly),
                    new JProperty("cdate", file.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")),
                    new JProperty("cdate_f", file.CreationTimeUtc.ToFileTimeUtc()),
                    new JProperty("mdate", file.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")),
                    new JProperty("mdate_f", file.LastWriteTimeUtc.ToFileTimeUtc()),
                    new JProperty("adate", file.LastAccessTime.ToString("yyyy-MM-dd HH:mm:ss")),
                    new JProperty("adate_f", file.LastAccessTimeUtc.ToFileTimeUtc()),
                    new JProperty("extension", file.Extension),
                    new JProperty("filesize_r", file.Length),
                    new JProperty("filesize", FilesizeUtil.BytesToString(file.Length)),
                    new JProperty("linktype", linkType),
                    new JProperty("isused", linkSource != null),
                    new JProperty("link_uid", linkSource?.UID),
                    new JProperty("link_title", linkSource?.Title),
                    new JProperty("link_pathvideo", linkSource?.PathVideo),
                    new JProperty("link_dirindex", linkSource?.DataDirIndex),
                    new JProperty("link_dirtile", linkSource?.DataDir.Name)
                        );
                result.Add(o);
            }

            return(result);
        }