Skip to content

Commit

Permalink
1.1.3 -> 1.1.4 第2次更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Apr 10, 2022
1 parent 8e492f1 commit 9abd11f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Commons/Define.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static class Define
#region URL 的正则表达式 (URL_REGEX)
internal const string URI_REGEX = @"^(((ht|f)tp(s?))\://)?" +
@"([a-zA-Z].)[a-zA-Z0-9\-\.]+\.(" +
@"com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|cc|int|arpa|asia|pro|coop|aero|tv|top|xin|xyz|vip|cn|mobi|ru|de|pl|eu|io|jp|club|au|post|me|guru|expert|tw|mo|hk|fr|ar|pk|mv|in|it|ws|sh|my|cd|ac|li|co|cm|win|red|rec|travel|wang|ch|dj|er|ee|es|is|kr|mm|mn|no|ne|to|tr|za|ml|ga|xxx|porn|adult|cyou|buzz|monster|icu|shop|best|site|live|online|pw|cloud|website|life|store|fun|app|today|uno|space|world|one|link|work|email|nl|trade|bid|stream|men|art|party|date|dev|tech|church|rocks|digital|download|moe|agency|network|click|fail|news|cool|vegas|blog|review|company|la|design|services|golf|exposed|team|ltd|help|zone|loan|wtf|media|solutions|games|directory|center|care|fyi|group|ooo|science|systems|works|city|pet|run|tips|studio|guide|cash|at|support|ninja|plus|rip|marketing|vin|reisen|tools|finance|immo|wiki|viajes|global|mx|promo|recipes|photos|academy|dog|pink|money|chat|casa|cafe|ink|foundation|faith|webcam|house|technology|photography|video|blue|farm|codes|realty|tel|land|show|business|international|social|sbs|skin|page|london|health|hiv|bond|vote|autos|rest|limo|hospital|gay|bar|game|fans|ph|study|cooking|glass|place|rent|shoes|tires|wedding|cab|camp|beer|menu|movie|fish|sexy|gifts|part|mom|green|moda|baby|navy|loans|engineering|computer|camera|barga|film|kitchen|supply|pics|haus|university|fit|cheap|vet|black|law|lol|tax|bio|sale|earth|kim|love|software|fitness|llc|school|pub|deals|style|domains|band|host|direct|shopping|tube|ist|mba|photo|energy|training|taxi|gift|wine|town|bike|toys|ski|poker|yoga|parts|solar|engineer|garden|observer|sucks|hosting|bingo|christmas|gives|horse|insure|diet|fishing|whoswho|tickets|boats|flowers|storage|cfd|inc|quest|luxe|security" +
@"com|edu|gov|mil|net|org|biz|info|name|cat|re|museum|us|ca|uk|cc|int|arpa|asia|pro|coop|aero|tv|top|xin|xyz|vip|cn|mobi|ru|de|pl|eu|io|jp|club|au|post|me|guru|expert|tw|mo|hk|fr|ar|pk|mv|in|it|ws|sh|my|cd|ac|li|co|cm|win|red|rec|travel|wang|ch|dj|er|ee|es|is|kr|mm|mn|no|ne|to|tr|za|ml|ga|xxx|porn|adult|cyou|buzz|monster|icu|shop|best|site|live|online|pw|cloud|website|life|store|fun|app|today|uno|space|world|one|link|work|email|nl|trade|bid|stream|men|art|party|date|dev|tech|church|rocks|digital|download|moe|agency|network|click|fail|news|cool|vegas|blog|review|company|la|design|services|golf|exposed|team|ltd|help|zone|loan|wtf|media|solutions|games|directory|center|care|fyi|group|ooo|science|systems|works|city|pet|run|tips|studio|guide|cash|at|support|ninja|plus|rip|marketing|vin|reisen|tools|finance|immo|wiki|viajes|global|mx|promo|recipes|photos|academy|dog|pink|money|chat|casa|cafe|ink|foundation|faith|webcam|house|technology|photography|video|blue|farm|codes|realty|tel|land|show|business|international|social|sbs|skin|page|london|health|hiv|bond|vote|autos|rest|limo|hospital|gay|bar|game|fans|ph|study|cooking|glass|place|rent|shoes|tires|wedding|cab|camp|beer|menu|movie|fish|sexy|gifts|part|mom|green|moda|baby|navy|loans|engineering|computer|camera|barga|film|kitchen|supply|pics|haus|university|fit|cheap|vet|black|law|lol|tax|bio|sale|earth|kim|love|software|fitness|llc|school|pub|deals|style|domains|band|host|direct|shopping|tube|ist|mba|photo|energy|training|taxi|gift|wine|town|bike|toys|ski|poker|yoga|parts|solar|engineer|garden|observer|sucks|hosting|bingo|christmas|gives|horse|insure|diet|fishing|whoswho|tickets|boats|flowers|storage|cfd|inc|quest|luxe|security" +
@")(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$";
#endregion URL 的正则表达式 (URL_REGEX)
internal static readonly string[] FILE_SUFFIXES = { ".png", ".jpg", ".gif" };
Expand Down
8 changes: 8 additions & 0 deletions Pages/BehaviorPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<Label Content="禁用瑟瑟" />
<controls:ToggleSwitch x:Name="DisableR18Toggle" Style="{StaticResource SettingToggle}" MouseDown="DisableR18Toggle_MouseDown" />
</Grid>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label Content="PixivCat" />
<controls:ToggleSwitch x:Name="PixivCatToggle" Style="{StaticResource SettingToggle}" MouseDown="PixivCatToggle_MouseDown" />
</Grid>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down
10 changes: 10 additions & 0 deletions Pages/BehaviorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ internal void DisableR18Toggle_MouseDown(object sender, System.Windows.Input.Mou

Properties.Settings.Default.Save();
}
internal void PixivCatToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//使用PixivCat接口
if (PixivCatToggle.IS_TOGGLED)
Properties.Settings.Default.IsPixivCat = true;
else
Properties.Settings.Default.IsPixivCat = false;

