Skip to content
This repository has been archived by the owner on Jul 29, 2018. It is now read-only.

Commit

Permalink
Smaller .mobi & one chapter
Browse files Browse the repository at this point in the history
-To make smaller .mobi file by using -dont_append_source in kindlegen.exe.
-issues #1
  • Loading branch information
ludoux committed Oct 13, 2017
1 parent 6eb8859 commit 28165c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
6 changes: 3 additions & 3 deletions DuduSpider/KindleGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public void MakePeriodical()
makeNcxFile();
LogWriter.WriteLine("Start making .mobi File!");
if (makeMobiFile())
LogWriter.WriteLine("Mobi file: " + Math.Ceiling(new System.IO.FileInfo(@"files\" + title + ".mobi").Length / 1048576.0) + " MByte\r\nAll things have been done successfully!");
LogWriter.WriteLine("Mobi file: " + Math.Ceiling(new System.IO.FileInfo(@"files\" + title + ".mobi").Length / 1048576.0) + " MByte.");
else
LogWriter.WriteLine("Ops...There must be something wrong...");
LogWriter.WriteLine("Error: Failed to make mobi file.");
}
private void makeOpfFile()
{
Expand Down Expand Up @@ -199,7 +199,7 @@ private void makeContentsFile()
private bool makeMobiFile()
{

System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("kindlegen.exe", Environment.CurrentDirectory + @"\files\" + title + ".opf -c2 -locale en");
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("kindlegen.exe", "-dont_append_source " + Environment.CurrentDirectory + @"\files\" + title + ".opf -c2 -locale en");
psi.StandardErrorEncoding = Encoding.UTF8;
psi.StandardOutputEncoding = Encoding.UTF8;
psi.RedirectStandardOutput = true;
Expand Down
16 changes: 4 additions & 12 deletions DuduSpider/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Program

static void Main(string[] args)
{
LogWriter.WriteLine("======Program Start!!!======");
LogWriter.WriteLine(Environment.NewLine + "======Program Start!!!======[" + Environment.CurrentDirectory);
string authorization;
List<Uri> allowedUrlHost = new List<Uri> { new Uri("http://mp.weixin.qq.com") };
if (args.Length != 2)
Expand All @@ -30,7 +30,6 @@ static void Main(string[] args)
update(authorization, allowedUrlHost);
else if (args[0].ToLower() == "-l")
lastTime(authorization, allowedUrlHost);
Console.ReadKey();
LogWriter.WriteLine("======Program Exit!!!======");
}
private static void firstTime(string authorization, List<Uri> allowedUrlHost)
Expand Down Expand Up @@ -88,21 +87,14 @@ private static void lastTime(string authorization, List<Uri> allowedUrlHost)
isStoryLine = !isStoryLine;
}
int i = 0;
List<int> home = new List<int>(), hot = new List<int>();
List<int> c = new List<int>();
foreach (Story.Manifestx mx in m)
{
if (mx._storyManifest[2] == "首页流")
home.Add(i);
else if (mx._storyManifest[2] == "热门流")
hot.Add(i);
c.Add(i);
i++;
}
int[] j = new int[m.Count];
for (int k = 0; k < m.Count; k++)
j[k] = k;
List<object[]> contents = new List<object[]>();//{string contentLabel, List<int> i}每一个 object[] 为一个目录, i 为在 list 中的位置,从 0 算起
contents.Add(new object[] { "首页流", home });
contents.Add(new object[] { "热门流", hot });
contents.Add(new object[] { "", c });//见 https://github.com/ludoux/DuduSpider/issues/1
new KindleGen(m, "DuduSpider", "zh-cn", "ludoux", "ludoux", "Daily", DateTime.Now.Date.ToString("yyyy-MM-dd"), "Daily", contents).MakePeriodical();
}
private static void fetch(string authorization, List<Cell> oldHomeTimeline, List<Cell> oldHotStories, List<Uri> allowedUrlHost)
Expand Down

0 comments on commit 28165c5

Please sign in to comment.