示例#1
0
        public void ImportImageThumbnail(string path)
        {
            if (!DoesLibraryContain(currentBookTitle))
            {
                Debug.Log("Cannot add thumbnail to non-existent book " + currentBookTitle + ". Import book first.");
                return;
            }
            BookInfo bookInfo = BookInfoMapper.DeserializeInfo(currentBookTitle);

            bookInfo.thumbnailPath = path;

            string[] pathParts = path.Split('.');
            if (pathParts.Length < 2)
            {
                throw new InvalidBookFormatException("Invalid image format. Must include extension");
            }
            string ext = pathParts[pathParts.Length - 1];

            CopyOriginal(path, Config.Instance.BookLibraryPath + "/" + Config.Instance.ApplicationName + "/" +
                         currentBookTitle + "/" + currentBookTitle + "-thumb." + ext);

            string outputPath = Config.Instance.BookLibraryPath + "/" + Config.Instance.ApplicationName + "/" +
                                bookInfo.title + "/info.yaml";

            BookInfoMapper.SerializeInfo(outputPath, bookInfo);
        }
示例#2
0
        private void ImportDotText(string path)
        {
            string outputDir = GenerateDirs(path);
            string title     = GetTitleFromPath(path);

            BookInfoMapper.SerializeInfo(outputDir + "/info.yaml", BookFormat.TXT, path, title);
            CopyOriginal(path, outputDir + "/" + title + ".txt");
        }
示例#3
0
        private void ImportPdf(string path)
        {
            string outputDir = GenerateDirs(path);
            string title     = GetTitleFromPath(path);

            PdfConversion.ToJpegs(path, outputDir + "/" + "pages/");
            BookInfoMapper.SerializeInfo(outputDir + "/info.yaml", BookFormat.PDF, path, title);
            CopyOriginal(path, outputDir + "/" + title + ".pdf");
        }