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.
- data/CHANGELOG.rdoc +2 -0
- data/Rakefile +1 -1
- data/fb_video_url_converter.gemspec +14 -14
- data/lib/facebook_bot.rb +23 -25
- data/spec/facebook_bot_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -2
- metadata +9 -9
data/CHANGELOG.rdoc
CHANGED
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.
|
|
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 =
|
|
5
|
-
s.version = "0.2.
|
|
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 = [
|
|
9
|
-
s.date =
|
|
10
|
-
s.description =
|
|
11
|
-
s.email =
|
|
12
|
-
s.extra_rdoc_files = [
|
|
13
|
-
s.files = [
|
|
14
|
-
s.homepage =
|
|
15
|
-
s.rdoc_options = [
|
|
16
|
-
s.require_paths = [
|
|
17
|
-
s.rubyforge_project =
|
|
18
|
-
s.rubygems_version =
|
|
19
|
-
s.summary =
|
|
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
|
data/lib/facebook_bot.rb
CHANGED
|
@@ -54,35 +54,32 @@ class FacebookBot
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def login
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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(
|
|
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', '?')
|
data/spec/facebook_bot_spec.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
data/spec/spec_helper.rb
CHANGED
|
@@ -23,8 +23,8 @@ require 'fb_video_url_converter'
|
|
|
23
23
|
require 'active_record'
|
|
24
24
|
require 'fileutils'
|
|
25
25
|
|
|
26
|
-
FacebookBot.email = '
|
|
27
|
-
FacebookBot.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.
|
|
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-
|
|
12
|
+
date: 2012-02-25 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|
|
16
|
-
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: *
|
|
24
|
+
version_requirements: *17362140
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: mechanize
|
|
27
|
-
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: *
|
|
35
|
+
version_requirements: *17361480
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: rspec
|
|
38
|
-
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: *
|
|
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.
|
|
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
|