ZMediumToMarkdown 2.5.1 → 2.6.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 +4 -4
- data/bin/ZMediumToMarkdown +3 -4
- data/lib/Helper.rb +1 -1
- data/lib/Request.rb +25 -5
- data/lib/ZMediumFetcher.rb +1 -1
- metadata +7 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea5ab4db3ceae4536d0c2cb0e9c84b9def07bf557840d49d5273b0f69cc166c
|
4
|
+
data.tar.gz: 1aba0d265b1bd8113b8f58d1d16fe676297ffb43b562bbb1c8c0e5131cd8fc03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 040a46e36d28e61c45615798a8f366ec6bd7550be3191cb949fd4c96ed6cd0abbe315f98c6694a856456b710d611535ef99de55150e3e34648cf0e6bfb53deea
|
7
|
+
data.tar.gz: 1765391b94ebb65031bb315c7afd9761e6d4afec9b9dca47c488bc0f016c5798d93b187c95c0dcba5e010883137c743eccbd6ab77b27f5f7a29be38f9938ca0d
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -8,8 +8,7 @@ require "ZMediumFetcher"
|
|
8
8
|
require "Helper"
|
9
9
|
require "optparse"
|
10
10
|
|
11
|
-
$
|
12
|
-
$cookie_uid = nil
|
11
|
+
$cookies = {}
|
13
12
|
|
14
13
|
class Main
|
15
14
|
def initialize
|
@@ -23,11 +22,11 @@ class Main
|
|
23
22
|
opts.banner = "Usage: ZMediumFetcher [options]"
|
24
23
|
|
25
24
|
opts.on('-s', '--cookie_sid COOKIESID', 'Your logged-in Medium cookie sid value') do |cookie_sid|
|
26
|
-
$
|
25
|
+
$cookies['sid'] = cookie_sid
|
27
26
|
end
|
28
27
|
|
29
28
|
opts.on('-d', '--cookie_uid COOKIEUID', 'Your logged-in Medium cookie uid value') do |cookie_uid|
|
30
|
-
$
|
29
|
+
$cookies['uid'] = cookie_uid
|
31
30
|
end
|
32
31
|
|
33
32
|
opts.on('-u', '--username USERNAME', 'Downloading all posts from user') do |username|
|
data/lib/Helper.rb
CHANGED
data/lib/Request.rb
CHANGED
@@ -22,18 +22,38 @@ class Request
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
cookiesString = $cookies.reject { |_, value| value.nil? }
|
26
|
+
.map { |key, value| "#{key}=#{value}" }
|
27
|
+
.join("; ");
|
28
|
+
|
29
|
+
if !cookiesString.nil? && cookiesString != ""
|
30
|
+
request['Cookie'] = cookiesString;
|
27
31
|
end
|
28
32
|
|
29
33
|
response = https.request(request);
|
30
|
-
|
34
|
+
|
35
|
+
setCookieString = response.get_fields('set-cookie');
|
36
|
+
if !setCookieString.nil? && setCookieString != ""
|
37
|
+
setCookies = setCookieString.map { |cookie| cookie.split('; ').first }.each_with_object({}) do |cookie, hash|
|
38
|
+
key, value = cookie.split('=', 2) # Split by '=' into key and value
|
39
|
+
hash[key] = value
|
40
|
+
end;
|
41
|
+
|
42
|
+
setCookies.each do |key, value|
|
43
|
+
$cookies[key] = value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
31
47
|
# 3XX Redirect
|
32
48
|
if response.code.to_i == 429
|
33
|
-
|
49
|
+
if retryCount >= 10
|
50
|
+
raise "Error: Too Manay Reqeust, blocked by Medium. URL: #{url}";
|
51
|
+
else
|
52
|
+
response = self.URL(url, method, data, retryCount);
|
53
|
+
end
|
34
54
|
elsif response.code.to_i >= 300 && response.code.to_i <= 399 && !response['location'].nil? && response['location'] != ''
|
35
55
|
if retryCount >= 10
|
36
|
-
raise "Error: Retry limit reached.
|
56
|
+
raise "Error: Retry limit reached. URL: #{url}"
|
37
57
|
else
|
38
58
|
location = response['location']
|
39
59
|
if !location.match? /^(http)/
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -362,7 +362,7 @@ class ZMediumFetcher
|
|
362
362
|
index = 1
|
363
363
|
postURLS.each do |postURL|
|
364
364
|
begin
|
365
|
-
# todo: unless File.
|
365
|
+
# todo: unless File.exist? Post.getPostPathFromPostURLString(postURL) +".md"
|
366
366
|
downloadPost(postURL["url"], downloadPathPolicy, postURL["pin"])
|
367
367
|
rescue => e
|
368
368
|
puts e
|
metadata
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ZMediumToMarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-03-22 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: nokogiri
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
18
|
+
version: 1.18.4
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
25
|
+
version: 1.18.4
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: net-http
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +53,6 @@ dependencies:
|
|
54
53
|
version: 2.3.2
|
55
54
|
description: ZMediumToMarkdown lets you download Medium post and convert it to markdown
|
56
55
|
format easily.
|
57
|
-
email:
|
58
56
|
executables:
|
59
57
|
- ZMediumToMarkdown
|
60
58
|
extensions: []
|
@@ -92,7 +90,6 @@ homepage: https://github.com/ZhgChgLi/ZMediumToMarkdown
|
|
92
90
|
licenses:
|
93
91
|
- MIT
|
94
92
|
metadata: {}
|
95
|
-
post_install_message:
|
96
93
|
rdoc_options: []
|
97
94
|
require_paths:
|
98
95
|
- lib
|
@@ -107,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
104
|
- !ruby/object:Gem::Version
|
108
105
|
version: '0'
|
109
106
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
107
|
+
rubygems_version: 3.6.2
|
112
108
|
specification_version: 4
|
113
109
|
summary: This project can help you to make an auto-sync or auto-backup service from
|
114
110
|
Medium, like auto-sync Medium posts to Jekyll or other static markdown blog engines
|