Skip to content

Commit d4fe6cd

Browse files
committed
Add issue #583 New filename token for post count (likes)
1 parent 4a68e1b commit d4fe6cd

File tree

7 files changed

+17
-9
lines changed

7 files changed

+17
-9
lines changed

src/TumblThree/SharedAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
[assembly: ComVisible(false)]
1414
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
15-
[assembly: AssemblyVersion("2.16.0.0")]
16-
[assembly: AssemblyFileVersion("2.16.0.0")]
15+
[assembly: AssemblyVersion("2.17.0.0")]
16+
[assembly: AssemblyFileVersion("2.17.0.0")]

src/TumblThree/TumblThree.Applications/Crawler/AbstractCrawler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ protected static string FileName(string url)
393393

394394
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>")]
395395
protected virtual string BuildFileNameCore(string url, string blogName, DateTime date, int timestamp, int index, string type, string id,
396-
List<string> tags, string slug, string title, string rebloggedFromName, string rebloggedRootName, string reblogKey)
396+
List<string> tags, string slug, string title, string rebloggedFromName, string rebloggedRootName, string reblogKey, int noteCount)
397397
{
398398
/*
399399
* Replaced are:
@@ -413,6 +413,7 @@ protected virtual string BuildFileNameCore(string url, string blogName, DateTime
413413
%r for reblog ("" / "reblog")
414414
%s slug (last part of a post's url)
415415
%k reblog-key
416+
%l likes/note count
416417
Tokens to make filenames unique:
417418
%x "_{number}" ({number}: 2..n)
418419
%y " ({number})" ({number}: 2..n)
@@ -490,6 +491,7 @@ protected virtual string BuildFileNameCore(string url, string blogName, DateTime
490491
}
491492
if (ContainsCI(filename, "%s")) filename = ReplaceCI(filename, "%s", slug);
492493
if (ContainsCI(filename, "%k")) filename = ReplaceCI(filename, "%k", reblogKey);
494+
if (ContainsCI(filename, "%l")) filename = ReplaceCI(filename, "%l", noteCount.ToString());
493495
int neededCharactersForNumbering = 0;
494496
if (ContainsCI(filename, "%x"))
495497
{

src/TumblThree/TumblThree.Applications/Crawler/AbstractTumblrCrawler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ protected string BuildFileName(string url, Post post, string type, int index)
545545
post = new Post() { Date = DateTime.MinValue.ToString("R"), DateGmt = DateTime.MinValue.ToString("R"), Type = "", Id = "", Tags = new List<string>(),
546546
Slug = "", RegularTitle = "", RebloggedFromName = "", RebloggedRootName = "", ReblogKey = "", Tumblelog = new TumbleLog2() { Name = "" } };
547547
}
548-
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);
548+
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);
549549
}
550550

551551
protected string BuildFileName(string url, Post post, int index)
@@ -561,7 +561,7 @@ protected string BuildFileName(string url, TumblrSvcJson.Post post, string type,
561561
post = new TumblrSvcJson.Post() { Date = DateTime.MinValue.ToString("R"), Type = "", Id = "", Tags = new List<string>(),
562562
Slug = "", Title = "", RebloggedFromName = "", RebloggedRootName = "", ReblogKey = "", Tumblelog = "" };
563563
}
564-
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);
564+
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);
565565
}
566566

567567
protected string BuildFileName(string url, TumblrSvcJson.Post post, int index)

src/TumblThree/TumblThree.Applications/Crawler/NewTumblCrawler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private string BuildFileName(string url, Post post, string type, int index)
390390
}
391391
var tags = GetTags(post);
392392
return BuildFileNameCore(url, GetBlogName(), post.dtActive.Value, UnixTimestamp(post), index, type, GetPostId(post),
393-
tags, "", GetTitle(post), reblogName, "", reblogId);
393+
tags, "", GetTitle(post), reblogName, "", reblogId, 0);
394394
}
395395

396396
private static string RemoveHtmlFromString(string text)

src/TumblThree/TumblThree.Applications/Crawler/TwitterCrawler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ private string BuildFileName(string url, Tweet post, string type, int index)
10361036
}
10371037
var tags = GetTags(post);
10381038
return BuildFileNameCore(url, post.User.Legacy.ScreenName, GetDate(post), UnixTimestamp(post), index, type, post.Legacy.IdStr,
1039-
tags, "", GetTitle(post.Legacy.FullText, tags), reblogName, "", reblogId);
1039+
tags, "", GetTitle(post.Legacy.FullText, tags), reblogName, "", reblogId, post.Legacy.FavoriteCount);
10401040
}
10411041

10421042
private static string GetTitle(string text, List<string> tags)

src/TumblThree/TumblThree.Applications/DataModels/TumblrApi/Post.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class Post : ICloneable
5959
public string ReblogButton { get; set; }
6060

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

6464
[DataMember(Name = "reblogged-from-url", EmitDefaultValue = false)]
6565
public string RebloggedFromUrl { get; set; }
@@ -290,7 +290,7 @@ private void Initialize()
290290
IsSubmission = false;
291291
LikeButton = string.Empty;
292292
ReblogButton = string.Empty;
293-
NoteCount = string.Empty;
293+
NoteCount = 0;
294294
RebloggedFromUrl = string.Empty;
295295
RebloggedFromName = string.Empty;
296296
RebloggedFromTitle = string.Empty;

src/TumblThree/TumblThree.Applications/DataModels/TumblrSvc/TumblrSvcJson.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ public class Post : ICloneable
579579
[DataMember(Name = "like_count", EmitDefaultValue = false)]
580580
public int LikeCount { get; set; }
581581

582+
public int NoteCount
583+
{
584+
get => LikeCount;
585+
set => LikeCount = value;
586+
}
587+
582588
[DataMember(Name = "reblog_count", EmitDefaultValue = false)]
583589
public int ReblogCount { get; set; }
584590

0 commit comments

Comments
 (0)