hosted_video 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +31 -0
- data/hosted_video.gemspec +1 -0
- data/lib/hosted_video/providers/rutube_by_iframe.rb +1 -9
- data/lib/hosted_video/providers/vimeo_by_iframe.rb +1 -9
- data/lib/hosted_video/providers/youtube_by_iframe.rb +1 -9
- data/lib/hosted_video/version.rb +1 -1
- data/spec/spec_helper.rb +0 -4
- 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: bef8edd4d844122f99a4cc256e84471dc4a83f1c
|
4
|
+
data.tar.gz: e5013dd01daa32477e6375d82481675cf8f17787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b3c2b28397ce608bdb3cf3881e2ef28dd1e0d098a8ef24e2fd6894ee97225e900f34214bb546b132e24e137b6152816e540b684739f042abeed7c2502214329
|
7
|
+
data.tar.gz: 5e8e85f1fb3dcbe4ab67cf9151d75d563365f7af585f2f6252b0e15e30485b54ecef5e19896adeee8222fff98a05a510904d68b2517827e47d53131ee40548f9
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -28,6 +28,37 @@ video.preview # => "http://img.youtube.com/vi/TBKN7_vx2xo/hqdefault.jpg"
|
|
28
28
|
video.iframe_code # => "<iframe width='420' height='315' frameborder='0' src='http://www.youtube.com/embed/TBKN7_vx2xo?wmode=transparent'></iframe>"
|
29
29
|
```
|
30
30
|
|
31
|
+
You can create your own video service providers by inheriting from HostedVideo::Providers::Base and implementing parsing functions:
|
32
|
+
```ruby
|
33
|
+
class MyProvider < HostedVideo::Providers::Base
|
34
|
+
# logic to determine your service
|
35
|
+
def self.can_parse?(url)
|
36
|
+
url =~ /myprovider\.com\/\d{3}.*/
|
37
|
+
end
|
38
|
+
|
39
|
+
# how to get preview image
|
40
|
+
def preview
|
41
|
+
"http://myprovider.ru/api/video/#{vid}/?preview=true")
|
42
|
+
end
|
43
|
+
|
44
|
+
def url_for_iframe
|
45
|
+
"http://rutube.ru/video/embed/#{vid}"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
# regular expression for getting video id from link
|
50
|
+
def vid_regex
|
51
|
+
/(https?:\/\/)?(www\.)?rutube\.ru\/video\/(?<id>\w{32}|\w{7}).*/
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
HostedVideo.configure do |c|
|
56
|
+
c.additional_providers += [MyProvider]
|
57
|
+
end
|
58
|
+
```
|
59
|
+
Please send me pull-requests with your providers or write an issue with pasted code.
|
60
|
+
|
61
|
+
|
31
62
|
## Contributing
|
32
63
|
|
33
64
|
1. Fork it
|
data/hosted_video.gemspec
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
module HostedVideo
|
2
2
|
module Providers
|
3
|
-
class RutubeByIframe <
|
3
|
+
class RutubeByIframe < Rutube
|
4
4
|
def self.can_parse?(url)
|
5
5
|
url =~ /rutube\.ru\/video\/embed\/(\w{32}|\w{7}).*/
|
6
6
|
end
|
7
7
|
|
8
|
-
def preview
|
9
|
-
JSON.load(open("http://rutube.ru/api/video/#{vid}/?format=json"))['thumbnail_url']
|
10
|
-
end
|
11
|
-
|
12
|
-
def url_for_iframe
|
13
|
-
"http://rutube.ru/video/embed/#{vid}"
|
14
|
-
end
|
15
|
-
|
16
8
|
private
|
17
9
|
|
18
10
|
def vid_regex
|
@@ -1,18 +1,10 @@
|
|
1
1
|
module HostedVideo
|
2
2
|
module Providers
|
3
|
-
class VimeoByIframe <
|
3
|
+
class VimeoByIframe < Vimeo
|
4
4
|
def self.can_parse?(url)
|
5
5
|
url =~ /player\.vimeo\.com\/video\/\d{7,8}.*/
|
6
6
|
end
|
7
7
|
|
8
|
-
def preview
|
9
|
-
JSON.load(open("http://vimeo.com/api/v2/video/#{vid}.json")).first['thumbnail_large']
|
10
|
-
end
|
11
|
-
|
12
|
-
def url_for_iframe
|
13
|
-
"http://player.vimeo.com/video/#{vid}?api=0"
|
14
|
-
end
|
15
|
-
|
16
8
|
private
|
17
9
|
|
18
10
|
def vid_regex
|
@@ -1,19 +1,11 @@
|
|
1
1
|
module HostedVideo
|
2
2
|
module Providers
|
3
|
-
class YoutubeByIframe <
|
3
|
+
class YoutubeByIframe < Youtube
|
4
4
|
|
5
5
|
def self.can_parse?(url)
|
6
6
|
url =~ /youtube\.com\/embed\/[\w,-]{11}(\?.*)?/
|
7
7
|
end
|
8
8
|
|
9
|
-
def preview
|
10
|
-
"http://img.youtube.com/vi/#{vid}/hqdefault.jpg"
|
11
|
-
end
|
12
|
-
|
13
|
-
def url_for_iframe
|
14
|
-
"http://www.youtube.com/embed/#{vid}?wmode=transparent"
|
15
|
-
end
|
16
|
-
|
17
9
|
private
|
18
10
|
|
19
11
|
def vid_regex
|
data/lib/hosted_video/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hosted_video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Alekseev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|