All scraping code removed
This commit is contained in:
parent
c61bc27a7b
commit
df90fc5361
106 changed files with 666 additions and 5319 deletions
|
|
@ -4,6 +4,7 @@ namespace FileManager
|
|||
{
|
||||
public static class AudibleApiStorage
|
||||
{
|
||||
// not customizable. don't move to config
|
||||
public static string IdentityTokensFile => Path.Combine(Configuration.Instance.LibationFiles, "IdentityTokens.json");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,6 @@ namespace FileManager
|
|||
return File.Exists(path);
|
||||
}
|
||||
|
||||
/// <param name="proposedPath">acceptable inputs:
|
||||
/// example.txt
|
||||
/// C:\Users\username\Desktop\example.txt</param>
|
||||
/// <returns>Returns full name and path of unused filename. including (#)</returns>
|
||||
public static string GetValidFilename(string proposedPath)
|
||||
=> GetValidFilename(Path.GetDirectoryName(proposedPath), Path.GetFileNameWithoutExtension(proposedPath), Path.GetExtension(proposedPath));
|
||||
|
||||
public static string GetValidFilename(string dirFullPath, string filename, string extension, params string[] metadataSuffixes)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dirFullPath))
|
||||
|
|
@ -78,21 +71,6 @@ namespace FileManager
|
|||
return property;
|
||||
}
|
||||
|
||||
public static string Declaw(string str)
|
||||
=> str
|
||||
.Replace("<script", "<sxcript")
|
||||
.Replace(".net", ".nxet")
|
||||
.Replace(".com", ".cxom")
|
||||
.Replace("<link", "<lxink")
|
||||
.Replace("http", "hxttp");
|
||||
public static string RestoreDeclawed(string str)
|
||||
=> str
|
||||
?.Replace("<sxcript", "<script")
|
||||
.Replace(".nxet", ".net")
|
||||
.Replace(".cxom", ".com")
|
||||
.Replace("<lxink", "<link")
|
||||
.Replace("hxttp", "http");
|
||||
|
||||
public static string TitleCompressed(string title)
|
||||
=> new string(title
|
||||
.Where(c => (char.IsLetterOrDigit(c)))
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FileManager
|
||||
{
|
||||
public static class WebpageStorage
|
||||
{
|
||||
// not customizable. don't move to config
|
||||
private static string PagesDirectory { get; }
|
||||
= new DirectoryInfo(Configuration.Instance.LibationFiles).CreateSubdirectory("Pages").FullName;
|
||||
private static string BookDetailsDirectory { get; }
|
||||
= new DirectoryInfo(PagesDirectory).CreateSubdirectory("Book Details").FullName;
|
||||
|
||||
public static string GetLibraryBatchName() => "Library_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||
public static string SavePageToBatch(string contents, string batchName, string extension)
|
||||
{
|
||||
var batch_dir = Path.Combine(PagesDirectory, batchName);
|
||||
|
||||
Directory.CreateDirectory(batch_dir);
|
||||
|
||||
var file = Path.Combine(batch_dir, batchName + '.' + extension.Trim('.'));
|
||||
var filename = FileUtility.GetValidFilename(file);
|
||||
File.WriteAllText(filename, contents);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static List<FileInfo> GetJsonFiles(DirectoryInfo libDir)
|
||||
=> libDir == null
|
||||
? new List<FileInfo>()
|
||||
: Directory
|
||||
.EnumerateFiles(libDir.FullName, "*.json")
|
||||
.Select(f => new FileInfo(f))
|
||||
.ToList();
|
||||
|
||||
public static DirectoryInfo GetMostRecentLibraryDir()
|
||||
{
|
||||
var dir = Directory
|
||||
.EnumerateDirectories(PagesDirectory, "Library_*")
|
||||
.OrderBy(a => a)
|
||||
.LastOrDefault();
|
||||
if (string.IsNullOrWhiteSpace(dir))
|
||||
return null;
|
||||
return new DirectoryInfo(dir);
|
||||
}
|
||||
|
||||
public static FileInfo GetBookDetailHtmFileInfo(string productId)
|
||||
{
|
||||
var path = Path.Combine(BookDetailsDirectory, $"BookDetail-{productId}.htm");
|
||||
return new FileInfo(path);
|
||||
}
|
||||
|
||||
public static FileInfo GetBookDetailJsonFileInfo(string productId)
|
||||
{
|
||||
var path = Path.Combine(BookDetailsDirectory, $"BookDetail-{productId}.json");
|
||||
return new FileInfo(path);
|
||||
}
|
||||
|
||||
public static FileInfo SaveBookDetailsToHtm(string productId, string contents)
|
||||
{
|
||||
var fi = GetBookDetailHtmFileInfo(productId);
|
||||
File.WriteAllText(fi.FullName, contents);
|
||||
return fi;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue