VimeoFallback 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/VimeoFallback.rb +50 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c713c083e8e46e1bf622fdd1781a5a851d9b9e94
|
4
|
+
data.tar.gz: b3655274c50c0b764d40063ee6728f6090952826
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 00deb78fb3384c81fb7c16c6de2bc1ed181210fe7faf59c041c2449eed8b845fbb9a018065e9de3bad2ff0784c468b9c63b571fae10e2e044b443bee54dbaf70
|
7
|
+
data.tar.gz: 1ce1c60b50c99750ffd01d46b7e8073dc20d53224afd0f1765a856280459a58c26719eedd2453d34749a306884af4f141fbe60c17f439839c31b7f3983d86120
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class VimeoFallback
|
5
|
+
attr_accessor :response
|
6
|
+
attr_accessor :url
|
7
|
+
attr_accessor :url_status
|
8
|
+
|
9
|
+
def initialize(id)
|
10
|
+
@id = id
|
11
|
+
getVideoURL(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def getVideoURL(id)
|
15
|
+
uri = URI.parse("http://player.vimeo.com/video/#{id}/fallback?noscript")
|
16
|
+
|
17
|
+
req = Net::HTTP::Get.new(uri.path)
|
18
|
+
req.add_field("Referer","http://player.vimeo.com/video/#{id}")
|
19
|
+
req.add_field("User-Agent","Ruby-2.0.0")
|
20
|
+
|
21
|
+
@response = Net::HTTP.new(uri.hostname, uri.port).start {|http|
|
22
|
+
http.request(req)
|
23
|
+
}
|
24
|
+
|
25
|
+
if (@response.is_a?(Net::HTTPSuccess))
|
26
|
+
processResponse(@response.body)
|
27
|
+
else
|
28
|
+
@url = "connection error"
|
29
|
+
end
|
30
|
+
|
31
|
+
@url
|
32
|
+
end
|
33
|
+
|
34
|
+
def getStatus
|
35
|
+
@response.code.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def processResponse(responseBody)
|
41
|
+
match = /id=try-link href="(?<url>.*?)"/.match(responseBody)
|
42
|
+
if (match != nil)
|
43
|
+
@url = "http://player.vimeo.com"+match[:url]
|
44
|
+
@url_status = true
|
45
|
+
else
|
46
|
+
@url = "error occurred"
|
47
|
+
@url_status = false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: VimeoFallback
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bladymir Tellez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: The gem fetches the fallback video url for a vimeo video. The URL returned
|
14
|
+
will be to a raw video file.
|
15
|
+
email: btellez@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/VimeoFallback.rb
|
21
|
+
homepage: https://github.com/blad/VimeoFallback
|
22
|
+
licenses:
|
23
|
+
- Apache v2.0
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.14
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Fetch the Fallback Video URL for a Vimeo Video.
|
45
|
+
test_files: []
|