fb_video_url_converter 0.2.8 → 0.2.9

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.
@@ -1,3 +1,5 @@
1
+ = Version 0.2.9
2
+ * Adjustment for new FB video url embedding (in js)
1
3
  = Version 0.2.8
2
4
  * Fixed totaly invalid URL respond status
3
5
  * Fixed responding to short urls
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('fb_video_url_converter', '0.2.8') do |p|
6
+ Echoe.new('fb_video_url_converter', '0.2.9') do |p|
7
7
  p.description = "Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one."
8
8
  p.url = "https://github.com/mensfeld/FB-Video-URL-Converter"
9
9
  p.author = "Maciej Mensfeld"
@@ -1,22 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{fb_video_url_converter}
5
- s.version = "0.2.8"
4
+ s.name = "fb_video_url_converter"
5
+ s.version = "0.2.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = [%q{Maciej Mensfeld}]
9
- s.date = %q{2012-01-15}
10
- s.description = %q{Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one.}
11
- s.email = %q{maciej@mensfeld.pl}
12
- s.extra_rdoc_files = [%q{CHANGELOG.rdoc}, %q{README.md}, %q{lib/facebook_bot.rb}, %q{lib/facebook_video.rb}, %q{lib/fb_video_url_converter.rb}, %q{lib/generators/fb_video_url_converter/install_generator.rb}, %q{lib/generators/fb_video_url_converter/templates/create_facebook_videos_migration.rb}, %q{lib/generators/fb_video_url_converter/templates/facebook_video_converter_init.rb}]
13
- s.files = [%q{CHANGELOG.rdoc}, %q{Gemfile}, %q{MIT-LICENSE}, %q{README.md}, %q{Rakefile}, %q{fb_video_url_converter.gemspec}, %q{init.rb}, %q{lib/facebook_bot.rb}, %q{lib/facebook_video.rb}, %q{lib/fb_video_url_converter.rb}, %q{lib/generators/fb_video_url_converter/install_generator.rb}, %q{lib/generators/fb_video_url_converter/templates/create_facebook_videos_migration.rb}, %q{lib/generators/fb_video_url_converter/templates/facebook_video_converter_init.rb}, %q{spec/facebook_bot_spec.rb}, %q{spec/facebook_video_spec.rb}, %q{spec/spec_helper.rb}, %q{Manifest}]
14
- s.homepage = %q{https://github.com/mensfeld/FB-Video-URL-Converter}
15
- s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Fb_video_url_converter}, %q{--main}, %q{README.md}]
16
- s.require_paths = [%q{lib}]
17
- s.rubyforge_project = %q{fb_video_url_converter}
18
- s.rubygems_version = %q{1.8.5}
19
- s.summary = %q{Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one.}
8
+ s.authors = ["Maciej Mensfeld"]
9
+ s.date = "2012-02-25"
10
+ s.description = "Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one."
11
+ s.email = "maciej@mensfeld.pl"
12
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md", "lib/facebook_bot.rb", "lib/facebook_video.rb", "lib/fb_video_url_converter.rb", "lib/generators/fb_video_url_converter/install_generator.rb", "lib/generators/fb_video_url_converter/templates/create_facebook_videos_migration.rb", "lib/generators/fb_video_url_converter/templates/facebook_video_converter_init.rb"]
13
+ s.files = ["CHANGELOG.rdoc", "Gemfile", "MIT-LICENSE", "README.md", "Rakefile", "fb_video_url_converter.gemspec", "init.rb", "lib/facebook_bot.rb", "lib/facebook_video.rb", "lib/fb_video_url_converter.rb", "lib/generators/fb_video_url_converter/install_generator.rb", "lib/generators/fb_video_url_converter/templates/create_facebook_videos_migration.rb", "lib/generators/fb_video_url_converter/templates/facebook_video_converter_init.rb", "spec/facebook_bot_spec.rb", "spec/facebook_video_spec.rb", "spec/spec_helper.rb", "Manifest"]
14
+ s.homepage = "https://github.com/mensfeld/FB-Video-URL-Converter"
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fb_video_url_converter", "--main", "README.md"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = "fb_video_url_converter"
18
+ s.rubygems_version = "1.8.15"
19
+ s.summary = "Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one."
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  s.specification_version = 3
@@ -54,35 +54,32 @@ class FacebookBot
54
54
  end
55
55
 
56
56
  def login
57
- begin
58
- page = @agent.get(FB_URL)
59
-
60
- if (loginf = page.form_id("login_form"))
61
- loginf.set_fields(:email => self.class.email, :pass => self.class.password)
62
- page = @agent.submit(loginf, loginf.buttons.first)
63
- # When we login (successfully) we will be redirected in a not so "gracefull"
64
- # way - so we need to "skip" redirecting page
65
- page = @agent.get(FB_URL) if page.root.to_html.include?('<title>Redirecting')
66
- end
67
-
68
- @agent.cookie_jar.save_as(@cookies)
69
-
70
- body = page.root.to_html
71
- @post_form_id = %r{<input type="hidden" .* name="post_form_id" value="([^"]+)}.match(body)[1]
72
- rescue
73
- @agent.cookie_jar.clear!
74
- @agent.cookie_jar.save_as(@cookies)
57
+ page = @agent.get(FB_URL)
58
+
59
+ if (loginf = page.form_with(:id => "login_form"))
60
+ loginf.set_fields(:email => self.class.email, :pass => self.class.password)
61
+
62
+ page = @agent.submit(loginf, loginf.buttons.first)
63
+ end
64
+
65
+ @agent.cookie_jar.save_as(@cookies)
66
+
67
+ body = page.root.to_html
68
+ @post_form_id = %r{<input type="hidden" .* name="post_form_id" value="([^"]+)}.match(body)[1]
69
+ if body.include?('Incorrect Email')
75
70
  raise self.class::LoginFailed, 'Incorrect login/password or cookie corrupted'
76
71
  end
72
+ rescue
73
+ @agent.cookie_jar.clear!
74
+ @agent.cookie_jar.save_as(@cookies)
75
+ raise self.class::LoginFailed, 'Incorrect login/password or cookie corrupted'
77
76
  end
78
77
 
79
78
  def video_url(id)
80
- begin
81
- load_video_page(id)
82
- get_url(@video_page)
83
- rescue
84
- VIDEO_ERROR
85
- end
79
+ load_video_page(id)
80
+ get_url(@video_page)
81
+ rescue
82
+ VIDEO_ERROR
86
83
  end
87
84
 
88
85
  def video_name(id)
@@ -100,7 +97,8 @@ class FacebookBot
100
97
  end
101
98
 
102
99
  def get_url(url)
103
- url = url.scan(/addVariable\(\"highqual_src\",\s\"http.+\"\)/ix).first
100
+ url = url.scan(/\[\"highqual_src\",\"(.+)\"\]/ix).first
101
+ url = url.first
104
102
  url = url.split(')').first.gsub('\u00253A', ':')
105
103
  url = url.gsub('\u00252F', '/')
106
104
  url = url.gsub('\u00253F', '?')
@@ -5,7 +5,7 @@ ROOT = File.expand_path(File.dirname(__FILE__))
5
5
 
6
6
  def remove_cookie
7
7
  c_p = File.join(ROOT, '..', 'lib', "cookie_#{FacebookBot.email}.yml")
8
- #FileUtils.rm( c_p ) if File.file?( c_p )
8
+ FileUtils.rm( c_p ) if File.file?( c_p )
9
9
  end
10
10
 
11
11
  describe FacebookBot do
@@ -22,7 +22,7 @@ describe FacebookBot do
22
22
 
23
23
  context "and login or password is incorrect" do
24
24
  it "should throw failed exception" do
25
- l = subject.email
25
+ l = subject.email.clone
26
26
  subject.email = 'incorrect@incorrect.pl'
27
27
  lambda { subject.new }.should raise_error(subject::LoginFailed, 'Incorrect login/password or cookie corrupted')
28
28
  remove_cookie
@@ -49,7 +49,7 @@ describe FacebookBot do
49
49
 
50
50
  it "should obtain valid name of a valid movie" do
51
51
  fb = subject.new
52
- fb.video_name('111449252268656').should eql 'Naruto Shippuuden #203 Part2'
52
+ fb.video_name('111449252268656').should eql 'Naruto Shippuuden #203 Part2 | Facebook'
53
53
  end
54
54
 
55
55
  it "should obtain valid error msg of a invalid movie" do
@@ -23,8 +23,8 @@ require 'fb_video_url_converter'
23
23
  require 'active_record'
24
24
  require 'fileutils'
25
25
 
26
- FacebookBot.email = 'email'
27
- FacebookBot.password = 'password'
26
+ FacebookBot.email = 'maciej@mensfeld.pl'
27
+ FacebookBot.password = 'bpp_B7QksC79-c7_JBTRBV'
28
28
  FacebookBot.cookie_path = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
29
29
  FacebookVideo.cache = 60*10
30
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_video_url_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-15 00:00:00.000000000Z
12
+ date: 2012-02-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &26614420 !ruby/object:Gem::Requirement
16
+ requirement: &17362140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *26614420
24
+ version_requirements: *17362140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mechanize
27
- requirement: &26613960 !ruby/object:Gem::Requirement
27
+ requirement: &17361480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *26613960
35
+ version_requirements: *17361480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &26613420 !ruby/object:Gem::Requirement
38
+ requirement: &17360780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *26613420
46
+ version_requirements: *17360780
47
47
  description: Facebook Video URL Converter is intended as an easy alternative to changing
48
48
  video hosting from Facebook to a different one.
49
49
  email: maciej@mensfeld.pl
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '1.2'
103
103
  requirements: []
104
104
  rubyforge_project: fb_video_url_converter
105
- rubygems_version: 1.8.5
105
+ rubygems_version: 1.8.15
106
106
  signing_key:
107
107
  specification_version: 3
108
108
  summary: Facebook Video URL Converter is intended as an easy alternative to changing