fontist 3.0.2 → 3.0.3
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: ef31ff4d5c017fd86187db92ab8eb9c428e694731d9bb7eb9be4dadbcb7ac210
|
|
4
|
+
data.tar.gz: 87f038f05b151bb64f31fc0592d2b2b6e883414852623232c23e2cff12d37df3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bad74c88e0eeb2d2cd12fb8e7c0f9e09663c9fc98ddbebdf0ab54b8f3eb90895414fa7fc5fb699356ff590f7f1ea1cb66cce11917415ecbe9d70112bc5f312e0
|
|
7
|
+
data.tar.gz: 4c843a8d911ce97ff680fb3ac85d440e80f617982a77c82e6bc8cc6c40b32a050ff2daf50a109c73b174c7ec851e0999f4a6df77148546b9f44838b80205e83d
|
|
@@ -272,7 +272,7 @@ module Fontist
|
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
def font_links
|
|
275
|
-
html = URI.parse(ROOT).open.read
|
|
275
|
+
html = URI.parse(ROOT).open("User-Agent" => Fontist::Utils::UserAgent.random_user_agent).read
|
|
276
276
|
document = Nokogiri::HTML.parse(html)
|
|
277
277
|
document.css("table.products div.title > a")
|
|
278
278
|
end
|
|
@@ -392,7 +392,7 @@ module Fontist
|
|
|
392
392
|
end
|
|
393
393
|
|
|
394
394
|
def find_archive_url_by_page_uri(uri)
|
|
395
|
-
response = uri.open
|
|
395
|
+
response = uri.open("User-Agent" => Fontist::Utils::UserAgent.random_user_agent)
|
|
396
396
|
current_url = response.base_uri
|
|
397
397
|
html = response.read
|
|
398
398
|
document = Nokogiri::HTML.parse(html)
|
|
@@ -55,7 +55,7 @@ module Fontist
|
|
|
55
55
|
Fontist.ui.say("Downloading Font#{version} catalog from #{url}...") if Fontist.ui.respond_to?(:say)
|
|
56
56
|
|
|
57
57
|
URI(url).open(
|
|
58
|
-
"User-Agent" =>
|
|
58
|
+
"User-Agent" => Fontist::Utils::UserAgent.random_user_agent,
|
|
59
59
|
) do |response|
|
|
60
60
|
File.write(catalog_file, response.read)
|
|
61
61
|
end
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
module Fontist
|
|
2
2
|
module Utils
|
|
3
3
|
class Downloader
|
|
4
|
-
DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " \
|
|
5
|
-
"AppleWebKit/537.36 (KHTML, like Gecko) " \
|
|
6
|
-
"Chrome/131.0.0.0 Safari/537.36".freeze
|
|
7
|
-
|
|
8
4
|
class << self
|
|
9
5
|
def download(*args)
|
|
10
6
|
new(*args).download
|
|
@@ -143,7 +139,7 @@ module Fontist
|
|
|
143
139
|
obj.headers &&
|
|
144
140
|
obj.headers.to_h.to_h { |k, v| [k.to_s, v] }) || {} # rubocop:disable Style/HashTransformKeys, Metrics/LineLength
|
|
145
141
|
|
|
146
|
-
|
|
142
|
+
Utils::UserAgent.browser_headers.merge(formula_headers)
|
|
147
143
|
end
|
|
148
144
|
|
|
149
145
|
def extract_raw_url
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fontist
|
|
4
|
+
module Utils
|
|
5
|
+
module UserAgent
|
|
6
|
+
PROFILES = [
|
|
7
|
+
{
|
|
8
|
+
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " \
|
|
9
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) " \
|
|
10
|
+
"Chrome/131.0.0.0 Safari/537.36",
|
|
11
|
+
platform: '"macOS"',
|
|
12
|
+
chrome_version: "131",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " \
|
|
16
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) " \
|
|
17
|
+
"Chrome/130.0.0.0 Safari/537.36",
|
|
18
|
+
platform: '"Windows"',
|
|
19
|
+
chrome_version: "130",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
user_agent: "Mozilla/5.0 (X11; Linux x86_64) " \
|
|
23
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) " \
|
|
24
|
+
"Chrome/132.0.0.0 Safari/537.36",
|
|
25
|
+
platform: '"Linux"',
|
|
26
|
+
chrome_version: "132",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " \
|
|
30
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) " \
|
|
31
|
+
"Chrome/130.0.0.0 Safari/537.36",
|
|
32
|
+
platform: '"macOS"',
|
|
33
|
+
chrome_version: "130",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " \
|
|
37
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) " \
|
|
38
|
+
"Chrome/132.0.0.0 Safari/537.36",
|
|
39
|
+
platform: '"Windows"',
|
|
40
|
+
chrome_version: "132",
|
|
41
|
+
},
|
|
42
|
+
].freeze
|
|
43
|
+
|
|
44
|
+
ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," \
|
|
45
|
+
"image/avif,image/webp,image/apng,*/*;q=0.8," \
|
|
46
|
+
"application/signed-exchange;v=b3;q=0.7"
|
|
47
|
+
|
|
48
|
+
ACCEPT_LANGUAGE = "en-US,en;q=0.9"
|
|
49
|
+
|
|
50
|
+
STATIC_HEADERS = {
|
|
51
|
+
"Accept" => ACCEPT,
|
|
52
|
+
"Accept-Language" => ACCEPT_LANGUAGE,
|
|
53
|
+
"Cache-Control" => "no-cache",
|
|
54
|
+
"Pragma" => "no-cache",
|
|
55
|
+
"Sec-Ch-Ua-Mobile" => "?0",
|
|
56
|
+
"Sec-Fetch-Dest" => "document",
|
|
57
|
+
"Sec-Fetch-Mode" => "navigate",
|
|
58
|
+
"Sec-Fetch-Site" => "cross-site",
|
|
59
|
+
"Sec-Fetch-User" => "?1",
|
|
60
|
+
"Upgrade-Insecure-Requests" => "1",
|
|
61
|
+
}.freeze
|
|
62
|
+
|
|
63
|
+
class << self
|
|
64
|
+
def random_profile
|
|
65
|
+
PROFILES.sample
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def browser_headers
|
|
69
|
+
profile = random_profile
|
|
70
|
+
build_headers(profile)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def random_user_agent
|
|
74
|
+
random_profile[:user_agent]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
def build_headers(profile)
|
|
80
|
+
STATIC_HEADERS.merge(
|
|
81
|
+
"User-Agent" => profile[:user_agent],
|
|
82
|
+
"Sec-Ch-Ua" => build_sec_ch_ua(profile[:chrome_version]),
|
|
83
|
+
"Sec-Ch-Ua-Platform" => profile[:platform],
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def build_sec_ch_ua(chrome_version)
|
|
88
|
+
"\"Google Chrome\";v=\"#{chrome_version}\", " \
|
|
89
|
+
"\"Chromium\";v=\"#{chrome_version}\", " \
|
|
90
|
+
"\"Not_A Brand\";v=\"24\""
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
data/lib/fontist/utils.rb
CHANGED
|
@@ -9,6 +9,7 @@ module Fontist
|
|
|
9
9
|
autoload :Locking, "#{__dir__}/utils/locking"
|
|
10
10
|
autoload :System, "#{__dir__}/utils/system"
|
|
11
11
|
autoload :UI, "#{__dir__}/utils/ui"
|
|
12
|
+
autoload :UserAgent, "#{__dir__}/utils/user_agent"
|
|
12
13
|
|
|
13
14
|
# Converts a glob pattern to case-insensitive by replacing each
|
|
14
15
|
# alphabetic character with a character class [aA]
|
data/lib/fontist/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fontist
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -509,6 +509,7 @@ files:
|
|
|
509
509
|
- lib/fontist/utils/locking.rb
|
|
510
510
|
- lib/fontist/utils/system.rb
|
|
511
511
|
- lib/fontist/utils/ui.rb
|
|
512
|
+
- lib/fontist/utils/user_agent.rb
|
|
512
513
|
- lib/fontist/validate_cli.rb
|
|
513
514
|
- lib/fontist/validation.rb
|
|
514
515
|
- lib/fontist/validator.rb
|