Skip to content

Commit

Permalink
v1.0.7.7
Browse files Browse the repository at this point in the history
Fix Issue #37: Update image parser.
  • Loading branch information
Nandaka committed Dec 30, 2015
1 parent 65048c5 commit 3f6b8cd
Show file tree
Hide file tree
Showing 37 changed files with 485 additions and 219 deletions.
8 changes: 4 additions & 4 deletions Nandaka.Common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Nandaka.Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Nandaka.Common")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
[assembly: AssemblyCopyright("Copyright © Nandaka 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,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("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
[assembly: AssemblyVersion("1.0.0.3")]
[assembly: AssemblyFileVersion("1.0.0.3")]
18 changes: 16 additions & 2 deletions Nandaka.Common/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,30 @@ public static string ParseExtension(string url)
return url;
}

public static string FixUrl(string url, bool useHttps = false)
/// <summary>
/// Try to fix the url
/// </summary>
/// <param name="url"></param>
/// <param name="domain">used for relative url, use without protocol, e.g. www.example.com</param>
/// <param name="useHttps"></param>
/// <returns></returns>
public static string FixUrl(string url, string domain, bool useHttps = false)
{
if (String.IsNullOrWhiteSpace(url)) return url;
if (!url.StartsWith("http"))
if (url.StartsWith("//"))
{
if (useHttps)
url = "https:" + url;
else
url = "http:" + url;
}
if (url.StartsWith("/"))
{
if (useHttps)
url = "https://" + domain + url;
else
url = "http://" + domain + url;
}

return url;
}
Expand Down
9 changes: 9 additions & 0 deletions Nijie.Test/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="NijieDownloader.Test.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Nandaka.Common.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="NijieDownloader.Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
Expand Down Expand Up @@ -35,6 +36,14 @@
</DbProviderFactories>
</system.data>
<userSettings>
<NijieDownloader.Test.Properties.Settings>
<setting name="Username" serializeAs="String">
<value />
</setting>
<setting name="Password" serializeAs="String">
<value />
</setting>
</NijieDownloader.Test.Properties.Settings>
<Nandaka.Common.Properties.Settings>
<setting name="Timeout" serializeAs="String">
<value>60000</value>
Expand Down
9 changes: 9 additions & 0 deletions Nijie.Test/Nijie.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="UnitTest1.cs" />
<Compile Include="UpdateHtmlForm.cs">
<SubType>Form</SubType>
Expand All @@ -96,6 +101,10 @@
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="UpdateHtmlForm.resx">
Expand Down
4 changes: 2 additions & 2 deletions Nijie.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("NijieDownloader.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Infineon Technologies")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NijieDownloader.Test")]
[assembly: AssemblyCopyright("Copyright © Infineon Technologies 2014")]
[assembly: AssemblyCopyright("Copyright © Nandaka 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
50 changes: 50 additions & 0 deletions Nijie.Test/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Nijie.Test/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="NijieDownloader.Test.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="Username" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Password" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
35 changes: 31 additions & 4 deletions Nijie.Test/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -149,7 +150,7 @@ public void TestSearchParserMethod()
}

Assert.IsTrue(result.IsNextAvailable, "Next Page should be available");
Assert.AreEqual(159, result.TotalImages, "Different image count");
Assert.AreEqual(160, result.TotalImages, "Different image count");
}

{
Expand All @@ -167,7 +168,7 @@ public void TestSearchParserMethod()
}

Assert.IsTrue(result.IsNextAvailable, "Next Page should be available");
Assert.AreEqual(87, result.TotalImages, "Different image count");
Assert.AreEqual(88, result.TotalImages, "Different image count");
}

