fb_video_url_converter 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +2 -0
- data/Rakefile +1 -1
- data/fb_video_url_converter.gemspec +2 -2
- data/lib/facebook_bot.rb +12 -5
- data.tar.gz.sig +1 -2
- metadata +2 -2
- metadata.gz.sig +1 -1
data/CHANGELOG.rdoc
CHANGED
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
|
+
Echoe.new('fb_video_url_converter', '0.2.2') 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,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{fb_video_url_converter}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.2"
|
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"]
|
9
9
|
s.cert_chain = ["/home/mencio/.cert_keys/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2011-06-
|
10
|
+
s.date = %q{2011-06-11}
|
11
11
|
s.description = %q{Facebook Video URL Converter is intended as an easy alternative to changing video hosting from Facebook to a different one.}
|
12
12
|
s.email = %q{maciej@mensfeld.pl}
|
13
13
|
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"]
|
data/lib/facebook_bot.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
require 'mechanize'
|
3
5
|
include WWW
|
@@ -24,9 +26,9 @@ class FacebookBot
|
|
24
26
|
attr_accessor :cookie_path
|
25
27
|
end
|
26
28
|
|
27
|
-
FB_URL
|
28
|
-
USER_AGENT
|
29
|
-
VIDEO_ERROR
|
29
|
+
FB_URL = "http://www.facebook.com/"
|
30
|
+
USER_AGENT = 'Windows IE 7'
|
31
|
+
VIDEO_ERROR = 'video_id_error'
|
30
32
|
|
31
33
|
|
32
34
|
def initialize
|
@@ -41,12 +43,13 @@ class FacebookBot
|
|
41
43
|
# @@root = File.expand_path(File.dirname(__FILE__))
|
42
44
|
@@root = self.class.cookie_path
|
43
45
|
end
|
44
|
-
|
46
|
+
|
45
47
|
@cookies = File.join(@@root, "cookie_#{self.class.email}.yml")
|
46
48
|
|
47
49
|
begin
|
48
50
|
@agent.cookie_jar.load(@cookies)
|
49
51
|
rescue
|
52
|
+
@agent.cookie_jar.clear!
|
50
53
|
end if (File.file?(@cookies) && File.size(@cookies) > 10)
|
51
54
|
|
52
55
|
self.login
|
@@ -58,6 +61,9 @@ class FacebookBot
|
|
58
61
|
if (loginf = page.form_id("login_form"))
|
59
62
|
loginf.set_fields(:email => self.class.email, :pass => self.class.password)
|
60
63
|
page = @agent.submit(loginf, loginf.buttons.first)
|
64
|
+
# When we login (successfully) we will be redirected in a not so "gracefull"
|
65
|
+
# way - so we need to "skip" redirecting page
|
66
|
+
page = @agent.get(FB_URL) if page.root.to_html.include?('<title>Redirecting')
|
61
67
|
end
|
62
68
|
|
63
69
|
@agent.cookie_jar.save_as(@cookies)
|
@@ -65,10 +71,11 @@ class FacebookBot
|
|
65
71
|
|
66
72
|
begin
|
67
73
|
# This is a UID given to each Facebook user.
|
68
|
-
@uid = %r{\\"user\\":(\d+),\\"hide\\"}.match(body)[1]
|
74
|
+
@uid = %r{\\"user\\":(\d+),\\"hide\\"}.match(body)[1]
|
69
75
|
rescue
|
70
76
|
@uid = nil
|
71
77
|
end
|
78
|
+
|
72
79
|
# This is a token we need to submit forms.
|
73
80
|
begin
|
74
81
|
@post_form_id = %r{<input type="hidden" .* name="post_form_id" value="([^"]+)}.match(body)[1]
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�\
|
1
|
+
z�[�*L0��H��k���c��*3��I�&�����ȮX�aܤ��m�bbN�Y�H�,�ͱy�����9�z����?n-]�qH~(\z�`�j��b��UM7 ~�,���|�]}Ȕ]��kK"���d�{�ޒd��t������[���mʤ4]��I�(C��ԣQ /���_U����{Чep�$/ˉ0^�O������u��#GV\q�$��T�<}�9k ��)���:�%�X���n�h��
|
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
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Maciej Mensfeld
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
BH3YFsdk
|
32
32
|
-----END CERTIFICATE-----
|
33
33
|
|
34
|
-
date: 2011-06-
|
34
|
+
date: 2011-06-11 00:00:00 +02:00
|
35
35
|
default_executable:
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
�KlQ����nԴ�$r6� �J�1�������y�,3��2�0gw�*�����!ȋ�|�k~G���s_v;Ϭ�g�m��+?�QCkw��z�.vI3��<g�����#�V���v@a}!�B�����S�` }�η�~L��,h��B�C�����,��d|��[�7|�W���iRܧ�g#wELf�~��ߎU�̍����U���١&�����W�&�#��b� p���|�oo�@gY�[jf�I& p#�
|