Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
Notify user if post couldn't be parsed
Browse files Browse the repository at this point in the history
- Notifies the user if a post couldn't be parsed and was discarded.
  • Loading branch information
johanneszab committed Mar 23, 2018
1 parent 300d8cd commit 46871f2
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/TumblThree/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
[assembly: AssemblyVersion("1.0.8.45")]
[assembly: AssemblyFileVersion("1.0.8.45")]
[assembly: AssemblyVersion("1.0.8.46")]
[assembly: AssemblyFileVersion("1.0.8.46")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Web;
using TumblThree.Applications.DataModels;
using TumblThree.Applications.DataModels.TumblrPosts;
using TumblThree.Applications.Downloader;
using TumblThree.Applications.Extensions;
using TumblThree.Applications.Properties;
using TumblThree.Applications.Services;
Expand Down Expand Up @@ -149,15 +148,17 @@ protected void AddToDownloadList(TumblrPost addToList)
statisticsBag.Add(addToList);
}

public static T ConvertJsonToClass<T>(string json) where T : new()
public T ConvertJsonToClass<T>(string json) where T : new()
{
try
{
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
return serializer.Deserialize<T>(json);
}
catch (InvalidOperationException)
catch (InvalidOperationException invalidOperationException)
{
Logger.Error("AbstractCrawler:ConvertJsonToClass<T>: {0}", "Could not parse data");
shellService.ShowError(invalidOperationException, Resources.PostNotParsable, blog.Name);
return new T();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private async Task UpdateMetaInformation()
}
}

public new static T ConvertJsonToClass<T>(string json) where T : new()
public new T ConvertJsonToClass<T>(string json) where T : new()
{
try
{
Expand All @@ -145,8 +145,10 @@ private async Task UpdateMetaInformation()
return (T)serializer.ReadObject(ms);
}
}
catch (System.Runtime.Serialization.SerializationException)
catch (System.Runtime.Serialization.SerializationException serializationException)
{
Logger.Error("TumblrBlogCrawler:ConvertJsonToClass<T>: {0}", "Could not parse data");
shellService.ShowError(serializationException, Resources.PostNotParsable, blog.Name);
return new T();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override async Task UpdateMetaInformationAsync()
}
}

public new static T ConvertJsonToClass<T>(string json) where T : new()
public new T ConvertJsonToClass<T>(string json) where T : new()
{
try
{
Expand All @@ -154,8 +154,10 @@ public override async Task UpdateMetaInformationAsync()
return (T)serializer.ReadObject(ms);
}
}
catch (System.Runtime.Serialization.SerializationException)
catch (System.Runtime.Serialization.SerializationException serializationException)
{
Logger.Error("TumblrHiddenCrawler:ConvertJsonToClass<T>: {0}", "Could not parse data");
shellService.ShowError(serializationException, Resources.PostNotParsable, blog.Name);
return new T();
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/TumblThree/TumblThree.Applications/DataModels/TumblrSvcJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public class Meta
[DataContract]
public class Theme
{
[DataMember(EmitDefaultValue = false)]
public int header_full_width { get; set; }
[DataMember(EmitDefaultValue = false)]
public int header_full_height { get; set; }
[DataMember(EmitDefaultValue = false)]
public int header_focus_width { get; set; }
[DataMember(EmitDefaultValue = false)]
public int header_focus_height { get; set; }
[DataMember(EmitDefaultValue = false)]
public string avatar_shape { get; set; }
[DataMember(EmitDefaultValue = false)]
Expand Down Expand Up @@ -354,6 +362,8 @@ public class Post : ICloneable
[DataMember(EmitDefaultValue = false)]
public bool is_nsfw_based_on_score { get; set; }
[DataMember(EmitDefaultValue = false)]
public List<string> supply_logging { get; set; }
[DataMember(EmitDefaultValue = false)]
public Blog blog { get; set; }
[DataMember(EmitDefaultValue = false)]
public bool is_nsfw { get; set; }
Expand Down Expand Up @@ -384,6 +394,8 @@ public class Post : ICloneable
[DataMember(EmitDefaultValue = false)]
public string summary { get; set; }
[DataMember(EmitDefaultValue = false)]
public bool is_blocks_post_format { get; set; }
[DataMember(EmitDefaultValue = false)]
public string recommended_source { get; set; }
[DataMember(EmitDefaultValue = false)]
public string recommended_color { get; set; }
Expand Down Expand Up @@ -535,6 +547,10 @@ public class Post : ICloneable
public bool? is_anonymous { get; set; }
[DataMember(EmitDefaultValue = false)]
public bool? is_submission { get; set; }
[DataMember(EmitDefaultValue = false)]
public bool should_bypass_tagfiltering { get; set; }
[DataMember(EmitDefaultValue = false)]
public string provider_uri { get; set; }

public object Clone()
{
Expand All @@ -551,6 +567,7 @@ private void Initialize()
{
type = string.Empty;
is_nsfw_based_on_score = false;
supply_logging = new List<string>();
blog = new Blog();
is_nsfw = false;
nsfw_score = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ private void Initialize()
ConcurrentBlogs = 1;
ConcurrentScans = 4;
LimitScanBandwidth = false;
TimeOut = 30;
TimeOut = 60;
LimitConnections = true;
MaxConnections = 90;
ConnectionTimeInterval = 60;
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
<data name="PostId" xml:space="preserve">
<value>Post ID: {0}</value>
</data>
<data name="PostNotParsable" xml:space="preserve">
<value>A post from {0} was not parsable. Setting 'posts per page' to 1 in the Details might increase the downloadable content.</value>
</data>
<data name="ProgressDownloadImage" xml:space="preserve">
<value>Downloading {0}.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ private void LoadSettings()
ConcurrentBlogs = 1;
ConcurrentScans = 4;
LimitScanBandwidth = false;
TimeOut = 30;
TimeOut = 60;
LimitConnections = true;
MaxConnections = 90;
ConnectionTimeInterval = 60;
Expand Down
4 changes: 2 additions & 2 deletions src/TumblThree/TumblThree.Presentation/Views/AboutView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<Label Content="{x:Static p:Resources.License}" Grid.Row="2" />
<Label Grid.Column="1" Grid.Row="2">
<Hyperlink Command="{Binding ShowWebsiteCommand}"
CommandParameter="https://github.com/johanneszab/TumblThree/blob/master/LICENSE.txt">
CommandParameter="https://github.com/johanneszab/TumblThree/blob/master/LICENSE">
The
MIT License (MIT)
</Hyperlink>
Expand All @@ -66,7 +66,7 @@
<Label Content="{x:Static p:Resources.ThirdPartySoftware}" Grid.Row="4" />
<Label Grid.Column="1" Grid.Row="4">
<Hyperlink Command="{Binding ShowWebsiteCommand}"
CommandParameter="https://github.com/johanneszab/TumblThree/blob/master/LICENSE-3RD-PARTY.txt">
CommandParameter="https://github.com/johanneszab/TumblThree/blob/master/LICENSE-3RD-PARTY">
Third-party
Software and Licenses
</Hyperlink>
Expand Down

0 comments on commit 46871f2

Please sign in to comment.