ehbrs-tools 0.25.1 → 0.26.0

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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +30 -14
  3. data/lib/ehbrs/{core_ext.rb → tools/core_ext.rb} +0 -0
  4. data/lib/ehbrs/tools/runner/finances/bb_browser.rb +1 -1
  5. data/lib/ehbrs/tools/runner/fs/selected.rb +1 -1
  6. data/lib/ehbrs/tools/runner/music/lyrics.rb +69 -0
  7. data/lib/ehbrs/tools/runner/web_utils/videos/upload.rb +1 -1
  8. data/lib/ehbrs/tools/version.rb +1 -1
  9. data/vendor/aranha-parsers/aranha-parsers.gemspec +1 -0
  10. data/vendor/aranha-parsers/lib/aranha/parsers/rspec/setup.rb +1 -1
  11. data/vendor/aranha-parsers/lib/aranha/parsers/rspec/{source_target_fixtures_example.rb → shared_examples/source_target_fixtures.rb} +0 -0
  12. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/fetch_content_error.rb +10 -0
  13. data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +15 -2
  14. data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
  15. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/compact.rb +22 -0
  16. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +1 -1
  17. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/compact.rb +20 -0
  18. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/delimited.rb +16 -0
  19. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/string_delimited.rb +70 -0
  20. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  21. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/compact_spec.rb +20 -0
  22. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/compact_spec.rb +20 -0
  23. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/string/delimited_spec.rb +34 -0
  24. data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +3 -0
  25. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music.rb +9 -0
  26. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
  27. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +31 -0
  28. data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
  29. data/vendor/ultimate_lyrics/Gemfile +5 -0
  30. data/vendor/ultimate_lyrics/bin/download_parser_spec_files.rb +94 -0
  31. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/field.rb +83 -0
  32. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/lyrics.rb +13 -0
  33. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/parser.rb +28 -0
  34. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/exclude_item.rb +17 -0
  35. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/extract_item.rb +21 -0
  36. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/item.rb +48 -0
  37. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/replace_fields.rb +13 -0
  38. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/rule.rb +52 -0
  39. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider/url_format.rb +21 -0
  40. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider.rb +92 -0
  41. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider_search.rb +43 -0
  42. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/providers_data.xml +355 -0
  43. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/song_metadata/field.rb +24 -0
  44. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/song_metadata.rb +28 -0
  45. data/vendor/ultimate_lyrics/lib/ultimate_lyrics/version.rb +5 -0
  46. data/vendor/ultimate_lyrics/lib/ultimate_lyrics.rb +7 -0
  47. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec.rb +20 -0
  48. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.source.html +8 -0
  49. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.target.yaml +3 -0
  50. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.url +1 -0
  51. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.source.html +8 -0
  52. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.target.yaml +3 -0
  53. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.url +1 -0
  54. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.source.html +193 -0
  55. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.target.yaml +3 -0
  56. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.url +1 -0
  57. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.source.html +193 -0
  58. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.target.yaml +3 -0
  59. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.url +1 -0
  60. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.source.html +87 -0
  61. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.target.yaml +36 -0
  62. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__michael_jackson_thriller.url +1 -0
  63. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.source.html +4 -0
  64. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.target.yaml +5 -0
  65. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.url +1 -0
  66. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.source.html +2 -0
  67. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.target.yaml +3 -0
  68. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.url +1 -0
  69. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.source.html +2 -0
  70. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.target.yaml +3 -0
  71. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.url +1 -0
  72. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.source.html +101 -0
  73. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.target.yaml +3 -0
  74. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.url +1 -0
  75. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.source.html +29 -0
  76. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.target.yaml +3 -0
  77. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.url +1 -0
  78. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.source.html +29 -0
  79. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.target.yaml +3 -0
  80. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.url +1 -0
  81. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.source.html +1298 -0
  82. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.target.yaml +3 -0
  83. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.url +1 -0
  84. data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/provider_search_spec.rb +72 -0
  85. data/vendor/ultimate_lyrics/spec/rubocop_spec.rb +3 -0
  86. data/vendor/ultimate_lyrics/spec/spec_helper.rb +4 -0
  87. data/vendor/ultimate_lyrics/ultimate_lyrics.gemspec +19 -0
  88. metadata +75 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd84e165d6c571aba1ae27995dd9a975089005db9590f6fadb5fccc9fbbc8525
