Пример #1
0
        public void getBookFromFlibusta(int element)
        {
            string[] bookDetails = System.IO.File.ReadLines(_toReadFlibusta.FullName).Skip(element).First().Split(";".ToCharArray());
            //string author = (bookDetails[0] + " " + bookDetails[1] + " " + bookDetails[2]).Trim(" ".ToCharArray());
            long id = long.Parse(bookDetails[bookDetails.Length - 1]);

            ProxifiedConnection pc = new ProxifiedConnection();

            pc.DownloadFile(id);
        }
Пример #2
0
        public string archiveBook(BookMetaData bookInfo)
        {
            var gdPath = Environment.GetFolderPath(
                Environment.SpecialFolder.UserProfile) + @"\Google Диск\Book Archive\";
            var gdFileName = bookInfo.dbRow.Split("[".ToCharArray())[0].Trim(" ".ToCharArray());

            foreach (char c in Path.GetInvalidFileNameChars())
            {
                gdFileName = gdFileName.Replace(c, "."[0]);
            }
            if (bookInfo.file == null)
            {
                var pc = new ProxifiedConnection();
                bookInfo.file = new FileInfo(pc.DownloadFile(bookInfo.bookId));
            }

            System.IO.File.Copy(bookInfo.file.FullName, gdPath + gdFileName + bookInfo.file.Extension);
            return(bookInfo.file.FullName);
        }
Пример #3
0
        public override bool run()
        {
            if (_commandLine.Length == 2)
            {
                int.TryParse(_commandLine[1], out _bookIndex);
                int local    = _fs.isLibraryFound() ? _fs.LocalBoksCount : 0;
                int web      = _fs.isWebLibraryAvailable() ? _fs.WebBooksCount : 0;
                int flibusta = _fs.FlibustaBooksCount;

                if (local + web + flibusta == 0)
                {
                    return(true);
                }

                var bookNums = getRandomSequence(_bookIndex, local + web + flibusta);

                foreach (var element in bookNums)
                {
                    if (element < local)
                    {
                        _fs.getBookFromLocalLibrary(element);
                    }
                    else if (element < local + web)
                    {
                        _fs.getBookFromOnlineLibrary(element - local);
                    }
                    else
                    {
                        _fs.getBookFromFlibusta(element - local - web);
                    }
                }
            }
            else if (_commandLine.Length == 3)
            {
                int.TryParse(_commandLine[2], out _bookIndex);
                var pc = new ProxifiedConnection();
                pc.DownloadFile(_bookIndex);
            }
            return(true);
        }