Skip to content

Commit

Permalink
Version 2.4.0 changes
Browse files Browse the repository at this point in the history
- fixed error 4.03
- added CLI executable
  • Loading branch information
LordZero25 committed Oct 30, 2019
1 parent 13c0853 commit a78f1c0
Show file tree
Hide file tree
Showing 45 changed files with 3,238 additions and 173 deletions.
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
Binary file added .vs/Syosetu-Downloader/v16/.suo
Binary file not shown.
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
File renamed without changes.
33 changes: 31 additions & 2 deletions src/syosetuDownloader.sln
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "syosetuDownloader", "syosetuDownloader\syosetuDownloader.csproj", "{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "syosetuDownloaderCore", "syosetuDownloaderCore\syosetuDownloaderCore.csproj", "{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "syosetuDownloaderCLI", "syosetuDownloaderCLI\syosetuDownloaderCLI.csproj", "{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Debug|Any CPU.ActiveCfg = Debug|x86
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Debug|x86.ActiveCfg = Debug|x86
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Debug|x86.Build.0 = Debug|x86
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Release|Any CPU.ActiveCfg = Release|x86
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Release|x86.ActiveCfg = Release|x86
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Release|x86.Build.0 = Release|x86
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Debug|x86.ActiveCfg = Debug|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Debug|x86.Build.0 = Debug|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Release|Any CPU.Build.0 = Release|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Release|x86.ActiveCfg = Release|Any CPU
{EF69F9D8-07B1-4F10-966F-CF469E0D9BF8}.Release|x86.Build.0 = Release|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Debug|x86.ActiveCfg = Debug|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Debug|x86.Build.0 = Debug|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Release|Any CPU.Build.0 = Release|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Release|x86.ActiveCfg = Release|Any CPU
{10C85DDC-3B6F-45CE-BCC5-10137F1D4D5D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {02B2A898-0DED-420A-8687-42C243B9E2E4}
EndGlobalSection
EndGlobal
90 changes: 0 additions & 90 deletions src/syosetuDownloader/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,101 +14,11 @@ namespace syosetuDownloader
/// </summary>
public partial class App : Application
{
class Options
{
[Option('l', "link", HelpText = "URL to be processed")]
public string Link { get; set; }

[Option('s', "start", HelpText = "Stating chapter", DefaultValue = "1")]
public string Start { get; set; }

[Option('e', "end", HelpText = "Ending chapter")]
public string End { get; set; }

[Option('f', "format", HelpText = "File format (HTML | TXT)", DefaultValue = "TXT")]
public string Format { get; set; }

[Option('t', "toc", HelpText = "Generates Table of contents", DefaultValue = false)]
public bool ToC { get; set; }

[Option('h', "help")]
public bool Help { get; set; }
}

string GetFilenameFormat()
{
using (System.IO.StreamReader sr = new System.IO.StreamReader("format.ini"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (!line.StartsWith(";"))
{
return line;
}
}
}

return "";
}

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

Options o = new Options();
if (e.Args.Any())
{
/* do stuff without a GUI */
Parser.Default.ParseArguments(e.Args, o);

if (o.Help == true)
{
AttachConsole(-1);
Console.WriteLine(CommandLine.Text.HelpText.AutoBuild(o));
this.Shutdown();
return;
}

Syousetsu.Constants sc = new Syousetsu.Constants();
HtmlDocument toc = Syousetsu.Methods.GetTableOfContents(o.Link, sc.SyousetsuCookie);

sc.ChapterTitle.Add("");
sc.SeriesTitle = Syousetsu.Methods.GetTitle(toc);
sc.Link = o.Link;
sc.Start = o.Start;
sc.End = String.IsNullOrWhiteSpace(o.End) ? Syousetsu.Methods.GetTotalChapters(toc).ToString() : o.End;
sc.SeriesCode = Syousetsu.Methods.GetSeriesCode(o.Link);
sc.FilenameFormat = GetFilenameFormat();
Syousetsu.Methods.GetAllChapterTitles(sc, toc);
Syousetsu.Constants.FileType fileType = Syousetsu.Constants.FileType.Text;
switch (o.Format.ToUpper())
{
case "HTML": { fileType = Syousetsu.Constants.FileType.HTML; break; }
case "TXT": { fileType = Syousetsu.Constants.FileType.Text; break; }
default: { fileType = Syousetsu.Constants.FileType.Text; break; }
}
sc.CurrentFileType = fileType;
Syousetsu.Methods.GetAllChapterTitles(sc, toc);

if (o.ToC == true)
{
Syousetsu.Create.GenerateTableOfContents(sc, toc);
}

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
Syousetsu.Methods.AddDownloadJob(sc);
sw.Stop();

AttachConsole(-1);
Console.WriteLine(sw.Elapsed);

this.Shutdown();
}
}

[System.Runtime.InteropServices.DllImport("Kernel32.dll")]
public static extern bool AttachConsole(int processId);
}
}
144 changes: 70 additions & 74 deletions src/syosetuDownloader/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,86 +58,82 @@ private void btnDownload_Click(object sender, RoutedEventArgs e)

bool fromToValid = (System.Text.RegularExpressions.Regex.IsMatch(_start, @"^\d+$") || _start.Equals(String.Empty)) &&
(System.Text.RegularExpressions.Regex.IsMatch(_end, @"^\d+$") || _end.Equals(String.Empty));
if (_link != String.Empty && fromToValid)

