Skip to content

Commit

Permalink
1. 变更Gelbooru站点自动提示获取方法
Browse files Browse the repository at this point in the history
2. 变更图片来源URL自动换行显示
3. 删除测试版本主窗口动画
4. 删除Gelbooru站点HTML解析冗余
  • Loading branch information
usaginya committed Jan 12, 2018
1 parent b27f9a1 commit 14f69b5
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion MoeLoaderDelta/Control/ImgControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ private void txtDesc_Click_6(object sender, RoutedEventArgs e)
//source
try
{
Clipboard.SetText(img.Source);
Clipboard.SetText(img.Source.Replace("\r\n", ""));
}
catch { }
}
Expand Down
12 changes: 6 additions & 6 deletions MoeLoaderDelta/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="ClosedStoryboard" Storyboard.TargetName="Window">
<!--<Storyboard x:Key="ClosedStoryboard" Storyboard.TargetName="Window">
<DoubleAnimation From="1" To="0" Duration="0:0:.1" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[1].Offset"/>
<DoubleAnimation From="1" To="0" Duration="0:0:.1" BeginTime="0:0:.1" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Offset"/>
<ColorAnimation To="#00000000" Duration="0" Storyboard.TargetProperty="OpacityMask.(GradientBrush.GradientStops)[2].Color"/>
Expand All @@ -872,7 +872,7 @@
<GradientStop Color="#FF000000" Offset="0"/>
<GradientStop Color="#FF000000" Offset="1"/>
<GradientStop Color="#FF000000" Offset="1"/>
</LinearGradientBrush>
</LinearGradientBrush>-->
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="txtSetting">
Expand All @@ -887,7 +887,7 @@
<EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="txtHelp">
<StopStoryboard BeginStoryboardName="OnMouseEnter3_BeginStoryboard" />
</EventTrigger>
<EventTrigger RoutedEvent="Loaded">
<!--<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
Expand All @@ -897,15 +897,15 @@
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</EventTrigger>-->
</Window.Triggers>
<Window.OpacityMask>
<!--<Window.OpacityMask>
<LinearGradientBrush StartPoint="1,1" EndPoint="0,0">
<GradientStop Color="#00000000" Offset="0"/>
<GradientStop Color="#00000000" Offset="1"/>
<GradientStop Color="#FF000000" Offset="1"/>
</LinearGradientBrush>
</Window.OpacityMask>
</Window.OpacityMask>-->
<Border
x:Name="containerB"
Background="WhiteSmoke"
Expand Down
5 changes: 3 additions & 2 deletions MoeLoaderDelta/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2275,10 +2275,11 @@ private void Max_Click(object sender, RoutedEventArgs e)