{
Expand All @@ -179,7 +180,7 @@ public void TestSearchParserMethod()
search.Option.Page = UpdateHtmlForm.search_tag_partial_latest_lastpage_page;

var result = nijie.ParseSearch(doc, search);
Assert.AreEqual(14, result.Images.Count, "Image counts differents");
Assert.AreEqual(15, result.Images.Count, "Image counts differents");

foreach (var image in result.Images)
{
Expand All @@ -188,7 +189,7 @@ public void TestSearchParserMethod()
}

Assert.IsFalse(result.IsNextAvailable, "Next Page should not be available");
Assert.AreEqual(159, result.TotalImages, "Different image count");
Assert.AreEqual(160, result.TotalImages, "Different image count");
}
}

Expand Down Expand Up @@ -235,6 +236,32 @@ public void TestImageParserMethod()
Assert.IsNotNull(item.ImageUrl, "Image url is missing!");
}
}
{
var page = UpdateHtmlForm.PATH + "image-manga-filter.html";
var ppage = UpdateHtmlForm.PATH + "image-manga-popup-filter.html";
Assert.IsTrue(File.Exists(page), "Test file is missing!");
Assert.IsTrue(File.Exists(ppage), "Test file is missing!");

HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(File.ReadAllText(page));
HtmlDocument pdoc = new HtmlDocument();
pdoc.LoadHtml(File.ReadAllText(ppage));

var image = new NijieImage(UpdateHtmlForm.MANGA2);

var result = nijie.ParseImage(image, ref nullMember, doc);
Assert.IsTrue(image.ImageId > 0, "Image Id not valid");
Assert.IsTrue(image.IsManga, "Image is not manga");
Assert.AreEqual(4, image.MangaPages.Count, "Manga pages count are different!");

Nijie.ParseImagePopUp(image, pdoc);
Assert.AreEqual(4, image.ImageUrls.Count, "Manga image urls count are different!");

foreach (var item in image.MangaPages)
{
Assert.IsNotNull(item.ImageUrl, "Image url is missing!");
}
}
{
var page = UpdateHtmlForm.PATH + "image-doujin.html";
var ppage = UpdateHtmlForm.PATH + "image-doujin-popup.html";
Expand Down
29 changes: 23 additions & 6 deletions Nijie.Test/UpdateHtmlForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions Nijie.Test/UpdateHtmlForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class UpdateHtmlForm : Form

public const int IMAGE = 92049;
public const int MANGA = 150508;
public const int MANGA2 = 151422;
public const int DOUJIN = 151004;

public UpdateHtmlForm()
Expand Down Expand Up @@ -130,17 +131,20 @@ private void btnUpdate_Click(object sender, EventArgs e)
txtLog.AppendText("Getting manga page..." + Environment.NewLine);
downloadHelper("https://nijie.info/view.php?id=" + MANGA, "image-manga.html");
downloadHelper("https://nijie.info/view_popup.php?id=" + MANGA, "image-manga-popup.html");
downloadHelper("https://nijie.info/view.php?id=" + MANGA2, "image-manga-filter.html");
downloadHelper("https://nijie.info/view_popup.php?id=" + MANGA2, "image-manga-popup-filter.html");

// doujin
txtLog.AppendText("Getting doujin page..." + Environment.NewLine);
downloadHelper("https://nijie.info/view.php?id=" + DOUJIN, "image-doujin.html");
downloadHelper("https://nijie.info/view_popup.php?id=" + DOUJIN, "image-doujin-popup.html");
}

this.DialogResult = System.Windows.Forms.DialogResult.OK;
Properties.Settings.Default.Save();
this.Close();
}
txtLog.AppendText("---====ALL DONE====---" + Environment.NewLine);

this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}

private string downloadHelper(string url, string filename, string referer = "https://nijie.info")
Expand All @@ -156,5 +160,17 @@ private string downloadHelper(string url, string filename, string referer = "htt
txtLog.AppendText(msg + Environment.NewLine);
return msg;
}

private void btnLogin_Click(object sender, EventArgs e)
{
txtLog.AppendText("Logging in..." + Environment.NewLine);
var result = nijie.Login(txtUser.Text, txtPass.Text);
if (result)
{
Properties.Settings.Default.Save();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
}
}
}
Loading

0 comments on commit 3f6b8cd

Please sign in to comment.