video_grabber 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/video_grabber/config.rb +2 -1
- data/lib/video_grabber/scraper.rb +4 -4
- data/lib/video_grabber/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42b16033bdf111d37375a5253c02a89d04d5a93e
|
4
|
+
data.tar.gz: fb3cf3dbd626dd8c51e9391981b56598445d5f34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 020ea57cb51f5b61abd8b64fb0a7ca7e6e290f0a50c33a801d3641be0b4953e03b7eede781ea87498f01afba6d3857600a49d5cdf52cf83521303f4a3401291e
|
7
|
+
data.tar.gz: 4e2677496204205b512e59d9209a50d39ca5e0ec92f49df5ceaae2959b2654e167632b5a5eb4db3881b4ab75b926b202f5d154ca885b39ac66fba0079c9bfe03
|
data/README.md
CHANGED
@@ -69,7 +69,7 @@ Or you can directly pass the param `keep_browser_open` during initialization.
|
|
69
69
|
- **timeout:** *(default: 60)* The timeout for the scraper. Will trigger a `VideoGrabber::Timeout` if the delay is met.
|
70
70
|
- **keep_browser_open** *(default: false)* If activated, will keep the scraper's browser open as long as you do not stop it (using the `stop` public method.).
|
71
71
|
- **headless_enabled** *(default: true)* If disabled, will open your Firefox browser to crawl your links.
|
72
|
-
- **
|
72
|
+
- **html_attributes** *(default: {controls: true})* This option enables you to pass html attributes that will be passed to your crawled links elements.
|
73
73
|
- **firefox_extension_path** If passed, your Scraper instance will run using the given extension (`.xpi` file). Useful if you want to benefit from an Adblocker for instance
|
74
74
|
|
75
75
|
## Versioning
|
data/lib/video_grabber/config.rb
CHANGED
@@ -23,12 +23,13 @@ module VideoGrabber
|
|
23
23
|
class Configuration
|
24
24
|
|
25
25
|
attr_accessor :url, :keep_browser_open, :timeout, :headless_enabled,
|
26
|
-
:firefox_extension_path, :
|
26
|
+
:firefox_extension_path, :html_attributes
|
27
27
|
|
28
28
|
def initialize
|
29
29
|
@keep_browser_open = false
|
30
30
|
@timeout = 60
|
31
31
|
@headless_enabled = true
|
32
|
+
@html_attributes = { controls: true }
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -2,7 +2,7 @@ module VideoGrabber
|
|
2
2
|
class Scraper
|
3
3
|
|
4
4
|
attr_reader :url, :browser, :timeout, :keep_browser_open, :headless_enabled,
|
5
|
-
:firefox_extension_path, :profile, :
|
5
|
+
:firefox_extension_path, :profile, :html_attributes
|
6
6
|
|
7
7
|
def initialize(config)
|
8
8
|
@keep_browser_open = config.keep_browser_open
|
@@ -10,7 +10,7 @@ module VideoGrabber
|
|
10
10
|
@timeout = config.timeout
|
11
11
|
@headless_enabled = config.headless_enabled
|
12
12
|
@firefox_extension_path = config.firefox_extension_path
|
13
|
-
@
|
13
|
+
@html_attributes = config.html_attributes
|
14
14
|
end
|
15
15
|
|
16
16
|
def start
|
@@ -74,13 +74,13 @@ module VideoGrabber
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def add_attributes(list)
|
77
|
-
return unless
|
77
|
+
return unless html_attributes
|
78
78
|
|
79
79
|
list.map do |element|
|
80
80
|
|
81
81
|
parsed_element = Nokogiri::XML(element)
|
82
82
|
|
83
|
-
|
83
|
+
html_attributes.each do |key, value|
|
84
84
|
parsed_element.xpath('//video').first.set_attribute(key, value)
|
85
85
|
end
|
86
86
|
|