6
6
using HtmlAgilityPack ;
7
7
using Newtonsoft . Json ;
8
8
using Newtonsoft . Json . Linq ;
9
+ using RedditSharp . Utils ;
9
10
10
11
namespace RedditSharp . Things
11
12
{
@@ -38,6 +39,7 @@ public class Subreddit : Thing
38
39
private const string FlairListUrl = "/r/{0}/api/flairlist.json" ;
39
40
private const string CommentsUrl = "/r/{0}/comments.json" ;
40
41
private const string SearchUrl = "/r/{0}/search.json?q={1}&restrict_sr=on&sort={2}&t={3}" ;
42
+ private const string SearchUrlDate = "/r/{0}/search.json?q=timestamp:{1}..{2}&restrict_sr=on&sort={3}&syntax=cloudsearch" ;
41
43
42
44
[ JsonIgnore ]
43
45
private Reddit Reddit { get ; set ; }
@@ -67,8 +69,8 @@ public class Subreddit : Thing
67
69
[ JsonProperty ( "header_title" ) ]
68
70
public string HeaderTitle { get ; set ; }
69
71
70
- [ JsonProperty ( "over18 " ) ]
71
- public bool ? NSFW { get ; set ; }
72
+ [ JsonProperty ( "over_18 " ) ]
73
+ public bool NSFW { get ; set ; }
72
74
73
75
[ JsonProperty ( "public_description" ) ]
74
76
public string PublicDescription { get ; set ; }
@@ -90,20 +92,20 @@ public class Subreddit : Thing
90
92
/// Property determining whether the current logged in user is a moderator on this subreddit.
91
93
/// </summary>
92
94
[ JsonProperty ( "user_is_moderator" ) ]
93
- public bool UserIsModerator { get ; set ; }
95
+ public bool ? UserIsModerator { get ; set ; }
94
96
95
- /// <summary>
96
- /// Property giving the moderator permissions of the logged in user on this subreddit.
97
+ /// <summary>
98
+ /// Property giving the moderator permissions of the logged in user on this subreddit.
97
99
/// </summary>
98
- [ JsonProperty ( "mod_permissions" ) ]
99
- [ JsonConverter ( typeof ( ModeratorPermissionConverter ) ) ]
100
+ [ JsonProperty ( "mod_permissions" ) ]
101
+ [ JsonConverter ( typeof ( ModeratorPermissionConverter ) ) ]
100
102
public ModeratorPermission ModPermissions { get ; set ; }
101
103
102
104
/// <summary>
103
105
/// Property determining whether the current logged in user is banned from the subreddit.
104
106
/// </summary>
105
107
[ JsonProperty ( "user_is_banned" ) ]
106
- public bool UserIsBanned { get ; set ; }
108
+ public bool ? UserIsBanned { get ; set ; }
107
109
108
110
[ JsonIgnore ]
109
111
public string Name { get ; set ; }
@@ -187,6 +189,13 @@ public Listing<Post> Search(string terms)
187
189
return new Listing < Post > ( Reddit , string . Format ( SearchUrl , Name , Uri . EscapeUriString ( terms ) , "relevance" , "all" ) , WebAgent ) ;
188
190
}
189
191
192
+ public Listing < Post > Search ( DateTime from , DateTime to , Sorting sortE = Sorting . New )
193
+ {
194
+ string sort = sortE . ToString ( ) . ToLower ( ) ;
195
+
196
+ return new Listing < Post > ( Reddit , string . Format ( SearchUrlDate , Name , from . DateTimeToUnixTimestamp ( ) , to . DateTimeToUnixTimestamp ( ) , sort ) , WebAgent ) ;
197
+ }
198
+
190
199
public SubredditSettings Settings
191
200
{
192
201
get
@@ -281,12 +290,12 @@ public IEnumerable<ModeratorUser> Moderators
281
290
}
282
291
}
283
292
284
- public IEnumerable < TBUserNote > UserNotes
285
- {
286
- get
287
- {
288
- return ToolBoxUserNotes . GetUserNotes ( WebAgent , Name ) ;
289
- }
293
+ public IEnumerable < TBUserNote > UserNotes
294
+ {
295
+ get
296
+ {
297
+ return ToolBoxUserNotes . GetUserNotes ( WebAgent , Name ) ;
298
+ }
290
299
}
291
300
292
301
public Subreddit Init ( Reddit reddit , JToken json , IWebAgent webAgent )
0 commit comments