4
- data.tar.gz: 10c2d2ca5902c1e5952f56d8400a176c898f40519675dd740ecc20f9fe8f5197
3
+ metadata.gz: ed1aa5f7815ed7b0d48dafd1adbe15fefc1d9b65c1f88b573b11c4f0f83dcb9a
4
+ data.tar.gz: 1410d0c2c225cb81a266c96c6e835169db6f05407f474fad319e23a2ac0be0cf
5
5
  SHA512:
6
- metadata.gz: 8c41cea11d8cf3f1a531b84efae67be1604bc4127323280bb6da2111b546f4580fa6856d330707588d610130d0d76454990c7acf3918d769d06271ad0fe9a412
7
- data.tar.gz: 961078668e064e54dc30c3e93c53fe82bbfe4ef8b1a7c927f63381a12e56e880ef695948c7174c9fd7889c3f2d0df7c7b25c2f4edb75a94e9968e6dd87386d87
6
+ metadata.gz: d5a5e0d55099bad71f3100b9ce17cc0fff3d6962543da41e43919536ded40e9a6d01ab1cb85514c1e73660e78065fc9f02cf7d0bafc0959f204b7fda1ba45ede
7
+ data.tar.gz: 8c37bccb70f1f5e2190b4102914b28fac6658f96ec7cbb56e2db606e3675bddddb149986eb300703539e754dbbe5d85be08f94723066799efad4a418f4ca5bd2
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ehbrs-tools (0.25.1)
4
+ ehbrs-tools (0.26.0)
5
5
  avm-tools (~> 0.82, >= 0.82.1)
6
6
  eac_cli (~> 0.12, >= 0.12.5)
7
7
  eac_ruby_utils (~> 0.71)
8
- ehbrs_ruby_utils (~> 0.8.1, ~> 0.8)
8
+ ehbrs_ruby_utils (~> 0.8, >= 0.8.1)
9
9
  filesize
10
10
  inifile (~> 3.0)
11
11
  os
@@ -14,12 +14,13 @@ PATH
14
14
  PATH
15
15
  remote: vendor/aranha-parsers
16
16
  specs:
17
- aranha-parsers (0.8.3)
17
+ aranha-parsers (0.8.5)
18
18
  activesupport (>= 4.0.0)
19
19
  addressable (~> 2.7)
20
20
  curb (~> 0.9.10)
21
21
  eac_ruby_utils (~> 0.74)
22
22
  httpclient (~> 2.8, >= 2.8.3)
23
+ nokogiri (~> 1.12, >= 1.12.4)
23
24
  ofx-parser (~> 1.1.0)
24
25
 
25
26
  PATH
@@ -62,7 +63,7 @@ PATH
62
63
  PATH
63
64
  remote: vendor/eac_ruby_utils
64
65
  specs:
65
- eac_ruby_utils (0.74.0)
66
+ eac_ruby_utils (0.75.0)
66
67
  activesupport (>= 4.0)
67
68
  addressable (~> 2.6)
68
69
  filesize
@@ -71,9 +72,19 @@ PATH
71
72
  PATH
72
73
  remote: vendor/ehbrs_ruby_utils
73
74
  specs:
74
- ehbrs_ruby_utils (0.8.1)
75
+ ehbrs_ruby_utils (0.10.0)
76
+ aranha-parsers (~> 0.8, >= 0.8.5)
75
77
  eac_ruby_utils (~> 0.70)
76
78
  eac_templates (~> 0.1, >= 0.1.1)
