morris 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07cf83296ce2b6ecdb52c4afe1b92d63fe861e57327462886cc1ba5f144e2ce5
4
- data.tar.gz: 72d9d028fa9ee0490be70c41784de98f495774eaf25d17cb42865f182ca6c1a8
3
+ metadata.gz: 6532b430aabd03227472ecbffca87240f944fe0fb5308f5436b033a54fb9879f
4
+ data.tar.gz: af5ec6041a761da92ed19d9248aff5a3818c62f0f156d0861fd41c8c972f9a36
5
5
  SHA512:
6
- metadata.gz: d4af8e95bcd1b2ff5c9008f8f8a6ade8bc6e366b6ec96c349abb4298d9a4bf752fcda8bb7dbc7729c3ecd23b91d33dd85b5f3fa0696f21ec5016d00c53f72f17
7
- data.tar.gz: f4eb227b310d4ef27bfd346c09f4604bfa29e038346429e1ab2aa5cdfe56f20226347e12e6b3f8feab4e34ce5792ae9e43f46be3e3e789df5956da82230bdd47
6
+ metadata.gz: cc49d05f28a5623c67ecb8e89c192991365d065f22963be72c731723697652ce8de7891278bdcbb4b70294268c131d27a4ab655b7193b967d5733c2bd8c2b5d2
7
+ data.tar.gz: 1ccf7a3aa96ad633958e793474dccba13fa743a52fcefdbf2929f11fe3fa2e2810dffd79b7e150bc2aebf736203dafedaabe3ea91f8526e72eaab5e6f2701c6c
@@ -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
- visit(url)
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 0 -o :filename :url")
27
28
 
28
29
  line.run(filename: filename,
29
30
  filetype: "mp4",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Morris
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.1
4
+ version: 0.1.2
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-03-05 00:00:00.000000000 Z
11
+ date: 2024-03-14 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