video-torrent-info 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 541f01c01e21b8e0b2cce6be15ba92c1c94691a9
4
+ data.tar.gz: d4f2da1c6d381d96c0214bec24e35dc075445fc0
5
+ SHA512:
6
+ metadata.gz: 22f8d18e4f1969c9d6898ae3827ca2c0c29fc4a72ef2dc30649b5e4187631b3d9ae2e2a50feb5a0d7909e3b3d7fbf374b4b4507bc7480d8435be7897e631468b
7
+ data.tar.gz: 72eceda2b365da48e41e2b8d5c28b6ec59b1d33224654c8f9d53b088847316eb21bbcc3b041ae4c6928c61043c683733eab76950feccee20680e368cf353f205
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rdoc", "~> 3.12"
10
+ gem "bundler", "~> 1.0"
11
+ gem "jeweler", "~> 1.8.7"
12
+ gem "rspec"
13
+ gem "rake-compiler"
14
+ gem "rice"
15
+ gem "ffmpeg-video-info"
16
+ gem 'bencode', :git => 'git://github.com/vintikzzz/ruby-bencode.git'
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ GIT
2
+ remote: git://github.com/vintikzzz/ruby-bencode.git
3
+ revision: 5288af4fc188181ccdce9f611c29e93018fdc47f
4
+ specs:
5
+ bencode (0.6.1)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ addressable (2.3.5)
11
+ builder (3.2.2)
12
+ diff-lcs (1.2.5)
13
+ faraday (0.8.8)
14
+ multipart-post (~> 1.2.0)
15
+ ffmpeg-video-info (0.1.1)
16
+ git (1.2.6)
17
+ github_api (0.10.1)
18
+ addressable
19
+ faraday (~> 0.8.1)
20
+ hashie (>= 1.2)
21
+ multi_json (~> 1.4)
22
+ nokogiri (~> 1.5.2)
23
+ oauth2
24
+ hashie (2.0.5)
25
+ highline (1.6.20)
26
+ httpauth (0.2.0)
27
+ jeweler (1.8.8)
28
+ builder
29
+ bundler (~> 1.0)
30
+ git (>= 1.2.5)
31
+ github_api (= 0.10.1)
32
+ highline (>= 1.6.15)
33
+ nokogiri (= 1.5.10)
34
+ rake
35
+ rdoc
36
+ json (1.8.1)
37
+ jwt (0.1.8)
38
+ multi_json (>= 1.5)
39
+ multi_json (1.8.2)
40
+ multi_xml (0.5.5)
41
+ multipart-post (1.2.0)
42
+ nokogiri (1.5.10)
43
+ oauth2 (0.9.2)
44
+ faraday (~> 0.8)
45
+ httpauth (~> 0.2)
46
+ jwt (~> 0.1.4)
47
+ multi_json (~> 1.0)
48
+ multi_xml (~> 0.5)
49
+ rack (~> 1.2)
50
+ rack (1.5.2)
51
+ rake (10.1.0)
52
+ rake-compiler (0.9.2)
53
+ rake
54
+ rdoc (3.12.2)
55
+ json (~> 1.4)
56
+ rice (1.5.3)
57
+ rspec (2.14.1)
58
+ rspec-core (~> 2.14.0)
59
+ rspec-expectations (~> 2.14.0)
60
+ rspec-mocks (~> 2.14.0)
61
+ rspec-core (2.14.7)
62
+ rspec-expectations (2.14.4)
63
+ diff-lcs (>= 1.1.3, < 2.0)
64
+ rspec-mocks (2.14.4)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ bencode!
71
+ bundler (~> 1.0)
72
+ ffmpeg-video-info
73
+ jeweler (~> 1.8.7)
74
+ rake-compiler
75
+ rdoc (~> 3.12)
76
+ rice
77
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Pavel Tatarsky
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = video-torrent-info
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to video-torrent-info
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Pavel Tatarsky. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "video-torrent-info"
16
+ gem.homepage = "http://github.com/vintikzzz/video-torrent-info"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Gets video info for the torrent file}
19
+ gem.description = %Q{It simply loads small part of torrent that contains metadata and processes it with ffmpeg}
20
+ gem.email = "fazzzenda@mail.ru"
21
+ gem.authors = ["Pavel Tatarsky"]
22
+ gem.extensions = %w[ext/torrent_client/extconf.rb]
23
+ # dependencies defined in Gemfile
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ require 'rdoc/task'
28
+ Rake::RDocTask.new do |rdoc|
29
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
+
31
+ rdoc.rdoc_dir = 'rdoc'
32
+ rdoc.title = "video-torrent-info #{version}"
33
+ rdoc.rdoc_files.include('README*')
34
+ rdoc.rdoc_files.include('lib/**/*.rb')
35
+ end
36
+
37
+ require 'rake/extensiontask'
38
+ Rake::ExtensionTask.new('torrent_client')
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ require "mkmf-rice"
2
+
3
+ $LDFLAGS << " -ltorrent-rasterbar -lboost_system -lboost_system-mt -lssl -lcrypto -lz"
4
+ $CPPFLAGS << " -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_PTHREAD=1 -DHAVE_BOOST=1 -DHAVE_BOOST_SYSTEM=1 -DHAVE_GETHOSTBYNAME=1 -DTORRENT_DEBUG=1 -DTORRENT_USE_OPENSSL=1 -DWITH_SHIPPED_GEOIP_H=1 -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE=1 -DBOOST_ASIO_ENABLE_CANCELIO=1 -DBOOST_ASIO_DYN_LINK=1 -DTORRENT_BUILDING_SHARED=1 -I. -ftemplate-depth-50"
5
+ create_makefile('torrent_client')
Binary file
@@ -0,0 +1,42 @@
1
+ require 'bencode'
2
+ class VideoTorrentInfo
3
+ autoload :TorrentClient, 'torrent_client'
4
+ autoload :FFmpegVideoInfo, 'ffmpeg_video_info'
5
+ DEFAULTS = {
6
+ port1: 8661,
7
+ port2: 8662,
8
+ temp_path: '/tmp',
9
+ supported_extensions: %w{ .avi .mkv .mpg .mpeg .3gp .wmv .mov .flv .mts },
10
+ download_limit: 1000000
11
+ }
12
+ def initialize(params = {})
13
+ @params = DEFAULTS.merge(params)
14
+ @torrent_client = VideoTorrentInfo::TorrentClient.new
15
+ end
16
+ def load(torrent_path)
17
+ string = File.open(torrent_path){ |file| file.read }
18
+ torrent = string.bdecode
19
+ files = get_video_files(torrent)
20
+ @torrent_client.load(torrent_path, files.keys.first, @params[:download_limit], @params[:temp_path], @params[:port1], @params[:port2])
21
+ dest = @params[:temp_path] + '/' + files.values.first
22
+ res = FFmpegVideoInfo.get(dest)
23
+ File.unlink(dest)
24
+ res
25
+ end
26
+ def get_video_files(torrent)
27
+ info = torrent['info']
28
+ res = {}
29
+ files = []
30
+ if info['files'].nil?
31
+ files = [info['name']]
32
+ else
33
+ files = info['files'].map { |e| (info['name'] + path).join('/') }
34
+ end
35
+ files.each do |f|
36
+ if @params[:supported_extensions].include?(File.extname(f))
37
+ res[files.index(f)] = f
38
+ end
39
+ end
40
+ res
41
+ end
42
+ end
Binary file
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'torrent_client'
3
+ describe VideoTorrentInfo::TorrentClient do
4
+ let(:target) { 'RIPD.3D.2013.BDRip1080p.halfOU(Killbrain)_[scarabey.org].mkv' }
5
+ subject { VideoTorrentInfo::TorrentClient.new }
6
+ context 'when #load' do
7
+ context 'with wrong file' do
8
+ specify do
9
+ expect { subject.load('abra', 0, 1000000, 'cadabra', 8661, 8662) }.to raise_error('failed to load torrent info: No such file or directory')
10
+ end
11
+ end
12
+ context 'with good file' do
13
+ before do
14
+ File.unlink(target)
15
+ subject.load('spec/fixtures/test.torrent', 0, 1000000, './', 8661, 8662)
16
+ end
17
+ specify do
18
+ expect(File.exist?(target)).to be_true
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'video_torrent_info'
3
+ describe VideoTorrentInfo do
4
+ subject { VideoTorrentInfo.new }
5
+ context 'when #load' do
6
+ context 'with good file' do
7
+ specify do
8
+ p subject.load('spec/fixtures/test.torrent')
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ Dir.chdir File.dirname(File.dirname(__FILE__))
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "video-torrent-info"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Pavel Tatarsky"]
12
+ s.date = "2013-12-02"
13
+ s.description = "It simply loads small part of torrent that contains metadata and processes it with ffmpeg"
14
+ s.email = "fazzzenda@mail.ru"
15
+ s.extensions = ["ext/torrent_client/extconf.rb"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/torrent_client.bundle",
29
+ "lib/video_torrent_info.rb",
30
+ "spec/fixtures/test.torrent",
31
+ "spec/lib/torrent_client_spec.rb",
32
+ "spec/lib/video_torrent_info_spec.rb",
33
+ "spec/spec_helper.rb",
34
+ "video-torrent-info.gemspec"
35
+ ]
36
+ s.homepage = "http://github.com/vintikzzz/video-torrent-info"
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = "2.0.5"
40
+ s.summary = "Gets video info for the torrent file"
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 4
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
49
+ s.add_development_dependency(%q<rspec>, [">= 0"])
50
+ s.add_development_dependency(%q<rake-compiler>, [">= 0"])
51
+ s.add_development_dependency(%q<rice>, [">= 0"])
52
+ s.add_development_dependency(%q<ffmpeg-video-info>, [">= 0"])
53
+ s.add_development_dependency(%q<bencode>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
58
+ s.add_dependency(%q<rspec>, [">= 0"])
59
+ s.add_dependency(%q<rake-compiler>, [">= 0"])
60
+ s.add_dependency(%q<rice>, [">= 0"])
61
+ s.add_dependency(%q<ffmpeg-video-info>, [">= 0"])
62
+ s.add_dependency(%q<bencode>, [">= 0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
68
+ s.add_dependency(%q<rspec>, [">= 0"])
69
+ s.add_dependency(%q<rake-compiler>, [">= 0"])
70
+ s.add_dependency(%q<rice>, [">= 0"])
71
+ s.add_dependency(%q<ffmpeg-video-info>, [">= 0"])
72
+ s.add_dependency(%q<bencode>, [">= 0"])
73
+ end
74
+ end
75
+
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: video-torrent-info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Tatarsky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rdoc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jeweler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake-compiler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rice
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ffmpeg-video-info
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: bencode
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: It simply loads small part of torrent that contains metadata and processes
126
+ it with ffmpeg
127
+ email: fazzzenda@mail.ru
128
+ executables: []
129
+ extensions:
130
+ - ext/torrent_client/extconf.rb
131
+ extra_rdoc_files:
132
+ - LICENSE.txt
133
+ - README.rdoc
134
+ files:
135
+ - .document
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - LICENSE.txt
139
+ - README.rdoc
140
+ - Rakefile
141
+ - VERSION
142
+ - lib/torrent_client.bundle
143
+ - lib/video_torrent_info.rb
144
+ - spec/fixtures/test.torrent
145
+ - spec/lib/torrent_client_spec.rb
146
+ - spec/lib/video_torrent_info_spec.rb
147
+ - spec/spec_helper.rb
148
+ - video-torrent-info.gemspec
149
+ - ext/torrent_client/extconf.rb
150
+ homepage: http://github.com/vintikzzz/video-torrent-info
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.0.5
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Gets video info for the torrent file
174
+ test_files: []