morris 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/morris/scrapers/post_scraper.rb +20 -1
- data/lib/morris/scrapers/scraper.rb +1 -0
- data/lib/morris/scrapers/video_scraper.rb +2 -1
- data/lib/morris/version.rb +1 -1
- metadata +2 -3
- data/.byebug_history +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec8d5642346eddd8dfc61f4f72b1bc068c05fdc2d6c00ef640ed5a212fbe46b9
|
4
|
+
data.tar.gz: ed6c2558fea7d7dc38be75d8154bb8a88d2280f0f96bdd02c12329fd43c9a8d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b37a063f890040279cbe2c9569e99b59da56e739757171303e687050af97d177cb4080e55766f2ecb6be082bbe5c2f583d3c4ea5bbbdccbcdcb35548c3d2c0f
|
7
|
+
data.tar.gz: 3cb84983b75bdfda2fc56521b32fe084a9fee7845718e99d30ddc3354c9cdc929d3fa5bfc5a94f6f9fb06ac68ae2750cfa5fbe546157a71477bd39adcbffe05b
|
data/Gemfile.lock
CHANGED
@@ -15,11 +15,30 @@ module Morris
|
|
15
15
|
|
16
16
|
Capybara.app_host = "https://tiktok.com"
|
17
17
|
|
18
|
+
# Clean up the url
|
19
|
+
uri = URI.parse(url)
|
20
|
+
|
21
|
+
url = "#{uri.scheme}://#{uri.host}#{uri.path}"
|
22
|
+
|
18
23
|
# Get the page
|
19
|
-
|
24
|
+
begin
|
25
|
+
visit(url)
|
26
|
+
rescue Addressable::URI::InvalidURIError
|
27
|
+
raise Morris::ContentUnavailableError.new
|
28
|
+
end
|
20
29
|
|
21
30
|
# Grab the JSON
|
22
31
|
element = page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).first
|
32
|
+
|
33
|
+
# If the element is not found, raise a ContentUnavailableError
|
34
|
+
if element.nil?
|
35
|
+
begin
|
36
|
+
page.find(class: "not-found")
|
37
|
+
rescue Capybara::ElementNotFound
|
38
|
+
raise Morris::ContentUnavailableError.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
23
42
|
text = element.text(:all) # Gotta get the hiddent text of the element
|
24
43
|
json = JSON.parse(text)
|
25
44
|
|
@@ -21,6 +21,7 @@ options.add_argument("--enable-features=NetworkService,NetworkServiceInProcess")
|
|
21
21
|
options.add_argument("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36")
|
22
22
|
options.add_preference "password_manager_enabled", false
|
23
23
|
options.add_argument("--user-data-dir=/tmp/tarun_morris_#{SecureRandom.uuid}")
|
24
|
+
options.add_argument("--mute-audio")
|
24
25
|
|
25
26
|
Capybara.register_driver :selenium_morris do |app|
|
26
27
|
client = Selenium::WebDriver::Remote::Http::Curb.new
|
@@ -23,7 +23,8 @@ module Morris
|
|
23
23
|
|
24
24
|
start_time = Time.now
|
25
25
|
filename = "#{Morris.temp_storage_location}/morris_media_#{SecureRandom.uuid}.mp4"
|
26
|
-
line = Terrapin::CommandLine.new("yt-dlp", "-f :filetype -o :filename :url")
|
26
|
+
# line = Terrapin::CommandLine.new("yt-dlp", "-f :filetype -o :filename :url")
|
27
|
+
line = Terrapin::CommandLine.new("yt-dlp", "-f ':filetype' -o :filename :url")
|
27
28
|
|
28
29
|
line.run(filename: filename,
|
29
30
|
filetype: "mp4",
|
data/lib/morris/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Guess
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -129,7 +129,6 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
- ".byebug_history"
|
133
132
|
- ".rubocop.yml"
|
134
133
|
- CHANGELOG.md
|
135
134
|
- CODE_OF_CONDUCT.md
|
data/.byebug_history
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
exit
|
2
|
-
content_element["createTime"]
|
3
|
-
c
|
4
|
-
username
|
5
|
-
c
|
6
|
-
up
|
7
|
-
n
|
8
|
-
username
|
9
|
-
quit
|
10
|
-
Time.at(content_element["createTime"].to_i)
|
11
|
-
content_element["createTime"]
|
12
|
-
exit
|
13
|
-
pp json["__DEFAULT_SCOPE__"].keys
|
14
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["author"]
|
15
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"].keys
|
16
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["video"]["cover"]
|
17
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["video"].keys
|
18
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["video"]
|
19
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["digged"]
|
20
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["textExtra"]
|
21
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["originalItem"]
|
22
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["stats"]["diggCount"]
|
23
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["stats"]
|
24
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["challenges"
|
25
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["id"]
|
26
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["desc"]
|
27
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]["contents"]
|
28
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"].keys
|
29
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"].keys
|
30
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]
|
31
|
-
pp json["__DEFAULT_SCOPE__"]["webapp.video-detail"].keys
|
32
|
-
pp json["__DEFAULT_SCOPE__"].keys
|
33
|
-
pp json
|
34
|
-
text
|
35
|
-
json
|
36
|
-
json["__DEFAULT_SCOPE__"]
|
37
|
-
json["__DEFAULT_SCOPE"]
|
38
|
-
json.keys
|
39
|
-
json
|
40
|
-
c
|
41
|
-
quit
|
42
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).first.text(:all)
|
43
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).first.innerText
|
44
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).first.text
|
45
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).first
|
46
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).text
|
47
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false).innerText
|
48
|
-
page.all(:xpath, '//*[@id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]', visible: false)
|
49
|
-
page.all(:xpath, "*[@id='__UNIVERSAL_DATA_FOR_REHYDRATION__']", visible: false)
|
50
|
-
c
|
51
|
-
page.all(:xpath, "*[@id='__UNIVERSAL_DATA_FOR_REHYDRATION__']", visible: false)
|
52
|
-
page.all(:xpath, "script[@id='__UNIVERSAL_DATA_FOR_REHYDRATION__']", visible: false)
|
53
|
-
page.find(:xpath, "script[@id='__UNIVERSAL_DATA_FOR_REHYDRATION__']", visible: false)
|
54
|
-
page.find(:xpath, "script[@id='__UNIVERSAL_DATA_FOR_REHYDRATION__']")
|
55
|
-
exit
|
56
|
-
File.size(result.video_file) > 500000
|
57
|
-
File.size(result.video_file)
|
58
|
-
File.exist?(result.video_file)
|
59
|
-
result.video_file
|
60
|
-
result[:path]
|
61
|
-
result
|
62
|
-
exit
|
63
|
-
RUBY_ENV
|
64
|
-
video_hash
|
65
|
-
up
|
66
|
-
exit
|
67
|
-
video_hash.transform_keys(&:to_s)
|
68
|
-
video_hash.strinify_keys
|
69
|
-
video_hash
|
70
|
-
up
|
71
|
-
exit
|
72
|
-
video_hash
|
73
|
-
@id
|
74
|
-
@iid
|
75
|
-
up
|
76
|
-
@id
|
77
|
-
line
|
78
|
-
c
|
79
|
-
@id
|
80
|
-
e
|
81
|
-
c
|
82
|
-
e
|
83
|
-
exit
|
84
|
-
e
|
85
|
-
c
|