if (String.IsNullOrWhiteSpace(_link) && fromToValid)
{
if (!_link.StartsWith("http")) { _link = @"http://" + _link; }
if (!_link.EndsWith("/")) { _link = _link + "/"; }
MessageBox.Show("Error parsing link and/or chapter range!", "", MessageBoxButton.OK, MessageBoxImage.Error);
}

if (Syousetsu.Methods.IsValidLink(_link))
{
Syousetsu.Constants sc = new Syousetsu.Constants();
sc.ChapterTitle.Add("");
HtmlDocument toc = Syousetsu.Methods.GetTableOfContents(_link, sc.SyousetsuCookie);
if (!_link.StartsWith("http")) { _link = @"http://" + _link; }
if (!_link.EndsWith("/")) { _link += "/"; }

if (Syousetsu.Methods.IsValid(toc))
{
GetFilenameFormat();
_row += 1;

Label lb = new Label();
lb.Content = Syousetsu.Methods.GetTitle(toc);
lb.ToolTip = "Click to open folder";

ProgressBar pb = new ProgressBar();
pb.Maximum = (_end == String.Empty) ? Syousetsu.Methods.GetTotalChapters(toc) : Convert.ToDouble(_end);
pb.ToolTip = "Click to stop download";
pb.Height = 10;

Separator s = new Separator();
s.Height = 5;

_start = (_start == String.Empty) ? "1" : _start;
_end = pb.Maximum.ToString();

sc.SeriesTitle = lb.Content.ToString();
sc.Link = _link;
sc.Start = _start;
sc.End = _end;
sc.CurrentFileType = _fileType;
sc.SeriesCode = Syousetsu.Methods.GetSeriesCode(_link);
sc.FilenameFormat = _format;
Syousetsu.Methods.GetAllChapterTitles(sc, toc);

if (chkList.IsChecked == true)
{
Syousetsu.Create.GenerateTableOfContents(sc, toc);
}

System.Threading.CancellationTokenSource ct = Syousetsu.Methods.AddDownloadJob(sc, pb);
pb.MouseDown += (snt, evt) =>
{
ct.Cancel();
pb.ToolTip = null;
};
lb.MouseDown += (snt, evt) =>
{
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), sc.SeriesTitle);
if (System.IO.Directory.Exists(path))
{
System.Diagnostics.Process.Start("explorer.exe", path);
}
};

stackPanel1.Children.Add(lb);
stackPanel1.Children.Add(pb);
stackPanel1.Children.Add(s);

_controls.Add(new Syousetsu.Controls { ID = _row, Label = lb, ProgressBar = pb, Separator = s });
}
else
{
MessageBox.Show("Link not valid!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
else
{
MessageBox.Show("Link not valid!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (!Syousetsu.Methods.IsValidLink(_link))
{
MessageBox.Show("Link not valid!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
else

Syousetsu.Constants sc = new Syousetsu.Constants();
sc.ChapterTitle.Add("");
HtmlDocument toc = Syousetsu.Methods.GetTableOfContents(_link, sc.SyousetsuCookie);

if (!Syousetsu.Methods.IsValid(toc))
{
MessageBox.Show("Error parsing link and/or chapter range!", "", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show("Link not valid!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}


GetFilenameFormat();
_row += 1;

Label lb = new Label();
lb.Content = Syousetsu.Methods.GetTitle(toc);
lb.ToolTip = "Click to open folder";

ProgressBar pb = new ProgressBar();
pb.Maximum = (_end == String.Empty) ? Syousetsu.Methods.GetTotalChapters(toc) : Convert.ToDouble(_end);
pb.ToolTip = "Click to stop download";
pb.Height = 10;

Separator s = new Separator();
s.Height = 5;

_start = (_start == String.Empty) ? "1" : _start;
_end = pb.Maximum.ToString();

sc.SeriesTitle = lb.Content.ToString();
sc.Link = _link;
sc.Start = _start;
sc.End = _end;
sc.CurrentFileType = _fileType;
sc.SeriesCode = Syousetsu.Methods.GetSeriesCode(_link);
sc.FilenameFormat = _format;
Syousetsu.Methods.GetAllChapterTitles(sc, toc);

if (chkList.IsChecked == true)
{
Syousetsu.Create.GenerateTableOfContents(sc, toc);
}

System.Threading.CancellationTokenSource ct = Syousetsu.Methods.AddDownloadJob(sc, pb);
pb.MouseDown += (snt, evt) =>
{
ct.Cancel();
pb.ToolTip = null;
};
lb.MouseDown += (snt, evt) =>
{
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), sc.SeriesTitle);
if (System.IO.Directory.Exists(path))
{
System.Diagnostics.Process.Start("explorer.exe", path);
}
};

stackPanel1.Children.Add(lb);
stackPanel1.Children.Add(pb);
stackPanel1.Children.Add(s);

_controls.Add(new Syousetsu.Controls { ID = _row, Label = lb, ProgressBar = pb, Separator = s });
}

private void rbText_Checked(object sender, RoutedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions src/syosetuDownloader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.4")]
[assembly: AssemblyFileVersion("2.3.4")]
[assembly: AssemblyVersion("2.4.0")]
[assembly: AssemblyFileVersion("2.4.0")]
8 changes: 6 additions & 2 deletions src/syosetuDownloader/syosetuDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Constants.cs" />
<Compile Include="Syousetsu.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -138,6 +136,12 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\syosetuDownloaderCore\syosetuDownloaderCore.csproj">
<Project>{ef69f9d8-07b1-4f10-966f-cf469e0d9bf8}</Project>
<Name>syosetuDownloaderCore</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Loading

0 comments on commit a78f1c0

Please sign in to comment.