searchlink 2.3.73 → 2.3.76

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/searchlink/config.rb +23 -23
  3. data/lib/searchlink/curl/html.rb +38 -38
  4. data/lib/searchlink/curl/json.rb +19 -17
  5. data/lib/searchlink/curl.rb +2 -2
  6. data/lib/searchlink/exceptions.rb +2 -2
  7. data/lib/searchlink/help.rb +13 -13
  8. data/lib/searchlink/output.rb +21 -21
  9. data/lib/searchlink/parse.rb +113 -108
  10. data/lib/searchlink/plist.rb +11 -11
  11. data/lib/searchlink/script_plugin.rb +10 -10
  12. data/lib/searchlink/search.rb +6 -6
  13. data/lib/searchlink/searches/amazon.rb +4 -4
  14. data/lib/searchlink/searches/applemusic.rb +28 -28
  15. data/lib/searchlink/searches/bitly.rb +11 -11
  16. data/lib/searchlink/searches/definition.rb +7 -7
  17. data/lib/searchlink/searches/duckduckgo.rb +31 -27
  18. data/lib/searchlink/searches/github.rb +48 -48
  19. data/lib/searchlink/searches/google.rb +16 -16
  20. data/lib/searchlink/searches/helpers/chromium.rb +46 -46
  21. data/lib/searchlink/searches/helpers/firefox.rb +20 -20
  22. data/lib/searchlink/searches/helpers/safari.rb +14 -14
  23. data/lib/searchlink/searches/history.rb +78 -78
  24. data/lib/searchlink/searches/hook.rb +5 -5
  25. data/lib/searchlink/searches/itunes.rb +37 -37
  26. data/lib/searchlink/searches/lastfm.rb +13 -13
  27. data/lib/searchlink/searches/linkding.rb +14 -14
  28. data/lib/searchlink/searches/lyrics.rb +11 -11
  29. data/lib/searchlink/searches/pinboard.rb +35 -35
  30. data/lib/searchlink/searches/social.rb +45 -56
  31. data/lib/searchlink/searches/software.rb +4 -4
  32. data/lib/searchlink/searches/spelling.rb +10 -10
  33. data/lib/searchlink/searches/spotlight.rb +4 -4
  34. data/lib/searchlink/searches/stackoverflow.rb +5 -5
  35. data/lib/searchlink/searches/tmdb.rb +17 -17
  36. data/lib/searchlink/searches/twitter.rb +8 -8
  37. data/lib/searchlink/searches/wikipedia.rb +4 -4
  38. data/lib/searchlink/searches/youtube.rb +7 -7
  39. data/lib/searchlink/searches.rb +16 -16
  40. data/lib/searchlink/semver.rb +4 -4
  41. data/lib/searchlink/string.rb +55 -55
  42. data/lib/searchlink/url.rb +30 -32
  43. data/lib/searchlink/util.rb +3 -3
  44. data/lib/searchlink/version.rb +19 -21
  45. data/lib/searchlink/which.rb +5 -5
  46. data/lib/searchlink.rb +31 -31
  47. metadata +31 -18
  48. data/lib/tokens.rb +0 -3
@@ -11,15 +11,15 @@ module SL
11
11
  # `trigger` is A regular expression that will trigger this plugin
12
12
  # when used with a bang. The one below will trigger on !lyrics or
13
13
  # !lyricse.
14
- trigger: 'lyrics?(e|e?js)?',
14
+ trigger: "lyrics?(e|e?js)?",
15
15
  # Every search that the plugin should execute should be individually
16
16
  # listed and described in the searches array. This is used for
17
17
  # completion and help generation. Do not include the bang (!) in the
18
18
  # search keyword.
19
19
  searches: [
20
- ['lyric', 'Song Lyrics Search'],
21
- ['lyrice', 'Song Lyrics Embed'],
22
- ['lyricjs', 'Song Lyrics JS Embed']
20
+ ["lyric", "Song Lyrics Search"],
21
+ ["lyrice", "Song Lyrics Embed"],
22
+ ["lyricjs", "Song Lyrics JS Embed"]
23
23
  ]