79
+ taglib-ruby (~> 1.1)
80
+ ultimate_lyrics (~> 0.1)
81
+
82
+ PATH
83
+ remote: vendor/ultimate_lyrics
84
+ specs:
85
+ ultimate_lyrics (0.1.0)
86
+ aranha-parsers (~> 0.8, >= 0.8.5)
87
+ eac_ruby_utils (~> 0.74)
77
88
 
78
89
  GEM
79
90
  remote: https://rubygems.org/
@@ -88,23 +99,23 @@ GEM
88
99
  public_suffix (>= 2.0.2, < 5.0)
89
100
  asciidoctor (2.0.16)
90
101
  ast (2.4.2)
91
- avm (0.3.0)
102
+ avm (0.3.2)
92
103
  eac_docker (~> 0.3)
93
104
  eac_git (~> 0.6)
94
105
  eac_ruby_utils (~> 0.68)
95
106
  eac_templates (~> 0.1, >= 0.1.1)
96
- avm-apps (0.4.0)
107
+ avm-apps (0.4.1)
97
108
  eac_ruby_utils (~> 0.67)
98
- avm-eac_asciidoctor_base0 (0.3.0)
109
+ avm-eac_asciidoctor_base0 (0.3.1)
99
110
  asciidoctor (~> 2.0, >= 2.0.12)
100
111
  avm-eac_webapp_base0 (~> 0.1)
101
112
  eac_ruby_utils (~> 0.63)
102
113
  os
103
114
  rouge (~> 3.26)
104
- avm-eac_webapp_base0 (0.1.0)
115
+ avm-eac_webapp_base0 (0.1.1)
105
116
  avm (~> 0.1)
106
117
  eac_ruby_utils (~> 0.68)
107
- avm-tools (0.104.0)
118
+ avm-tools (0.105.0)
108
119
  aranha-parsers (~> 0.4)
109
120
  asciidoctor (~> 2.0, >= 2.0.12)
110
121
  avm (~> 0.1)
@@ -153,10 +164,10 @@ GEM
153
164
  eac_ruby_gems_utils (0.9.5)
154
165
  bundler (~> 2.2, >= 2.2.17)
155
166
  eac_ruby_utils (~> 0.70)
156
- eac_templates (0.1.1)
167
+ eac_templates (0.1.2)
157
168
  eac_config (~> 0.5)
158
169
  eac_ruby_utils (~> 0.64)
159
- faraday (1.7.0)
170
+ faraday (1.8.0)
160
171
  faraday-em_http (~> 1.0)
161
172
  faraday-em_synchrony (~> 1.0)
162
173
  faraday-excon (~> 1.1)
@@ -190,20 +201,23 @@ GEM
190
201
  minitest (5.14.4)
191
202
  multipart-post (2.1.1)
192
203
  net-ssh (4.2.0)
204
+ nokogiri (1.12.4-x86_64-linux)
205
+ racc (~> 1.4)
193
206
  ofx-parser (1.1.0)
194
207
  hpricot (>= 0.6)
195
208
  os (1.1.1)
196
- parallel (1.20.1)
209
+ parallel (1.21.0)
197
210
  parseconfig (1.1.0)
198
211
  parser (3.0.2.0)
199
212
  ast (~> 2.4.1)
200
213
  parslet (1.8.2)
201
214
  public_suffix (4.0.6)
215
+ racc (1.5.2)
202
216
  rack (2.2.3)
203
217
  rainbow (3.0.0)
204
218
  rchardet (1.8.0)
205
219
  rexml (3.2.5)
206
- rouge (3.26.0)
220
+ rouge (3.26.1)
207
221
  rspec (3.10.0)
208
222
  rspec-core (~> 3.10.0)
209
223
  rspec-expectations (~> 3.10.0)
@@ -236,6 +250,7 @@ GEM
236
250
  selenium-webdriver (3.142.7)
237
251
  childprocess (>= 0.5, < 4.0)
238
252
  rubyzip (>= 1.2.2)
