fb_video_url_converter 0.2.5 → 0.2.6

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/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,7 @@
1
+ = Version 0.2.6
2
+ * Fix for undefined each for nil class - when cookiejar is corrupted - will clear corrupted cookiejar - so in next request - will relogin
1
3
  = Version 0.2.5
2
- * Removed errors login. Reraising different errors than FacebookBot::LoginFailed so will log automatically. Inserted all cookie_jar operations into begin-rescue blocks because it sometimes raises "undefined method expired? 4 nil class"
4
+ * Removed errors login. Reraising different errors than FacebookBot::LoginFailed so will log automatically. Inserted all cookie_jar operations into begin-rescue blocks because it sometimes raises 'undefined method expired? 4 nil class'
3
5
  = Version 0.2.4
4
6
  * Experimental Rails errors loggin
5
7
  = Version 0.2.3
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('fb_video_url_converter', '0.2.5') do |p|
5
+ Echoe.new('fb_video_url_converter', '0.2.6') do |p|
6
6
  p.description = "Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one."
7
7
  p.url = "https://github.com/mensfeld/FB-Video-URL-Converter"
8
8
  p.author = "Maciej Mensfeld"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{fb_video_url_converter}
5
- s.version = "0.2.5"
5
+ s.version = "0.2.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Maciej Mensfeld"]
data/lib/facebook_bot.rb CHANGED
@@ -54,29 +54,25 @@ class FacebookBot
54
54
  end
55
55
 
56
56
  def login
57
- page = @agent.get(FB_URL)
58
-
59
- if (loginf = page.form_id("login_form"))
60
- loginf.set_fields(:email => self.class.email, :pass => self.class.password)
61
- page = @agent.submit(loginf, loginf.buttons.first)
62
- # When we login (successfully) we will be redirected in a not so "gracefull"
63
- # way - so we need to "skip" redirecting page
64
- page = @agent.get(FB_URL) if page.root.to_html.include?('<title>Redirecting')
65
- end
66
-
67
- # Donno why but sometimes cookiejar gets crazy - so better be prepared ;)
68
57
  begin
69
- @agent.cookie_jar.save_as(@cookies)
70
- rescue
71
- end
72
-
73
- body = page.root.to_html
58
+ page = @agent.get(FB_URL)
74
59
 
75
- # This is a token we need to submit forms.
76
- begin
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
77
71
  @post_form_id = %r{<input type="hidden" .* name="post_form_id" value="([^"]+)}.match(body)[1]
78
72
  rescue
79
- raise self.class::LoginFailed, 'Incorrect login or password'
73
+ @agent.cookie_jar.clear!
74
+ @agent.cookie_jar.save_as(@cookies)
75
+ raise self.class::LoginFailed, 'Incorrect login/password or cookie corrupted'
80
76
  end
81
77
  end
82
78
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: fb_video_url_converter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.5
5
+ version: 0.2.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Maciej Mensfeld
metadata.gz.sig CHANGED
Binary file