24
24
  }
25
25
  end
@@ -41,20 +41,20 @@ module SL
41
41
  # To return an embed, set url (first parameter in the return
42
42
  # array) to 'embed', and put the embed contents in the second
43
43
  # parameter.
44
- title ? ['embed', title, link_text] : false
44
+ title ? ["embed", title, link_text] : false
45
45
  else
46
46
  # Use `SL#add_error(title, text)` to add errors to the HTML
47
47
  # report. The report will only be shown if errors have been added.
48
- SL.add_error('No lyrics found', "Song lyrics for #{search_terms} not found")
48
+ SL.add_error("No lyrics found", "Song lyrics for #{search_terms} not found")
49
49
  false
50
50
  end
51
51
  when /js$/
52
52
  url, title = SL.ddg("site:genius.com #{search_terms}", link_text)
53
53
  if url
54
54
  title = js_embed(url)
55
- title ? ['embed', title, link_text] : false
55
+ title ? ["embed", title, link_text] : false
56
56
  else
57
- SL.add_error('No lyrics found', "Song lyrics for #{search_terms} not found")
57
+ SL.add_error("No lyrics found", "Song lyrics for #{search_terms} not found")
58
58
  false
59
59
  end
60
60
  else
@@ -96,13 +96,13 @@ module SL
96
96
  # `curl -SsL` is faster and easier. Curl::Html.new(url) returns a
97
97
  # new object containing :body
98
98
  body = Curl::Html.new(url).body
99
- title = body.match(/_sf_async_config.title = '(.*?) \| Genius Lyrics'/)[1].gsub(/\\/, '').sub(/ Lyrics$/, '')
99
+ title = body.match(/_sf_async_config.title = '(.*?) \| Genius Lyrics'/)[1].gsub(/\\/, "").sub(/ Lyrics$/, "")
100
100
  matches = body.scan(%r{class="Lyrics__Container-.*?>(.*?)</div><div class="LyricsFooter})
101
101
 
102
102
  lyrics = matches.join("\n")
103
103
 
104
104
  if lyrics
