-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
31 changed files
with
1,609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "syosetuDownloader", "syosetuDownloader\syosetuDownloader.csproj", "{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x86 = Debug|x86 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{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|x86.ActiveCfg = Release|x86 | ||
{3D9382A0-5AC7-4D1C-B108-E5DF390151DD}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Application x:Class="syosetuDownloader.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Windows; | ||
|
||
namespace syosetuDownloader | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Controls; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Text.RegularExpressions; | ||
using HtmlAgilityPack; | ||
using System.Net; | ||
|
||
namespace Syousetsu | ||
{ | ||
public class Controls | ||
{ | ||
public int ID { get; set; } | ||
public Label Label { get; set; } | ||
public ProgressBar ProgressBar { get; set; } | ||
public Separator Separator { get; set; } | ||
} | ||
|
||
public class Constants | ||
{ | ||
public enum FileType { Text, HTML }; | ||
private CookieContainer _cookies = new CookieContainer(); | ||
string _title = String.Empty; | ||
string _start = String.Empty; | ||
string _end = String.Empty; | ||
FileType _fileType; | ||
string _path = String.Empty; | ||
string _link = String.Empty; | ||
string _seriesCode = String.Empty; | ||
|
||
public CookieContainer SyousetsuCookie | ||
{ | ||
get | ||
{ | ||
Cookie c = new System.Net.Cookie(); | ||
c.Domain = ".syosetu.com"; | ||
c.Value = "yes"; | ||
c.Name = "over18"; | ||
|
||
_cookies.Add(c); | ||
return _cookies; | ||
} | ||
} | ||
|
||
public string Title | ||
{ | ||
get { return _title; } | ||
set { _title = value; } | ||
} | ||
|
||
public string Start | ||
{ | ||
get { return _start; } | ||
set { _start = value; } | ||
} | ||
|
||
public string End | ||
{ | ||
get { return _end; } | ||
set { _end = value; } | ||
} | ||
|
||
|
||
public FileType CurrentFileType | ||
{ | ||
get { return _fileType; } | ||
set { _fileType = value; } | ||
} | ||
|
||
public string Path | ||
{ | ||
get { return _path; } | ||
set { _path = value; } | ||
} | ||
|
||
public string Link | ||
{ | ||
get { return _link; } | ||
set { _link = value; } | ||
} | ||
|
||
public string SeriesCode | ||
{ | ||
get { return _seriesCode; } | ||
set { _seriesCode = value; } | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Window x:Class="syosetuDownloader.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
Title="Narou Downloader" ResizeMode="CanMinimize" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="501" d:DesignWidth="317" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"> | ||
<Grid> | ||
<Label Content="Link:" Height="28" HorizontalAlignment="Left" Name="lblLink" VerticalAlignment="Top" Margin="26,5,0,0" /> | ||
<TextBox Height="23" HorizontalAlignment="Left" Name="txtLink" VerticalAlignment="Top" Width="197" Margin="66,5,0,0" /> | ||
<Label Content="From chapters" Height="28" HorizontalAlignment="Left" Margin="26,34,0,0" Name="label1" VerticalAlignment="Top" /> | ||
<TextBox Height="23" HorizontalAlignment="Left" Margin="118,34,0,0" Name="txtFrom" VerticalAlignment="Top" Width="50" /> | ||
<Label Content="To" Height="28" HorizontalAlignment="Left" Margin="180,34,0,0" Name="label2" VerticalAlignment="Top" /> | ||
<TextBox Height="23" HorizontalAlignment="Left" Margin="213,34,0,0" Name="txtTo" VerticalAlignment="Top" Width="50" /> | ||
<GroupBox Header="File Type" Height="61" HorizontalAlignment="Center" Name="groupBox1" VerticalAlignment="Top" Width="237" Margin="29,66,29,0"> | ||
<Grid> | ||
<RadioButton Content="Text" Height="16" HorizontalAlignment="Center" Name="rbText" VerticalAlignment="Top" Margin="67,11,117,0" IsChecked="True" Checked="rbText_Checked" /> | ||
<RadioButton Content="HTML" Height="16" HorizontalAlignment="Center" Name="rbHtml" VerticalAlignment="Top" Margin="114,11,60,0" Checked="rbHtml_Checked" /> | ||
</Grid> | ||
</GroupBox> | ||
<Button Content="Download" Height="23" HorizontalAlignment="Center" Name="btnDownload" VerticalAlignment="Top" Width="107" Margin="94,138,94,0" Click="btnDownload_Click" /> | ||
<ScrollViewer Height="255" HorizontalAlignment="Left" Margin="0,167,0,0" Name="scrollViewer1" VerticalAlignment="Top" Width="295" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> | ||
<StackPanel Name="stackPanel1" /> | ||
</ScrollViewer> | ||
<Button Content="Delete Completed" Height="23" HorizontalAlignment="Center" Name="btnDelete" VerticalAlignment="Bottom" Width="103" Margin="96,0,96,10" Click="btnDelete_Click" /> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
using System.Net; | ||
using HtmlAgilityPack; | ||
|
||
namespace syosetuDownloader | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
int _row = 0; | ||
string _link = String.Empty; | ||
string _start = String.Empty; | ||
string _end = String.Empty; | ||
Syousetsu.Constants.FileType _fileType; | ||
List<Syousetsu.Controls> _controls = new List<Syousetsu.Controls>(); | ||
|
||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void btnDownload_Click(object sender, RoutedEventArgs e) | ||
{ | ||
_row += 1; | ||
|
||
this._link = txtLink.Text; | ||
this._start = txtFrom.Text; | ||
this._end = txtTo.Text; | ||
|
||
if (_link != String.Empty) | ||
{ | ||
if (!_link.StartsWith("http")) { _link = @"http://" + _link; } | ||
if (!_link.EndsWith("/")) { _link = _link + "/"; } | ||
|
||
HtmlDocument toc = Syousetsu.Methods.GetTableOfContents(_link); | ||
if (Syousetsu.Methods.IsValidLink(_link) && | ||
Syousetsu.Methods.IsValid(toc)) | ||
{ | ||
Label lb = new Label(); | ||
lb.Content = Syousetsu.Methods.GetTitle(toc); | ||
lb.ToolTip = "Click to open folder"; | ||
|
||
ProgressBar pb = new ProgressBar(); | ||
pb.Maximum = Syousetsu.Methods.GetTotalChapters(toc); | ||
pb.ToolTip = "Click to stop download"; | ||
pb.Height = 10; | ||
|
||
Separator s = new Separator(); | ||
s.Height = 5; | ||
|
||
Syousetsu.Constants sc = new Syousetsu.Constants(); | ||
sc.Title = lb.Content.ToString(); | ||
sc.Link = _link; | ||
sc.Start = _start; | ||
sc.End = _end; | ||
sc.CurrentFileType = _fileType; | ||
sc.SeriesCode = Syousetsu.Methods.GetSeriesCode(_link); | ||
|
||
System.Threading.CancellationTokenSource ct = Syousetsu.Methods.AddDownloadJob(sc, pb); | ||
pb.MouseDown += (snt, evt) => | ||
{ | ||
ct.Cancel(); | ||
pb.ToolTip = ""; | ||
}; | ||
lb.MouseDown += (snt, evt) => | ||
{ | ||
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), sc.Title); | ||
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) | ||
{ | ||
_fileType = Syousetsu.Constants.FileType.Text; | ||
} | ||
|
||
private void rbHtml_Checked(object sender, RoutedEventArgs e) | ||
{ | ||
_fileType = Syousetsu.Constants.FileType.HTML; | ||
} | ||
|
||
private void btnDelete_Click(object sender, RoutedEventArgs e) | ||
{ | ||
_controls.Where((c) => c.ProgressBar.Value == c.ProgressBar.Maximum).ToList().ForEach((c) => | ||
{ | ||
stackPanel1.Children.Remove(c.Label); | ||
stackPanel1.Children.Remove(c.ProgressBar); | ||
stackPanel1.Children.Remove(c.Separator); | ||
}); | ||
|
||
_controls = (from c in _controls | ||
where c.ProgressBar.Value != c.ProgressBar.Maximum | ||
select c).ToList(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Windows; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("syosetuDownloader")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("syosetuDownloader")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
//In order to begin building localizable applications, set | ||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file | ||
//inside a <PropertyGroup>. For example, if you are using US english | ||
//in your source files, set the <UICulture> to en-US. Then uncomment | ||
//the NeutralResourceLanguage attribute below. Update the "en-US" in | ||
//the line below to match the UICulture setting in the project file. | ||
|
||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] | ||
|
||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] | ||
|
||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// 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("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.