lita-youtube-me 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/lib/lita/handlers/youtube_me.rb +11 -3
- data/lita-youtube-me.gemspec +1 -1
- data/spec/lita/handlers/youtube_me_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57dd7c41c391ea30dc027af62f5842eb24a78e8
|
4
|
+
data.tar.gz: e410dbb8d7e0029891fb66ab494506079b2102fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(/\
|
19
|
-
route(/\
|
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
|
data/lita-youtube-me.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-youtube-me"
|
3
|
-
spec.version = "0.0.
|
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.
|
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-
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|