summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-05-06 19:51:49 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-05-25 22:53:53 +0200
commit8dd18248692726e8db05138c4ce2b01f39ad62f6 (patch)
treec2e38183ed9799c98dc7c5522f4131bb3b10c8c6 /src
parentc7876d564f09995244186f57d61cedfeb63038b6 (diff)
downloadinvidious-8dd18248692726e8db05138c4ce2b01f39ad62f6.tar.gz
invidious-8dd18248692726e8db05138c4ce2b01f39ad62f6.tar.bz2
invidious-8dd18248692726e8db05138c4ce2b01f39ad62f6.zip
Comments: Move reddit type definitions to their own file
Diffstat (limited to 'src')
-rw-r--r--src/invidious/comments.cr58
-rw-r--r--src/invidious/comments/reddit_types.cr57
2 files changed, 57 insertions, 58 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 466c9fe5..00e8d399 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -1,61 +1,3 @@
-class RedditThing
- include JSON::Serializable
-
- property kind : String
- property data : RedditComment | RedditLink | RedditMore | RedditListing
-end
-
-class RedditComment
- include JSON::Serializable
-
- property author : String
- property body_html : String
- property replies : RedditThing | String
- property score : Int32
- property depth : Int32
- property permalink : String
-
- @[JSON::Field(converter: RedditComment::TimeConverter)]
- property created_utc : Time
-
- module TimeConverter
- def self.from_json(value : JSON::PullParser) : Time
- Time.unix(value.read_float.to_i)
- end
-
- def self.to_json(value : Time, json : JSON::Builder)
- json.number(value.to_unix)
- end
- end
-end
-
-struct RedditLink
- include JSON::Serializable
-
- property author : String
- property score : Int32
- property subreddit : String
- property num_comments : Int32
- property id : String
- property permalink : String
- property title : String
-end
-
-struct RedditMore
- include JSON::Serializable
-
- property children : Array(String)
- property count : Int32
- property depth : Int32
-end
-
-class RedditListing
- include JSON::Serializable
-
- property children : Array(RedditThing)
- property modhash : String
-end
-
def fetch_youtube_comments(id, cursor, format, locale, thin_mode, region, sort_by = "top")
case cursor
when nil, ""
diff --git a/src/invidious/comments/reddit_types.cr b/src/invidious/comments/reddit_types.cr
new file mode 100644
index 00000000..796a1183
--- /dev/null
+++ b/src/invidious/comments/reddit_types.cr
@@ -0,0 +1,57 @@
+class RedditThing
+ include JSON::Serializable
+
+ property kind : String
+ property data : RedditComment | RedditLink | RedditMore | RedditListing
+end
+
+class RedditComment
+ include JSON::Serializable
+
+ property author : String
+ property body_html : String
+ property replies : RedditThing | String
+ property score : Int32
+ property depth : Int32
+ property permalink : String
+
+ @[JSON::Field(converter: RedditComment::TimeConverter)]
+ property created_utc : Time
+
+ module TimeConverter
+ def self.from_json(value : JSON::PullParser) : Time
+ Time.unix(value.read_float.to_i)
+ end
+
+ def self.to_json(value : Time, json : JSON::Builder)
+ json.number(value.to_unix)
+ end
+ end
+end
+
+struct RedditLink
+ include JSON::Serializable
+
+ property author : String
+ property score : Int32
+ property subreddit : String
+ property num_comments : Int32
+ property id : String
+ property permalink : String
+ property title : String
+end
+
+struct RedditMore
+ include JSON::Serializable
+
+ property children : Array(String)
+ property count : Int32
+ property depth : Int32
+end
+
+class RedditListing
+ include JSON::Serializable
+
+ property children : Array(RedditThing)
+ property modhash : String
+end