flickvimeo 1.0.1 → 1.0.2
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.
- data/flickvimeo.gemspec +2 -2
- data/lib/flickvimeo.rb +1 -1
- data/lib/flickvimeo/video.rb +15 -26
- data/test/test_video.rb +1 -1
- metadata +9 -9
data/flickvimeo.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'flickvimeo'
|
16
|
-
s.version = '1.0.
|
16
|
+
s.version = '1.0.2'
|
17
17
|
s.date = '2011-01-02'
|
18
18
|
# s.rubyforge_project = 'flickvimeo'
|
19
19
|
|
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
|
45
45
|
## List your runtime dependencies here. Runtime dependencies are those
|
46
46
|
## that are needed for an end user to actually USE your code.
|
47
|
-
s.add_dependency('
|
47
|
+
s.add_dependency('nokogiri', '~> 1.4.3')
|
48
48
|
|
49
49
|
## List your development dependencies here. Development dependencies are
|
50
50
|
## those that are only needed during development
|
data/lib/flickvimeo.rb
CHANGED
data/lib/flickvimeo/video.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
require "net/http"
|
2
2
|
require "uri"
|
3
|
-
require '
|
3
|
+
require 'nokogiri'
|
4
4
|
|
5
5
|
module FlickVimeo
|
6
6
|
class Video
|
7
|
+
attr_accessor :clip_id, :url
|
8
|
+
|
7
9
|
def initialize(id)
|
8
|
-
@
|
9
|
-
@url
|
10
|
+
@clip_id = vimeo_id(id)
|
11
|
+
@url = "http://vimeo.com/moogaloop/load/clip:#{@clip_id}/local/"
|
10
12
|
@codec = 'h264'
|
11
13
|
end
|
12
14
|
|
13
15
|
def video_redirect_url
|
14
|
-
"http://player.vimeo.com/play_redirect?quality=#{
|
16
|
+
"http://player.vimeo.com/play_redirect?quality=#{quality}&codecs=#{@codec}&clip_id=#{clip_id}&time=#{timestamp}&sig=#{signature}&type=html5_desktop_local"
|
15
17
|
end
|
16
18
|
|
17
19
|
def video_file_url
|
@@ -22,48 +24,35 @@ module FlickVimeo
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def timestamp
|
25
|
-
config
|
27
|
+
config.search('timestamp').text
|
26
28
|
end
|
27
29
|
|
28
30
|
def signature
|
29
|
-
config
|
30
|
-
end
|
31
|
-
|
32
|
-
def clip_id
|
33
|
-
config['config']['video']['id']
|
31
|
+
config.search('request_signature').text
|
34
32
|
end
|
35
33
|
|
36
|
-
def
|
37
|
-
config
|
34
|
+
def quality
|
35
|
+
config.search('video isHD').text == '1' ? 'hd' : 'sd'
|
38
36
|
end
|
39
37
|
|
40
38
|
def config
|
41
39
|
@config ||= begin
|
42
40
|
response = http_request(@url)
|
43
|
-
|
44
|
-
if m = response.body.match(/clip\d+_\d+ = (.*)?;Player.checkRatio/)
|
45
|
-
Yajl::Parser.parse(convert_javascript_to_valid_json(m[1]))
|
46
|
-
end
|
41
|
+
Nokogiri::XML.parse(response.body)
|
47
42
|
end
|
48
43
|
end
|
49
44
|
|
50
|
-
def
|
51
|
-
# Cleanup javascript to be valid JSON
|
52
|
-
json = input.gsub(/([\{\[,]\s*)([a-zA-Z_]+):/) { %{#{$1}"#{$2}":} }
|
53
|
-
json = json.gsub(/(:\s*)'((?:[^'\\]|\\.)*)'/, '\1"\2"')
|
54
|
-
end
|
55
|
-
|
56
|
-
def vimeo_url(id)
|
45
|
+
def vimeo_id(id)
|
57
46
|
case id.to_s
|
58
47
|
when %r{^http://.*vimeo.com.*[#/](\d+)}
|
59
|
-
|
48
|
+
$1
|
60
49
|
when /^\d+$/
|
61
|
-
|
50
|
+
id
|
62
51
|
else
|
63
52
|
raise "Unknown id format: #{id}"
|
64
53
|
end
|
65
54
|
end
|
66
|
-
|
55
|
+
|
67
56
|
def http_request(url)
|
68
57
|
uri = URI.parse(url)
|
69
58
|
http = Net::HTTP.new(uri.host, uri.port)
|
data/test/test_video.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flickvimeo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Lindvall
|
@@ -19,19 +19,19 @@ date: 2011-01-02 00:00:00 -08:00
|
|
19
19
|
default_executable: flickvimeo
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: nokogiri
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 1
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version:
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
- 3
|
34
|
+
version: 1.4.3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
description: A simple tool to use AirFlick to send Vimeo videos to your AppleTV
|