Properties.Settings.Default.Save();
}
internal void DisableExceptionToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//禁用报错
Expand Down
12 changes: 12 additions & 0 deletions Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
<Setting Name="IsR18Disabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="IsPixivCat" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
58 changes: 11 additions & 47 deletions Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ private void PickSettings()
RestoreSettings(Define.APPEARANCE_PAGE.LockAnimationToggle, Define.APPEARANCE_PAGE.LockAnimationToggle_MouseDown);
if (Properties.Settings.Default.IsR18Disabled)
RestoreSettings(Define.BEHAVIOR_PAGE.DisableR18Toggle, Define.BEHAVIOR_PAGE.DisableR18Toggle_MouseDown);
if (Properties.Settings.Default.IsPixivCat)
RestoreSettings(Define.BEHAVIOR_PAGE.PixivCatToggle, Define.BEHAVIOR_PAGE.PixivCatToggle_MouseDown);
if (Properties.Settings.Default.IsExceptionDisabled)
RestoreSettings(Define.BEHAVIOR_PAGE.DisableExceptionToggle, Define.BEHAVIOR_PAGE.DisableExceptionToggle_MouseDown);
if (Properties.Settings.Default.IsTipsDisabled)
Expand Down Expand Up @@ -302,7 +304,11 @@ private async Task PickInput()
if (Regex.IsMatch((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text, "^([0-9]*)-?[0-9]*$"))
await IsPixivID(); //Pixiv ID
else if (new Regex(Define.URI_REGEX).IsMatch((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text))
{
if (!(IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.StartsWith("https://") && !(IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.StartsWith("http://"))
(IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text = "https://" + (IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text;
await IsUri(); //Uri
}
else
await IsKeyWord(); //关键词

Expand All @@ -318,66 +324,24 @@ private async Task IsUri()
Title = "正在解析链接";

if ((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Contains(@"www.pixiv.net/artworks")) //Pixiv Url
{
Exception exception = new();
foreach (string fileSuffix in Define.FILE_SUFFIXES)
{
try
{
await GetImage((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Replace(@"www.pixiv.net/artworks", @"pixiv.re") + fileSuffix);

Title = "链接解析完成";

return;
}
catch (Exception ex) { exception = ex; }
}
throw exception;
}
await GetImage((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Replace(@"www.pixiv.net/artworks", @"pixiv.re") + ".png");
else if ((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Contains(@"www.pixiv.net/member_illust.php?") && (IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Contains("illust_id")) //Pixiv Illust Url
{
NameValueCollection paramCollection = GetParamCollection(new Uri((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text).Query);

Exception exception = new();
foreach (string fileSuffix in Define.FILE_SUFFIXES)
{
try
{
await GetImage(@"https://pixiv.re/" + paramCollection["illust_id"]! + fileSuffix);

Title = "链接解析完成";

return;
}
catch (Exception ex) { exception = ex; }
}
throw exception;
await GetImage(@"https://pixiv.re/" + paramCollection["illust_id"]! + ".png");
}
else //其他Uri(包括Pximg Url)
{
await GetImage((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Replace(@"pximg.net", @"pixiv.re"));
}
await GetImage((IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text.Replace(@"i.pximg.net", Define.BEHAVIOR_PAGE.PixivCatToggle.IS_TOGGLED ? @"i.pixiv.re" : @"pximg.moezx.cc"));

Title = "链接解析完成";
}
private async Task IsPixivID()
{
Title = "正在解析PixivID";

Exception exception = new();
foreach (string fileSuffix in Define.FILE_SUFFIXES)
{
try
{
await GetImage(@"https://pixiv.re/" + (IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text + fileSuffix);

Title = "PixivID解析完成";
await GetImage(@"https://pixiv.re/" + (IS_ACTIVE ? ActiveSearchBox : InactiveSearchBox).Text + ".png");

return;
}
catch (Exception ex) { exception = ex; }
}
throw exception;
Title = "PixivID解析完成";
}
private void IsFilePath()
{
Expand Down

0 comments on commit 9abd11f

Please sign in to comment.