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 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.1'
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('yajl-ruby', '~> 0.7.8')
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
@@ -2,5 +2,5 @@
2
2
  require 'flickvimeo/video'
3
3
 
4
4
  module FlickVimeo
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  end
@@ -1,17 +1,19 @@
1
1
  require "net/http"
2
2
  require "uri"
3
- require 'yajl'
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
- @id = id
9
- @url = vimeo_url(id)
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=#{best_quality}&codecs=#{@codec}&clip_id=#{clip_id}&time=#{timestamp}&sig=#{signature}&type=html5_desktop_local"
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['config']['request']['timestamp']
27
+ config.search('timestamp').text
26
28
  end
27
29
 
28
30
  def signature
29
- config['config']['request']['signature']
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 best_quality
37
- config['config']['video']['files'][@codec].first
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 convert_javascript_to_valid_json(input)
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
- "http://player.vimeo.com/video/#{$1}"
48
+ $1
60
49
  when /^\d+$/
61
- "http://player.vimeo.com/video/#{id}"
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
@@ -7,7 +7,7 @@ class TestBasic < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  def test_format
10
- assert_equal 'hd', @video.best_quality
10
+ assert_equal 'hd', @video.quality
11
11
  end
12
12
 
13
13
  def test_clip_id
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
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: yajl-ruby
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: 19
29
+ hash: 1
30
30
  segments:
31
- - 0
32
- - 7
33
- - 8
34
- version: 0.7.8
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