253
+ taglib-ruby (1.1.0)
239
254
  telegram-bot-ruby (0.16.0)
240
255
  dry-inflector
241
256
  faraday
@@ -264,6 +279,7 @@ DEPENDENCIES
264
279
  eac_ruby_utils!
265
280
  ehbrs-tools!
266
281
  ehbrs_ruby_utils!
282
+ ultimate_lyrics!
267
283
 
268
284
  BUNDLED WITH
269
285
  2.2.25
File without changes
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ehbrs/core_ext'
3
+ require 'ehbrs/tools/core_ext'
4
4
  require 'ehbrs_ruby_utils/finances/bb_browser/docker_image'
5
5
 
6
6
  module Ehbrs
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/envs'
4
4
  require 'eac_ruby_utils/fs/clearable_directory'
5
- require 'ehbrs/core_ext'
5
+ require 'ehbrs/tools/core_ext'
6
6
 
7
7
  module Ehbrs
8
8
  module Tools
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs_cache'
4
+ require 'ehbrs/tools/core_ext'
5
+ require 'ehbrs_ruby_utils/videos/container'
6
+ require 'ultimate_lyrics/provider'
7
+
8
+ module Ehbrs
9
+ module Tools
10
+ class Runner
11
+ class Music
12
+ class Lyrics
13
+ DEFAULT_PROVIDER = 'lyrics.com'
14
+
15
+ runner_with :help, :output do
16
+ arg_opt '-p', '--provider', "Nome do provedor [Nome do #{DEFAULT_PROVIDER}]"
17
+ pos_arg :file
18
+ end
19
+
20
+ def run
21
+ start_banner
22
+ show_results
23
+ end
24
+
25
+ def show_results
26
+ if lyrics.found?
27
+ success 'Lyrics found'
28
+ run_output
29
+ else
30
+ fatal_error 'No lyric found'
31
+ end
32
+ end
33
+
34
+ def start_banner
35
+ infov 'File', file
36
+ %w[artist album track title].each do |attr|
37
+ infov attr.humanize, container.tag_file.tag.send(attr)
38
+ end
39
+ infov 'Selected provider', provider
40
+ end
41
+
42
+ def container_uncached
43
+ ::EhbrsRubyUtils::Videos::Container.from_file(file)
44
+ end
45
+
46
+ def file
47
+ parsed.file.to_pathname
48
+ end
49
+
50
+ def lyrics_uncached
51
+ container.lyrics_by_provider(provider)
52
+ end
53
+
54
+ def output_content
55
+ lyrics.text
56
+ end
57
+
58
+ def provider_uncached
59
+ ::UltimateLyrics::Provider.by_name(provider_name)
60
+ end
61
+
62
+ def provider_name
63
+ parsed.provider.if_present(DEFAULT_PROVIDER)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -32,7 +32,7 @@ module Ehbrs
32
32
  '/videos/files/import',
33
33
  method: :put,
34
34
  body: {
35
- 'videos_tableless_local_import_list[list_file]' => ::File.new(files_list_path)
35
+ 'videos_local_files_import_list[list_file]' => ::File.new(files_list_path)
36
36
  },
