lita-youtube-me 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: b69c15d7418f23826ab51582155b6a0f5aeefea6
4
- data.tar.gz: 85623f1c85cb60c6e29bfa91389f8479e706406d
3
+ metadata.gz: d57dd7c41c391ea30dc027af62f5842eb24a78e8
4
+ data.tar.gz: e410dbb8d7e0029891fb66ab494506079b2102fa
5
5
  SHA512:
6
- metadata.gz: cbc9658f85ca27ce1c7aee9c4bf5b7de6c0b348e90a12edb4611d08ab331d7fc1a6385b74a907f86e6984eaee2adfefd895dd48f3e735d27b68d32ed18cbf030
7
- data.tar.gz: 65a7a70f4f42160aa0a6b0de9699634d6069630262ffb3c2701b1bace3dda6ec695520b64d8f8f92644f112917ffeab3d83c3a4a899fc6f255832f3ca352b61c
6
+ metadata.gz: aee0edf7fd63f1467ed66d8700219121ab2f725911b546e18db21fa7c6f7ea252e54081cd232ff2c648a1b53ee8e53d71d77f80653b43b78eeb38ed3f81b01c8
7
+ data.tar.gz: 20d3b8395457c4b9949ec2975a886ab3c8afa4c9e51766ce8be1cd68755fe73121c59ebca79b740ec48e9ac6f4eb0e3a57616459405fa074619e2bc7bbd9bd96
@@ -1,4 +1,6 @@
1
1
  require "date"
2
+ require "uri"
3
+ require "cgi"
2
4
  require "iso8601"
3
5
 
4
6
  module Lita
@@ -15,8 +17,8 @@ module Lita
15
17
  "youtube (me) QUERY" => "Gets a YouTube video."
16
18
  })
17
19
  # Detect YouTube links in non-commands and display video info
18
- route(/\byoutube\.com\/watch\?v=([^?&#\s]+)/i, :display_info, command: false)
19
- route(/\byoutu\.be\/([^?&#\s]+)/i, :display_info, command: false)
20
+ route(/\b(youtube\.com\/watch\S+)\s*/i, :display_info, command: false)
21
+ route(/\b(youtu\.be\/\S+)\s*/i, :display_info, command: false)
20
22
 
21
23
  def find_video(response)
22
24
  query = response.matches[0][0]
@@ -38,9 +40,15 @@ module Lita
38
40
  end
39
41
  end
40
42
 
43
+ # The video id is found in the 'v' query parameter
44
+ def extract_video_id(url_string)
45
+ query = CGI.parse URI(url_string).query
46
+ query['v'].first
47
+ end
48
+
41
49
  def display_info(response)
42
50
  if config.detect_urls
43
- id = response.matches[0][0]
51
+ id = extract_video_id(response.matches[0][0])
44
52
  info_string = info(id)
45
53
  unless info_string.nil?
46
54
  response.reply info_string
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-youtube-me"
3
- spec.version = "0.0.5"
3
+ spec.version = "0.0.6"
4
4
  spec.authors = ["Taylor Lapeyre"]
5
5
  spec.email = ["taylorlapeyre@gmail.com"]
6
6
  spec.description = %q{A Lita handler that replies with a youtube URL when given a query.}
@@ -63,6 +63,12 @@ describe Lita::Handlers::YoutubeMe, lita_handler: true do
63
63
  expect(replies.first).to match(/10 minutes of DJ Mbenga saying Tacos \[10:02\] by RickFreeloader on 2011-09-12 \(\S+ views, \d+% liked\)/)
64
64
  end
65
65
 
66
+ it 'will respond with video info when given a url with multiple query params' do
67
+ registry.config.handlers.youtube_me.detect_urls = true
68
+ send_message("burrito burrito https://www.youtube.com/watch?t=81&v=wv7DfebpL7E")
69
+ expect(replies.first).to_not be_nil
70
+ end
71
+
66
72
  it "does not display video info for detected YouTube URLs when the detect_urls config variable is false" do
67
73
  registry.config.handlers.youtube_me.detect_urls = false
68
74
  send_message("https://www.youtube.com/watch?v=nG7RiygTwR4")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-youtube-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lapeyre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-08 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita