reddit_post_to_markdown 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b71d407ce547e59be02bec0f63ec65f30cf6eb518d0cd8bb6045baecd0b1b73
|
|
4
|
+
data.tar.gz: ba3d8ae097aed561c3b4cb9970db384d49193c3c2c2666fb97641a999a9fcfc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6bcf46441425954a79db588f7bc76b9b746a13acb51fd88909b77c110d427a98c33f4e76778911ab8875736c47a14952bb91964d195bf4e21408d9426e066338
|
|
7
|
+
data.tar.gz: aab145ee470c38ad201c0bd0e18cc1a66c16cb65c192eb63521665612d871d06cac85287552c9d4133d35fffadde5ee4b98ff66d3455950b0d5b662172736888
|
|
@@ -114,7 +114,8 @@ module RedditPostToMarkdown
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def post_url
|
|
117
|
-
@post_data.fetch("
|
|
117
|
+
permalink = @post_data.fetch("permalink", "")
|
|
118
|
+
permalink.empty? ? @post_data.fetch("url", "") : "https://www.reddit.com#{permalink}"
|
|
118
119
|
end
|
|
119
120
|
|
|
120
121
|
def post_created_utc
|
|
@@ -123,6 +124,13 @@ module RedditPostToMarkdown
|
|
|
123
124
|
|
|
124
125
|
def post_image_urls
|
|
125
126
|
image_urls = []
|
|
127
|
+
|
|
128
|
+
if @post_data["post_hint"] == "image"
|
|
129
|
+
url = @post_data["url"]
|
|
130
|
+
image_urls << url if url && !url.empty?
|
|
131
|
+
return image_urls
|
|
132
|
+
end
|
|
133
|
+
|
|
126
134
|
media_metadata = @post_data["media_metadata"]
|
|
127
135
|
# a hash of hashes with some sort of hashed keys we don't care about
|
|
128
136
|
return image_urls unless media_metadata
|
|
@@ -28,19 +28,17 @@ module RedditPostToMarkdown
|
|
|
28
28
|
PATTERNS.any? { |pattern| url.match?(pattern) }
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# Strips
|
|
31
|
+
# Strips the query string and trailing slash from a Reddit URL.
|
|
32
32
|
#
|
|
33
|
-
# Removes
|
|
34
|
-
#
|
|
35
|
-
# whitespace is also removed.
|
|
33
|
+
# Removes everything from the first +?+ onward (tracking params, share IDs,
|
|
34
|
+
# etc. are never needed to fetch the post JSON), then strips any trailing
|
|
35
|
+
# slash. Leading and trailing whitespace is also removed.
|
|
36
36
|
#
|
|
37
37
|
# @param url [String] the URL to clean
|
|
38
38
|
# @return [String] the cleaned URL
|
|
39
39
|
def self.clean_url(url)
|
|
40
40
|
url = url.to_s.strip
|
|
41
|
-
url = url.split("?
|
|
42
|
-
url = url.split("?ref=").first
|
|
43
|
-
url = url.split("?context=").first
|
|
41
|
+
url = url.split("?").first
|
|
44
42
|
url.chomp("/")
|
|
45
43
|
end
|
|
46
44
|
end
|
|
@@ -4,12 +4,18 @@ Gem::Specification.new do |spec|
|
|
|
4
4
|
spec.name = "reddit_post_to_markdown"
|
|
5
5
|
spec.version = RedditPostToMarkdown::VERSION
|
|
6
6
|
spec.authors = ["masukomi"]
|
|
7
|
+
spec.email = ["masukomi@masukomi.org"]
|
|
8
|
+
spec.homepage = "https://github.com/masukomi/reddit_post_to_markdown"
|
|
7
9
|
spec.summary = "Download a public Reddit post and convert it to Markdown"
|
|
8
10
|
spec.description = "Takes the URL of a public Reddit post, downloads the post and its comments via the Reddit JSON API, and returns the content as a Markdown string."
|
|
9
11
|
spec.license = "MIT"
|
|
10
12
|
|
|
11
13
|
spec.required_ruby_version = ">= 2.7"
|
|
12
14
|
|
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.org"
|
|
18
|
+
|
|
13
19
|
spec.files = Dir["lib/**/*.rb", "reddit_post_to_markdown.gemspec"]
|
|
14
20
|
|
|
15
21
|
spec.add_dependency "httparty", "~> 0.22"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reddit_post_to_markdown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- masukomi
|
|
@@ -53,6 +53,8 @@ dependencies:
|
|
|
53
53
|
version: '3.26'
|
|
54
54
|
description: Takes the URL of a public Reddit post, downloads the post and its comments
|
|
55
55
|
via the Reddit JSON API, and returns the content as a Markdown string.
|
|
56
|
+
email:
|
|
57
|
+
- masukomi@masukomi.org
|
|
56
58
|
executables: []
|
|
57
59
|
extensions: []
|
|
58
60
|
extra_rdoc_files: []
|
|
@@ -64,9 +66,13 @@ files:
|
|
|
64
66
|
- lib/reddit_post_to_markdown/url_validator.rb
|
|
65
67
|
- lib/reddit_post_to_markdown/version.rb
|
|
66
68
|
- reddit_post_to_markdown.gemspec
|
|
69
|
+
homepage: https://github.com/masukomi/reddit_post_to_markdown
|
|
67
70
|
licenses:
|
|
68
71
|
- MIT
|
|
69
|
-
metadata:
|
|
72
|
+
metadata:
|
|
73
|
+
homepage_uri: https://github.com/masukomi/reddit_post_to_markdown
|
|
74
|
+
source_code_uri: https://github.com/masukomi/reddit_post_to_markdown
|
|
75
|
+
changelog_uri: https://github.com/masukomi/reddit_post_to_markdown/CHANGELOG.org
|
|
70
76
|
rdoc_options: []
|
|
71
77
|
require_paths:
|
|
72
78
|
- lib
|