37
37
  header: {
38
38
  'Accept' => 'application/json'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.25.1'
5
+ VERSION = '0.26.0'
6
6
  end
7
7
  end
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency 'curb', '~> 0.9.10'
18
18
  s.add_dependency 'eac_ruby_utils', '~> 0.74'
19
19
  s.add_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
20
+ s.add_dependency 'nokogiri', '~> 1.12', '>= 1.12.4'
20
21
  s.add_dependency 'ofx-parser', '~> 1.1.0'
21
22
 
22
23
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3', '>= 0.3.3'
@@ -7,7 +7,7 @@ module Aranha
7
7
  module Rspec
8
8
  module Setup
9
9
  def self.extended(_setup_obj)
10
- require 'aranha/parsers/rspec/source_target_fixtures_example'
10
+ require 'aranha/parsers/rspec/shared_examples/source_target_fixtures'
11
11
  end
12
12
  end
13
13
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aranha
4
+ module Parsers
5
+ class SourceAddress
6
+ class FetchContentError < ::RuntimeError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'addressable'
4
4
  require 'curb'
5
+ require 'aranha/parsers/source_address/fetch_content_error'
5
6
 
6
7
  module Aranha
7
8
  module Parsers
@@ -34,15 +35,27 @@ module Aranha
34
35
  def content
35
36
  c = ::Curl::Easy.new(url)
36
37
  c.follow_location = true
37
- raise "Curl perform failed (URL: #{url})" unless c.perform
38
+ curl_perform(c)
38
39
  return c.body_str if c.status.to_i == 200
39
40
 
40
- raise "Get #{url} returned #{c.status.to_i}"
41
+ raise ::Aranha::Parsers::SourceAddress::FetchContentError,
42
+ "Get #{url} returned #{c.status.to_i}"
41
43
  end
42
44
 
43
45
  def serialize
44
46
  url
45
47
  end
48
+
49
+ private
50
+
51
+ def curl_perform(curl)
52
+ unless curl.perform
53
+ raise(::Aranha::Parsers::SourceAddress::FetchContentError,
54
+ "Curl perform failed (URL: #{url})")
55
+ end
56
+ rescue Curl::Err::CurlError => e
57
+ raise ::Aranha::Parsers::SourceAddress::FetchContentError, "CURL error: #{e.class.name}"
58
+ end
46
59
  end
47
60
  end
48
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Parsers
5
- VERSION = '0.8.3'
5
+ VERSION = '0.8.5'
6
6
  end
7
7
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Compact
5
+ attr_reader :object, :attributes
6
+
7
+ def initialize(object, attributes)
8
+ @object = object
9
+ @attributes = attributes
10
+ end
11
+
12
+ # @return [Array]
13
+ def to_a
14
+ attributes.map { |attr| object.send(attr) }
15
+ end
16
+
17
+ # @return [Hash]
18
+ def to_h
19
+ attributes.map { |attr| [attr.to_sym, object.send(attr)] }.to_h
20
+ end
21
+ end
22
+ end
@@ -6,7 +6,7 @@ require 'tmpdir'
6
6
  module EacRubyUtils
7
7
  class << self
8
8
  def fs_cache
9
- @fs_cache ||= ::EacRubyUtils::FilesystemCache.new(::Dir.tmpdir, 'eac_ruby_utils', '.cache')
9
+ @fs_cache ||= ::EacRubyUtils::FilesystemCache.new(::Dir.tmpdir, 'eac_ruby_utils_fs_cache')
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/compact'
4
+
5
+ class Object
6
+ # @return [EacRubyUtils::Compact]
7
+ def compact(*attributes)
8
+ ::EacRubyUtils::Compact.new(self, attributes)
9
+ end
10
+
11
+ # @return [Array]
12
+ def compact_to_a(*attributes)
13
+ compact(*attributes).to_a
14
+ end
15
+
16
+ # @return [Hash]
17
+ def compact_to_h(*attributes)
18
+ compact(*attributes).to_h
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/string_delimited'
4
+
5
+ class String
6
+ # @return [EacRubyUtils::StringDelimited]
7
+ def delimited(begin_delimiter, end_delimiter)
8
+ ::EacRubyUtils::StringDelimited.new(self, begin_delimiter, end_delimiter)
9
+ end
10
+
11
+ %w[inner outer without_inner without_outer].each do |method_suffix|
12
+ define_method "delimited_#{method_suffix}" do |begin_delimiter, end_delimiter|
13
+ delimited(begin_delimiter, end_delimiter).send(method_suffix)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class StringDelimited
5
+ attr_reader :string, :begin_delimiter, :end_delimiter
6
+
7
+ def initialize(string, begin_delimiter, end_delimiter)
8
+ @string = string
9
+ @begin_delimiter = begin_delimiter
10
+ @end_delimiter = end_delimiter
11
+ end
12
+
13
+ def inner
14
+ between_indexes(content_index, end_index).to_s
15
+ end
16
+
17
+ def outer
18
+ between_indexes(begin_index, after_end_index).to_s
19
+ end
20
+
21
+ def without_inner
22
+ without_join(
23
+ between_indexes(sos_index, content_index), between_indexes(end_index, eos_index)
24
+ )
25
+ end
26
+
27
+ def without_outer
28
+ without_join(
29
+ between_indexes(sos_index, begin_index),
30
+ between_indexes(after_end_index, eos_index)
31
+ )
32
+ end
33
+
34
+ private
35
+
36
+ def after_end_index
37
+ end_index.if_present { |v| v + end_delimiter.length }
38
+ end
39
+
40
+ def begin_index
41
+ string.index(begin_delimiter)
42
+ end
43
+
44
+ def between_indexes(a_begin_index, a_end_index)
45
+ a_begin_index && a_end_index ? string[a_begin_index, a_end_index - a_begin_index] : nil
46
+ end
47
+
48
+ def content_index
49
+ begin_index.if_present { |v| v + begin_delimiter.length }
50
+ end
51
+
52
+ def without_join(*strings)
53
+ return string if strings.any?(&:nil?)
54
+
55
+ strings.join('')
56
+ end
57
+
58
+ def end_index
59
+ content_index.if_present { |_v| string.index(end_delimiter, content_index) }
60
+ end
61
+
62
+ def sos_index
63
+ 0
64
+ end
65
+
66
+ def eos_index
67
+ string.length
68
+ end
69
+ end
70
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.74.0'
4
+ VERSION = '0.75.0'
5
5
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/compact'
4
+
5
+ ::RSpec.describe ::EacRubyUtils::Compact do
6
+ let(:object) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
7
+ let(:instance) { described_class.new(object, %w[a_attr b_attr]) }
8
+
9
+ describe '#to_a' do
10
+ it do
11
+ expect(instance.to_a).to eq(%w[a_value b_value])
12
+ end
13
+ end
14
+
15
+ describe '#to_h' do
16
+ it do
17
+ expect(instance.to_h).to eq(a_attr: 'a_value', b_attr: 'b_value')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/object/compact'
4
+
5
+ ::RSpec.describe ::Object do
6
+ let(:instance) { ::OpenStruct.new(a_attr: 'a_value', b_attr: 'b_value') }
7
+ let(:attributes) { %w[a_attr b_attr] }
8
+
9
+ describe '#compact' do
10
+ it do
11
+ expect(instance.compact_to_a(*attributes)).to eq(%w[a_value b_value])
12
+ end
13
+ end
14
+
15
+ describe '#to_h' do
16
+ it do
17
+ expect(instance.compact_to_h(*attributes)).to eq(a_attr: 'a_value', b_attr: 'b_value')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches/string/delimited'
4
+
5
+ ::RSpec.describe ::String do
6
+ let(:instance) { 'A text with <b>content between</b> tags.' }
7
+
8
+ {
9
+ ['<b>', '</b>'] => {
10
+ 'inner' => 'content between',
11
+ 'without_inner' => 'A text with <b></b> tags.',
12
+ 'outer' => '<b>content between</b>',
13
+ 'without_outer' => 'A text with tags.'
14
+ },
15
+ ['<b>', '</br>'] => {
16
+ 'inner' => '',
17
+ 'without_inner' => 'A text with <b>content between</b> tags.',
18
+ 'outer' => '',
19
+ 'without_outer' => 'A text with <b>content between</b> tags.'
20
+ }
21
+ }.each do |delimiters, expected_values|
22
+ context "when delimiters are #{delimiters}" do
23
+ let(:bdel) { delimiters[0] }
24
+ let(:edel) { delimiters[1] }
25
+
26
+ expected_values.each do |method_suffix, expected_value|
27
+ method_name = "delimited_#{method_suffix}"
28
+ it "#{method_name} should return \"#{expected_value}\"" do
29
+ expect(instance.send(method_name, bdel, edel)).to eq(expected_value)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -15,8 +15,11 @@ Gem::Specification.new do |s|
15
15
  s.files = Dir['{lib,template}/**/*']
16
16
  s.test_files = Dir['{spec}/**/*', '.rubocop.yml', '.rspec']
17
17
 
18
+ s.add_dependency 'aranha-parsers', '~> 0.8', '>= 0.8.5'
18
19
  s.add_dependency 'eac_ruby_utils', '~> 0.70'
19
20
  s.add_dependency 'eac_templates', '~> 0.1', '>= 0.1.1'
21
+ s.add_dependency 'taglib-ruby', '~> 1.1'
22
+ s.add_dependency 'ultimate_lyrics', '~> 0.1'
20
23
 
21
24
  s.add_development_dependency 'aranha-parsers', '~> 0.8'
22
25
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EhbrsRubyUtils
6
+ module Music
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.8.1'
4
+ VERSION = '0.10.0'
5
5
  end
@@ -4,23 +4,49 @@ require 'eac_ruby_utils/core_ext'
4
4
  require 'ehbrs_ruby_utils/executables'
5
5
  require 'ehbrs_ruby_utils/videos/stream'
6
6
  require 'json'
7
+ require 'taglib'
8
+ require 'ultimate_lyrics/provider_search'
9
+ require 'ultimate_lyrics/song_metadata'
7
10
 
8
11
  module EhbrsRubyUtils
9
12
  module Videos
10
13
  class Container
14
+ class << self
15
+ def from_file(path)
16
+ new(path)
17
+ end
18
+ end
19
+
11
20
  enable_simple_cache
12
21
  common_constructor :path do
13
22
  self.path = path.to_pathname
14
23
  end
15
24
 
25
+ delegate :tag, to: :tag_file
26
+ delegate :to_s, to: :path
27
+
16
28
  ::EhbrsRubyUtils::Videos::Stream.lists.codec_type.each_value do |stream_type|
17
29
  define_method stream_type.to_s.pluralize do
18
30
  streams.select { |stream| stream.codec_type == stream_type }
19
31
  end
20
32
  end
21
33
 
34
+ # @param provider [UltimateLyrics::Provider]
35
+ # @return [UltimateLyrics::Lyrics]
36
+ def lyrics_by_provider(provider)
37
+ ::UltimateLyrics::ProviderSearch.new(provider, song_metadata).lyrics
38
+ end
39
+
22
40
  private
23
41
 
42
+ # @return [UltimateLyrics::SongMetadata]
43
+ def song_metadata_uncached
44
+ ::UltimateLyrics::SongMetadata.new(
45
+ ::UltimateLyrics::SongMetadata::Field.lists.sources.values
46
+ .map { |source| [source, tag.send(source)] }.to_h
47
+ )
48
+ end
49
+
24
50
  def probe_data_uncached
25
51
  ::JSON.parse(
26
52
  ::EhbrsRubyUtils::Executables.ffprobe.command(
@@ -34,6 +60,11 @@ module EhbrsRubyUtils
34
60
  ::EhbrsRubyUtils::Videos::Stream.new(stream_ffprobe_data)
35
61
  end
36
62
  end
63
+
64
+ # @return [TagLib::FileRef]
65
+ def tag_file_uncached
66
+ ::TagLib::FileRef.new(path.to_path)
67
+ end
37
68
  end
38
69
  end
39
70
  end
@@ -35,7 +35,7 @@ module EhbrsRubyUtils
35
35
  end
36
36
  end
37
37
 
38
- %i[codec_name codec_long_name].each do |method_name|
38
+ %i[codec_name codec_long_name height width].each do |method_name|
39
39
  define_method method_name do
40
40
  ffprobe_data[method_name]
41
41
  end