105
- lyrics = CGI.unescape(lyrics).gsub(%r{<br/?>}, " \n").gsub(%r{</?.*?>}, '').gsub(/&#x27;/, "'")
105
+ lyrics = CGI.unescape(lyrics).gsub(%r{<br/?>}, " \n").gsub(%r{</?.*?>}, "").gsub(/&#x27;/, "'")
106
106
  "#{title}\n\n#{lyrics.code_indent}\n"
107
107
  else
108
108
  false
@@ -117,6 +117,6 @@ module SL
117
117
  # method takes a title, a type (:search for a search plugin), and the
118
118
  # unique class. When running #register within the search class itself,
119
119
  # you can just use `self`.
120
- SL::Searches.register 'lyrics', :search, self
120
+ SL::Searches.register "lyrics", :search, self
121
121
  end
122
122
  end
@@ -2,34 +2,34 @@
2
2
 
3
3
  module SL
4
4
  class PinboardSearch
5
- PINBOARD_CACHE = SL::Util.cache_file_for('pinboard')
5
+ PINBOARD_CACHE = SL::Util.cache_file_for("pinboard")
6
6
 
7
7
  class << self
8
8
  def settings
9
9
  {
10
- trigger: 'pb',
10
+ trigger: "pb",
11
11
  searches: [
12
- ['pb', 'Pinboard Bookmark Search']
12
+ ["pb", "Pinboard Bookmark Search"]
13
13
  ]
14
14
  }
15
15
  end
16
16
 
17
17
  def pinboard_bookmarks
18
- curl = TTY::Which.which('curl')
19
- bookmarks = `#{curl} -sSL "https://api.pinboard.in/v1/posts/all?auth_token=#{SL.config['pinboard_api_key']}&format=json"`
20
- bookmarks = bookmarks.force_encoding('utf-8')
18
+ curl = TTY::Which.which("curl")
19
+ bookmarks = `#{curl} -sSL "https://api.pinboard.in/v1/posts/all?auth_token=#{SL.config["pinboard_api_key"]}&format=json"`
20
+ bookmarks = bookmarks.force_encoding("utf-8")
21
21
  bookmarks.gsub!(/[^[:ascii:]]/) do |non_ascii|
22
- non_ascii.force_encoding('utf-8')
23
- .encode('utf-16be')
24
- .unpack('H*')
22
+ non_ascii.force_encoding("utf-8")
23
+ .encode("utf-16be")
24
+ .unpack("H*")
25
25
  .gsub(/(....)/, '\u\1')
26
26
  end
27
27
 
28
- bookmarks.gsub!(/[\u{1F600}-\u{1F6FF}]/, '')
28
+ bookmarks.gsub!(/[\u{1F600}-\u{1F6FF}]/, "")
29
29
 
30
30
  bookmarks = JSON.parse(bookmarks)
31
31
  updated = Time.now
32
- { 'update_time' => updated, 'bookmarks' => bookmarks }
32
+ { "update_time" => updated, "bookmarks" => bookmarks }
33
33
  end
34
34
 
35
35
  def save_pinboard_cache(cache)
@@ -38,9 +38,9 @@ module SL
38
38
  # file = File.new(cachefile,'w')
39
39
  # file = Zlib::GzipWriter.new(File.new(cachefile,'w'))
40
40
  begin
41
- File.open(cachefile, 'wb') { |f| f.write(Marshal.dump(cache)) }
41
+ File.open(cachefile, "wb") { |f| f.write(Marshal.dump(cache)) }
42
42
  rescue IOError
43
- SL.add_error('Pinboard cache error', 'Failed to write stash to disk')
43
+ SL.add_error("Pinboard cache error", "Failed to write stash to disk")
44
44
  return false
45
45
  end
46
46
  true
@@ -57,19 +57,19 @@ module SL
57
57
  cache = Marshal.load(File.binread(cachefile))
58
58
  # file.close
59
59
  rescue IOError # Zlib::GzipFile::Error
60
- SL.add_error('Error loading pinboard cache', "IOError reading #{cachefile}")
60
+ SL.add_error("Error loading pinboard cache", "IOError reading #{cachefile}")
61
61
  cache = pinboard_bookmarks
62
62
  save_pinboard_cache(cache)
63
63
  rescue StandardError
64
- SL.add_error('Error loading pinboard cache', "StandardError reading #{cachefile}")
64
+ SL.add_error("Error loading pinboard cache", "StandardError reading #{cachefile}")
65
65
  cache = pinboard_bookmarks
66
66
  save_pinboard_cache(cache)
67
67
  end
68
- curl = TTY::Which.which('curl')
69
- updated = JSON.parse(`#{curl} -SsL 'https://api.pinboard.in/v1/posts/update?auth_token=#{SL.config['pinboard_api_key']}&format=json'`)
70
- last_bookmark = Time.parse(updated['update_time'])
71
- if cache&.key?('update_time')
72
- last_update = cache['update_time']
68
+ curl = TTY::Which.which("curl")
69
+ updated = JSON.parse(`#{curl} -SsL 'https://api.pinboard.in/v1/posts/update?auth_token=#{SL.config["pinboard_api_key"]}&format=json'`)
70
+ last_bookmark = Time.parse(updated["update_time"])
71
+ if cache&.key?("update_time")
72
+ last_update = cache["update_time"]
73
73
  refresh_cache = true if last_update < last_bookmark
74
74
  else
75
75
  refresh_cache = true
@@ -98,8 +98,8 @@ module SL
98
98
  #
99
99
  # Exact matching is case and punctuation insensitive
100
100
  def search(_, search_terms, link_text)
101
- unless SL.config['pinboard_api_key']
102
- SL.add_error('Missing Pinboard API token',
101
+ unless SL.config["pinboard_api_key"]
102
+ SL.add_error("Missing Pinboard API token",
103
103
  'Find your api key at https://pinboard.in/settings/password and add it
104
104
  to your configuration (pinboard_api_key: YOURKEY)')
105
105
  return false
@@ -112,21 +112,21 @@ module SL
112
112
  case search_terms
113
113
  when /^ *'/
114
114
  exact_match = true
115
- search_terms.gsub!(/(^ *'+|'+ *$)/, '')
115
+ search_terms.gsub!(/(^ *'+|'+ *$)/, "")
116
116
  when /%22(.*?)%22/
117
117
  match_phrases = search_terms.scan(/%22(\S.*?\S)%22/)
118
- search_terms.gsub!(/%22(\S.*?\S)%22/, '')
118
+ search_terms.gsub!(/%22(\S.*?\S)%22/, "")
119
119
  end
120
120
 
121
121
  cache = load_pinboard_cache
122
122
  # cache = pinboard_bookmarks
123
- bookmarks = cache['bookmarks']
123
+ bookmarks = cache["bookmarks"]
124
124
 
125
125
  if exact_match
126
126
  bookmarks.each do |bm|
127
- text = [bm['description'], bm['extended'], bm['tags']].join(' ')
127
+ text = [bm["description"], bm["extended"], bm["tags"]].join(" ")
128
128
 
129
- return [bm['href'], bm['description']] if text.matches_exact(search_terms)
129
+ return [bm["href"], bm["description"]] if text.matches_exact(search_terms)
130
130
  end
131
131
 
132
132
  return false
@@ -135,7 +135,7 @@ module SL
135
135
  unless match_phrases.empty?
136
136
  bookmarks.delete_if do |bm|
137
137
  matched = tru
138
- full_text = [bm['description'], bm['extended'], bm['tags']].join(' ')
138
+ full_text = [bm["description"], bm["extended"], bm["tags"]].join(" ")
139
139
  match_phrases.each do |phrase|
140
140
  matched = false unless full_text.matches_exact(phrase)
141
141
  end
@@ -145,8 +145,8 @@ module SL
145
145
 
146
146
  matches = []
147
147
  bookmarks.each do |bm|
148
- title_tags = [bm['description'], bm['tags']].join(' ')
149
- full_text = [bm['description'], bm['extended'], bm['tags']].join(' ')
148
+ title_tags = [bm["description"], bm["tags"]].join(" ")
149
+ full_text = [bm["description"], bm["extended"], bm["tags"]].join(" ")
150
150
 
151
151
  score = if title_tags.matches_exact(search_terms)
152
152
  14.0
@@ -158,15 +158,15 @@ module SL
158
158
  0
159
159
  end
160
160
 
161
- return [bm['href'], bm['description']] if score == 14
161
+ return [bm["href"], bm["description"]] if score == 14
162
162
 
163
163
  next unless score.positive?
164
164
 
165
165
  matches.push({
166
166
  score: score,
167
- href: bm['href'],
168
- title: bm['description'],
169
- date: bm['time']
167
+ href: bm["href"],
168
+ title: bm["description"],
169
+ date: bm["time"]
170
170
  })
171
171
  end
172
172
 
@@ -180,6 +180,6 @@ module SL
180
180
  end
181
181
  end
182
182
 
183
- SL::Searches.register 'pinboard', :search, self
183
+ SL::Searches.register "pinboard", :search, self
184
184
  end
185
185
  end
@@ -5,95 +5,84 @@ module SL
5
5
  class << self
6
6
  def settings
7
7
  {
8
- trigger: '@[tfilm]',
8
+ trigger: "@[tfilm]",
9
9
  searches: [
10
- ['@t', 'Twitter Handle'],
11
- ['@f', 'Facebook Handle'],
12
- ['@i', 'Instagram Handle'],
13
- ['@l', 'LinkedIn Handle'],
14
- ['@m', 'Mastodon Handle']
15
- ]
10
+ ["@t", "Twitter Handle"],
11
+ ["@f", "Facebook Handle"],
12
+ ["@i", "Instagram Handle"],
13
+ ["@l", "LinkedIn Handle"],
14
+ ["@m", "Mastodon Handle"],
15
+ ],
16
16
  }
17
17
  end
18
18
 
19
- def search(search_type, search_terms, link_text = '')
19
+ def search(search_type, search_terms, link_text = "")
20
20
  type = case search_type
21
- when /^@t/ # twitter-ify username
22
- unless search_terms.strip =~ /^@?[0-9a-z_$]+$/i
23
- return [false, "#{search_terms} is not a valid Twitter handle", link_text]
24
-
25
- end
26
-
27
- 't'
28
- when /^@fb?/ # fb-ify username
29
- unless search_terms.strip =~ /^@?[0-9a-z_]+$/i
30
- return [false, "#{search_terms} is not a valid Facebook username", link_text]
31
-
32
- end
33
-
34
- 'f'
35
- when /^@i/ # intagramify username
36
- unless search_terms.strip =~ /^@?[0-9a-z_]+$/i
37
- return [false, "#{search_terms} is not a valid Instagram username", link_text]
38
-
39
- end
40
-
41
- 'i'
42
- when /^@l/ # linked-inify username
43
- unless search_terms.strip =~ /^@?[0-9a-z_]+$/i
44
- return [false, "#{search_terms} is not a valid LinkedIn username", link_text]
45
-
46
- end
47
-
48
- 'l'
49
- when /^@m/ # mastodonify username
50
- unless search_terms.strip =~ /^@?[0-9a-z_]+@[0-9a-z_.]+$/i
51
- return [false, "#{search_terms} is not a valid Mastodon username", link_text]
52
-
53
- end
54
-
55
- 'm'
56
- else
57
- 't'
58
- end
21
+ when /^@t/ # twitter-ify username
22
+ unless search_terms.strip =~ /^@?[0-9a-z_$]+$/i
23
+ return [false, "#{search_terms} is not a valid Twitter handle", link_text]
24
+ end
25
+
26
+ "t"
27
+ when /^@fb?/ # fb-ify username
28
+ return [false, "#{search_terms} is not a valid Facebook username", link_text] unless search_terms.strip =~ /^@?[0-9a-z_]+$/i
29
+
30
+ "f"
31
+ when /^@i/ # intagramify username
32
+ return [false, "#{search_terms} is not a valid Instagram username", link_text] unless search_terms.strip =~ /^@?[0-9a-z_]+$/i
33
+
34
+ "i"
35
+ when /^@l/ # linked-inify username
36
+ unless search_terms.strip =~ /^@?[0-9a-z_]+$/i
37
+ return [false, "#{search_terms} is not a valid LinkedIn username", link_text]
38
+ end
39
+
40
+ "l"
41
+ when /^@m/ # mastodonify username
42
+ return [false, "#{search_terms} is not a valid Mastodon username", link_text] unless search_terms.strip =~ /^@?[0-9a-z_]+@[0-9a-z_.]+$/i
43
+
44
+ "m"
45
+ else
46
+ "t"
47
+ end
59
48
 
60
49
  url, title = social_handle(type, search_terms)
61
- link_text = title if link_text == ''
50
+ link_text = title if link_text == ""
62
51
  [url, title, link_text]
63
52
  end
64
53
 
65
54
  def template_social(user, url, service)
66
- template = SL.config['social_template'].dup
55
+ template = SL.config["social_template"].dup
67
56
 
68
57
  template.sub!(/%user%/, user)
69
58
  template.sub!(/%service%/, service)
70
- template.sub!(/%url%/, url.sub(%r{^https?://(www\.)?}, '').sub(%r{/$}, ''))
59
+ template.sub!(/%url%/, url.sub(%r{^https?://(www\.)?}, "").sub(%r{/$}, ""))
71
60
 
72
61
  template
73
62
  end
74
63
 
75
64
  def social_handle(type, term)
76
- handle = term.sub(/^@/, '').strip
65
+ handle = term.sub(/^@/, "").strip
77
66
 
78
67
  case type
79
68
  when /^t/i
80
69
  url = "https://twitter.com/#{handle}"
81
- title = template_social(handle, url, 'Twitter')
70
+ title = template_social(handle, url, "Twitter")
82
71
  when /^f/i
83
72
  url = "https://www.facebook.com/#{handle}"
84
- title = template_social(handle, url, 'Facebook')
73
+ title = template_social(handle, url, "Facebook")
85
74
  when /^l/i
86
75
  url = "https://www.linkedin.com/in/#{handle}/"
87
- title = template_social(handle, url, 'LinkedIn')
76
+ title = template_social(handle, url, "LinkedIn")
88
77
  when /^i/i
89
78
  url = "https://www.instagram.com/#{handle}/"
90
- title = template_social(handle, url, 'Instagram')
79
+ title = template_social(handle, url, "Instagram")
91
80
  when /^m/i
92
81
  parts = handle.split(/@/)
93
82
  return [false, term] unless parts.count == 2
94
83
 
95
84
  url = "https://#{parts[1]}/@#{parts[0]}"
96
- title = template_social(handle, url, 'Mastodon')
85
+ title = template_social(handle, url, "Mastodon")
97
86
  else
98
87
  [false, term]
99
88
  end
@@ -102,6 +91,6 @@ module SL
102
91
  end
103
92
  end
104
93
 
105
- SL::Searches.register 'social', :search, self
94
+ SL::Searches.register "social", :search, self
106
95
  end
107
96
  end
@@ -6,9 +6,9 @@ module SL
6
6
  class << self
7
7
  def settings
8
8
  {
9
- trigger: 's',
9
+ trigger: "s",
10
10
  searches: [
11
- ['s', 'Software Search']
11
+ ["s", "Software Search"]
12
12
  ]
13
13
  }
14
14
  end
@@ -18,12 +18,12 @@ module SL
18
18
  search_url = %(#{excludes.map { |x| "-site:#{x}" }.join(' ')} #{search_terms} app)
19
19
 
20
20
  url, title, link_text = SL.ddg(search_url, link_text)
21
- link_text = title if link_text == '' && !SL.titleize
21
+ link_text = title if link_text == "" && !SL.titleize
22
22
 
23
23
  [url, title, link_text]
24
24
  end
25
25
  end
26
26
 
27
- SL::Searches.register 'software', :search, self
27
+ SL::Searches.register "software", :search, self
28
28
  end
29
29
  end
@@ -6,10 +6,10 @@ module SL
6
6
  class << self
7
7
  def settings
8
8
  {
9
- trigger: 'sp(?:ell)?',
9
+ trigger: "sp(?:ell)?",
10
10
  searches: [
11
11
  %w[sp Spelling],
12
- ['spell', nil]
12
+ ["spell", nil]
13
13
  ]
14
14
  }
15
15
  end
@@ -21,33 +21,33 @@ module SL
21
21
  end
22
22
  end
23
23
 
24
- SL::Searches.register 'spelling', :search, self
24
+ SL::Searches.register "spelling", :search, self
25
25
  end
26
26
 
27
27
  class << self
28
28
  def spell(phrase)
29
- aspell = if File.exist?('/usr/local/bin/aspell')
30
- '/usr/local/bin/aspell'
31
- elsif File.exist?('/opt/homebrew/bin/aspell')
32
- '/opt/homebrew/bin/aspell'
29
+ aspell = if File.exist?("/usr/local/bin/aspell")
30
+ "/usr/local/bin/aspell"
31
+ elsif File.exist?("/opt/homebrew/bin/aspell")
32
+ "/opt/homebrew/bin/aspell"
33
33
  else
34
34
  `which aspell`.strip
35
35
  end
36
36
 
37
37
  if aspell.nil? || aspell.empty?
38
- SL.add_error('Missing aspell', 'Install aspell in to allow spelling corrections')
38
+ SL.add_error("Missing aspell", "Install aspell in to allow spelling corrections")
39
39
  return false
40
40
  end
41
41
 
42
42
  words = phrase.split(/\b/)
43
- output = ''
43
+ output = ""
44
44
  words.each do |w|
45
45
  if w =~ /[A-Za-z]+/
46
46
  spell_res = `echo "#{w}" | #{aspell} --sug-mode=bad-spellers -C pipe | head -n 2 | tail -n 1`
47
47
  if spell_res.strip == "\*"
48
48
  output += w
49
49
  else
50
- spell_res.sub!(/.*?: /, '')
50
+ spell_res.sub!(/.*?: /, "")
51
51
  results = spell_res.split(/, /).delete_if { |word| phrase =~ /^[a-z]/ && word =~ /[A-Z]/ }
52
52
  output += results[0]
53
53
  end
@@ -6,9 +6,9 @@ module SL
6
6
  class << self
7
7
  def settings
8
8
  {
9
- trigger: 'file',
9
+ trigger: "file",
10
10
  searches: [
11
- ['file', 'Spotlight Search']
11
+ ["file", "Spotlight Search"]
12
12
  ]
13
13
  }
14
14
  end
@@ -17,7 +17,7 @@ module SL
17
17
  query = search_terms.gsub(/%22/, '"')
18
18
  matches = `mdfind '#{query}' 2>/dev/null`.strip.split(/\n/)
19
19
  res = matches.min_by { |r| File.basename(r).length }
20
- return [false, query, link_text] if res.strip.empty?
20
+ return [false, query, link_text] if res.nil? || res.strip.empty?
21
21
 
22
22
  title = File.basename(res)
23
23
  link_text = title if link_text.strip.empty? || link_text == search_terms
@@ -25,6 +25,6 @@ module SL
25
25
  end
26
26
  end
27
27
 
28
- SL::Searches.register 'spotlight', :search, self
28
+ SL::Searches.register "spotlight", :search, self
29
29
  end
30
30
  end
@@ -6,17 +6,17 @@ module SL
6
6
  class << self
7
7
  def settings
8
8
  {
9
- trigger: 'soa?',
9
+ trigger: "soa?",
10
10
  searches: [
11
- ['so', 'StackOverflow Search'],
12
- ['soa', 'StackOverflow Accepted Answer']
11
+ ["so", "StackOverflow Search"],
12
+ ["soa", "StackOverflow Accepted Answer"]
13
13
  ]
14
14
  }
15
15
  end
16
16
 
17
17
  def search(search_type, search_terms, link_text)
18
18
  url, title, link_text = SL.ddg("site:stackoverflow.com #{search_terms}", link_text)
19
- link_text = title if link_text == '' && !SL.titleize
19
+ link_text = title if link_text == "" && !SL.titleize
20
20
 
21
21
  if search_type =~ /a$/
22
22
  body = `curl -SsL #{url}`.strip
@@ -28,6 +28,6 @@ module SL
28
28
  end
29
29
  end
30
30
 
31
- SL::Searches.register 'stackoverflow', :search, self
31
+ SL::Searches.register "stackoverflow", :search, self
32
32
  end
33
33
  end
@@ -6,12 +6,12 @@ module SL
6
6
  class << self
7
7
  def settings
8
8
  {
9
- trigger: 'tmdb[amt]?',
9
+ trigger: "tmdb[amt]?",
10
10
  searches: [
11
- ['tmdb', 'TMDB Multi Search'],
12
- ['tmdba', 'TMDB Actor Search'],
13
- ['tmdbm', 'TMDB Movie Search'],
14
- ['tmdbt', 'TMDB TV Search']
11
+ ["tmdb", "TMDB Multi Search"],
12
+ ["tmdba", "TMDB Actor Search"],
13
+ ["tmdbm", "TMDB Movie Search"],
14
+ ["tmdbt", "TMDB TV Search"]
15
15
  ]
16
16
  }
17
17
  end
@@ -19,23 +19,23 @@ module SL
19
19
  def search(search_type, terms, link_text)
20
20
  type = case search_type
21
21
  when /t$/
22
- 'tv'
22
+ "tv"
23
23
  when /m$/
24
- 'movie'
24
+ "movie"
25
25
  when /a$/
26
- 'person'
26
+ "person"
27
27
  else
28
- 'multi'
28
+ "multi"
29
29
  end
30
30
  body = `/usr/bin/curl -sSL 'https://api.themoviedb.org/3/search/#{type}?query=#{terms.url_encode}&api_key=2bd76548656d92517f14d64766e87a02'`
31
31
  data = JSON.parse(body)
32
- if data.key?('results') && data['results'].count.positive?
33
- res = data['results'][0]
34
- type = res['media_type'] if type == 'multi'
35
- id = res['id']
32
+ if data.key?("results") && data["results"].count.positive?
33
+ res = data["results"][0]
34
+ type = res["media_type"] if type == "multi"
35
+ id = res["id"]
36
36
  url = "https://www.themoviedb.org/#{type}/#{id}"
37
- title = res['name']
38
- title ||= res['title']
37
+ title = res["name"]
38
+ title ||= res["title"]
39
39
  title ||= terms
40
40
  else
41
41
  url, title, link_text = SL.ddg("site:imdb.com #{terms}", link_text)
@@ -43,12 +43,12 @@ module SL
43
43
  return false unless url
44
44
  end
45
45
 
46
- link_text = title if link_text == '' && !SL.titleize
46
+ link_text = title if link_text == "" && !SL.titleize
47
47
 
48
48
  [url, title, link_text]
49
49
  end
50
50
  end
51
51
 
52
- SL::Searches.register 'tmdb', :search, self
52
+ SL::Searches.register "tmdb", :search, self
53
53
  end
54
54
  end
@@ -5,9 +5,9 @@ module SL
5
5
  class << self
6
6
  def settings
7
7
  {
8
- trigger: 'te',
8
+ trigger: "te",
9
9
  searches: [
10
- ['te', 'Twitter Embed']
10
+ ["te", "Twitter Embed"]
11
11
  ]
12
12
  }
13
13
  end
@@ -16,7 +16,7 @@ module SL
16
16
  if SL::URL.url?(search_terms) && search_terms =~ %r{^https://twitter.com/}
17
17
  url, title = twitter_embed(search_terms)
18
18
  else
19
- SL.add_error('Invalid Tweet URL', "#{search_terms} is not a valid link to a tweet or timeline")
19
+ SL.add_error("Invalid Tweet URL", "#{search_terms} is not a valid link to a tweet or timeline")
20
20
  url = false
21
21
  title = false
22
22
  end
@@ -29,20 +29,20 @@ module SL
29
29
  if res
30
30
  begin
31
31
  json = JSON.parse(res)
32
- url = 'embed'
33
- title = json['html']
32
+ url = "embed"
33
+ title = json["html"]
34
34
  rescue StandardError
35
- SL.add_error('Tweet Error', 'Error retrieving tweet')
35
+ SL.add_error("Tweet Error", "Error retrieving tweet")
36
36
  url = false
37
37
  title = tweet
38
38
  end
39
39
  else
40
- return [false, 'Error retrieving tweet']
40
+ return [false, "Error retrieving tweet"]
41
41
  end
42
42
  [url, title]
43
43
  end
44
44
  end
45
45
 
46
- SL::Searches.register 'twitter', :search, self
46
+ SL::Searches.register "twitter", :search, self
47
47
  end
48
48
  end