Skip to content

Commit

Permalink
Add issue #583 New filename token for post count (likes)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas694 committed Dec 15, 2024
1 parent 4a68e1b commit d4fe6cd
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
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("2.16.0.0")]
[assembly: AssemblyFileVersion("2.16.0.0")]
[assembly: AssemblyVersion("2.17.0.0")]
[assembly: AssemblyFileVersion("2.17.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ protected static string FileName(string url)

[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>")]
protected virtual string BuildFileNameCore(string url, string blogName, DateTime date, int timestamp, int index, string type, string id,
List<string> tags, string slug, string title, string rebloggedFromName, string rebloggedRootName, string reblogKey)
List<string> tags, string slug, string title, string rebloggedFromName, string rebloggedRootName, string reblogKey, int noteCount)
{
/*
* Replaced are:
Expand All @@ -413,6 +413,7 @@ protected virtual string BuildFileNameCore(string url, string blogName, DateTime
%r for reblog ("" / "reblog")
%s slug (last part of a post's url)
%k reblog-key
%l likes/note count
Tokens to make filenames unique:
%x "_{number}" ({number}: 2..n)
%y " ({number})" ({number}: 2..n)
Expand Down Expand Up @@ -490,6 +491,7 @@ protected virtual string BuildFileNameCore(string url, string blogName, DateTime
}
if (ContainsCI(filename, "%s")) filename = ReplaceCI(filename, "%s", slug);
if (ContainsCI(filename, "%k")) filename = ReplaceCI(filename, "%k", reblogKey);
if (ContainsCI(filename, "%l")) filename = ReplaceCI(filename, "%l", noteCount.ToString());
int neededCharactersForNumbering = 0;
if (ContainsCI(filename, "%x"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ protected string BuildFileName(string url, Post post, string type, int index)
post = new Post() { Date = DateTime.MinValue.ToString("R"), DateGmt = DateTime.MinValue.ToString("R"), Type = "", Id = "", Tags = new List<string>(),
Slug = "", RegularTitle = "", RebloggedFromName = "", RebloggedRootName = "", ReblogKey = "", Tumblelog = new TumbleLog2() { Name = "" } };
}
return BuildFileNameCore(url, post.Tumblelog.Name, GetDate(post), post.UnixTimestamp, index, type, post.Id, post.Tags, post.Slug, post.RegularTitle, post.RebloggedFromName, post.RebloggedRootName, post.ReblogKey);
return BuildFileNameCore(url, post.Tumblelog.Name, GetDate(post), post.UnixTimestamp, index, type, post.Id, post.Tags, post.Slug, post.RegularTitle, post.RebloggedFromName, post.RebloggedRootName, post.ReblogKey, post.NoteCount);
}

protected string BuildFileName(string url, Post post, int index)
Expand All @@ -561,7 +561,7 @@ protected string BuildFileName(string url, TumblrSvcJson.Post post, string type,
post = new TumblrSvcJson.Post() { Date = DateTime.MinValue.ToString("R"), Type = "", Id = "", Tags = new List<string>(),
Slug = "", Title = "", RebloggedFromName = "", RebloggedRootName = "", ReblogKey = "", Tumblelog = "" };
}
return BuildFileNameCore(url, post.Tumblelog, GetDate(post), post.Timestamp, index, type, post.Id, post.Tags, post.Slug, post.Title, post.RebloggedFromName, post.RebloggedRootName, post.ReblogKey);
return BuildFileNameCore(url, post.Tumblelog, GetDate(post), post.Timestamp, index, type, post.Id, post.Tags, post.Slug, post.Title, post.RebloggedFromName, post.RebloggedRootName, post.ReblogKey, post.NoteCount);
}

protected string BuildFileName(string url, TumblrSvcJson.Post post, int index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private string BuildFileName(string url, Post post, string type, int index)
}
var tags = GetTags(post);
return BuildFileNameCore(url, GetBlogName(), post.dtActive.Value, UnixTimestamp(post), index, type, GetPostId(post),
tags, "", GetTitle(post), reblogName, "", reblogId);
tags, "", GetTitle(post), reblogName, "", reblogId, 0);
}

private static string RemoveHtmlFromString(string text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ private string BuildFileName(string url, Tweet post, string type, int index)
}
var tags = GetTags(post);
return BuildFileNameCore(url, post.User.Legacy.ScreenName, GetDate(post), UnixTimestamp(post), index, type, post.Legacy.IdStr,
tags, "", GetTitle(post.Legacy.FullText, tags), reblogName, "", reblogId);
tags, "", GetTitle(post.Legacy.FullText, tags), reblogName, "", reblogId, post.Legacy.FavoriteCount);
}

private static string GetTitle(string text, List<string> tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Post : ICloneable
public string ReblogButton { get; set; }

[DataMember(Name = "note-count", EmitDefaultValue = false)]
public string NoteCount { get; set; }
public int NoteCount { get; set; }

[DataMember(Name = "reblogged-from-url", EmitDefaultValue = false)]
public string RebloggedFromUrl { get; set; }
Expand Down Expand Up @@ -290,7 +290,7 @@ private void Initialize()
IsSubmission = false;
LikeButton = string.Empty;
ReblogButton = string.Empty;
NoteCount = string.Empty;
NoteCount = 0;
RebloggedFromUrl = string.Empty;
RebloggedFromName = string.Empty;
RebloggedFromTitle = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ public class Post : ICloneable
[DataMember(Name = "like_count", EmitDefaultValue = false)]
public int LikeCount { get; set; }

public int NoteCount
{
get => LikeCount;
set => LikeCount = value;
}

[DataMember(Name = "reblog_count", EmitDefaultValue = false)]
public int ReblogCount { get; set; }

Expand Down

0 comments on commit d4fe6cd

Please sign in to comment.