private void Close_Click(object sender, RoutedEventArgs e)
{
OpacityMask = Resources["ClosedBrush"] as LinearGradientBrush;
/* OpacityMask = Resources["ClosedBrush"] as LinearGradientBrush;
Storyboard std = Resources["ClosedStoryboard"] as Storyboard;
std.Completed += delegate { Close(); };
std.Begin();
std.Begin();*/
Close();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion MoeLoaderDelta/PreviewWnd.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ private void MenuItem_Click_3(object sender, RoutedEventArgs e)
{
try
{
Clipboard.SetText(descs[selectedId].Source);
Clipboard.SetText(descs[selectedId].Source.Replace("\n", ""));
}
catch (Exception) { }
}
Expand Down
19 changes: 9 additions & 10 deletions MoeSite/Img.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,20 @@ public class Img
/// <summary>
/// 图片来源
/// </summary>
public string Source { set; get; }
private string source;
public string Source
{
get { return StringLineBreak(HttpUtility.HtmlDecode(source), 64); }
set { source = value; }
}

private string desc;
/// <summary>
/// 图片描述
/// </summary>
private string desc;
public string Desc
{
get
{
return StringLineBreak(HttpUtility.HtmlDecode (desc), 64);
}
get { return StringLineBreak(HttpUtility.HtmlDecode(desc), 64); }
set { desc = value; }
}

Expand Down Expand Up @@ -132,10 +134,7 @@ public string Dimension
private string author;
public string Author
{
get
{
return HttpUtility.HtmlDecode(author);
}
get { return HttpUtility.HtmlDecode(author); }
set { author = value; }
}

Expand Down
4 changes: 2 additions & 2 deletions MoeSite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.2.5")]
[assembly: AssemblyFileVersion("1.3.2.5")]
[assembly: AssemblyVersion("1.3.2.6")]
[assembly: AssemblyFileVersion("1.3.2.6")]
4 changes: 2 additions & 2 deletions SitePack/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.4")]
[assembly: AssemblyFileVersion("1.0.5.4")]
[assembly: AssemblyVersion("1.0.5.5")]
[assembly: AssemblyFileVersion("1.0.5.5")]
39 changes: 24 additions & 15 deletions SitePack/SiteGelbooru.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
using HtmlAgilityPack;
using MoeLoaderDelta;
using System.Text.RegularExpressions;

using System.Web.Script.Serialization;

namespace SitePack
{
/// <summary>
/// Gelbooru.com
/// Fixed 171213
/// Fixed 180112
/// </summary>
class SiteGelbooru : AbstractImageSite
{
private bool APImode;
private SiteBooru booru;
//private SessionClient Sweb = new SessionClient();
private SessionClient Sweb = new SessionClient();
private SessionHeadersCollection shc = new SessionHeadersCollection();
public override string SiteUrl { get { return "https://gelbooru.com"; } }
public override string SiteName { get { return "gelbooru.com"; } }
public override string ShortName { get { return "gelbooru"; } }
Expand Down Expand Up @@ -50,13 +51,29 @@ public override string GetPageString(int page, int count, string keyWord, IWebPr
return pageString;
}

//tags https://gelbooru.com/index.php?page=tags&s=list&tags=kanto*
//tags https://gelbooru.com/index.php?page=autocomplete&term=don
/// <summary>
/// API only
/// JSON and API
/// </summary>
public override List<TagItem> GetTags(string word, IWebProxy proxy)
{
return booru.GetTags(word, proxy);
List<TagItem> re = new List<TagItem>();
try
{
string url = string.Format(SiteUrl + "/index.php?page=autocomplete&term={0}", word);
shc.Accept = SessionHeadersValue.AcceptAppJson;
url = Sweb.Get(url, proxy, "UTF-8", shc);

object[] jsonobj = (new JavaScriptSerializer()).DeserializeObject(url) as object[];

foreach (object o in jsonobj)
{
re.Add(new TagItem() { Name = o.ToString() });
}
}
catch { }

return re.Count > 0 ? re : booru.GetTags(word, proxy);
}

public override List<Img> GetImages(string pageString, IWebProxy proxy)
Expand Down Expand Up @@ -114,15 +131,7 @@ public override List<Img> GetImages(string pageString, IWebProxy proxy)
i.Author = n.InnerText.Substring(n.InnerText.LastIndexOf(' ') + 1, n.InnerText.Length - n.InnerText.LastIndexOf(' ') - 1);
if (n.InnerText.Contains("Source"))
i.Source = n.SelectSingleNode("//*[@rel=\"nofollow\"]").Attributes["href"].Value;
if (n.InnerText.Contains("Rating") && n.InnerText.Contains("Safe"))
i.IsExplicit = false;
else if (n.InnerText.Contains("Rating"))
i.IsExplicit = true;
if (n.InnerText.Contains("Rating") && n.InnerText.Contains("Safe"))
i.IsExplicit = false;
else if (n.InnerText.Contains("Rating"))
i.IsExplicit = true;

i.IsExplicit = !(n.InnerText.Contains("Rating") && n.InnerText.Contains("Safe"));
if (n.InnerText.Contains("Score"))
i.Score = Convert.ToInt32(n.SelectSingleNode("./span").InnerText);
if (n.InnerHtml.Contains("Original"))
Expand Down

0 comments on commit 14f69b5

Please sign in to comment.