video-torrent-info 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79aa9eddaf64c89f8db33c47976c5b15bd73c41d
4
- data.tar.gz: 3e2604e5d89f28d82d39d38767f9ceca18f866ae
3
+ metadata.gz: b71e5aefa32be1fbc835ed07180bf827f76e6269
4
+ data.tar.gz: e2cc0d4ee9d5557de8760e3d2f89b80eef7ed710
5
5
  SHA512:
6
- metadata.gz: 452ecb6f7847cb7c2f06210eaf7ac0f11437da291d4fc02f42dc0e14ac8f6c5d7a29c458213d60b49fc5c7e6a461dcfd01ed2c1802a23ed948bd4c0802dc78d9
7
- data.tar.gz: 2ff3cc939419b62dff4aa4ccf0f237259ed77fe701c1c23f86191ed73e8151c080273b3da7417a59e7e99d07e5aa42aa28d0628faa535e61fab5e78b27bb7f0a
6
+ metadata.gz: 7efcf563f6f6f580f3c2df4085aaa3604e6d77c27c354d0e7c24db2ef0087d507c253b28e5139431c69d5c47e6cb7e20d1b562a8a2607749fc166d577855b624
7
+ data.tar.gz: d93bc5b62f8e8fe9d55af9f5fced1e4bc73c56b292a9a46fe3d6fe5218d49907dbf6d8cfd29f18de57941d181bb94704aeffd88993dfae0ca9566f53323c9390
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -18,7 +18,7 @@ struct MyException : public std::exception
18
18
  const char* what() const throw() { return s.c_str(); }
19
19
  };
20
20
 
21
- void load(String torrent_path, int idx, int size, String save_path, int port1, int port2)
21
+ void load(String torrent_path, int idx, int size, String save_path, int port1, int port2, int timeout)
22
22
  {
23
23
  using namespace libtorrent;
24
24
 
@@ -57,6 +57,7 @@ void load(String torrent_path, int idx, int size, String save_path, int port1, i
57
57
  }
58
58
 
59
59
  size_type temp = 0;
60
+ int t = 0;
60
61
 
61
62
  while (true)
62
63
  {
@@ -69,7 +70,12 @@ void load(String torrent_path, int idx, int size, String save_path, int port1, i
69
70
  {
70
71
  return;
71
72
  }
72
- sleep(1000);
73
+ if (t >= timeout * 1000)
74
+ {
75
+ return;
76
+ }
77
+ t++;
78
+ usleep(1000);
73
79
  }
74
80
  }
75
81
  void handle_my_exception(std::exception const & ex)
@@ -7,7 +7,8 @@ class VideoTorrentInfo
7
7
  port2: 8662,
8
8
  temp_path: '/tmp',
9
9
  supported_extensions: %w{ .avi .mkv .mpg .mpeg .3gp .wmv .mov .flv .mts },
10
- download_limit: 1000000
10
+ download_limit: 1000000,
11
+ timeout: 60
11
12
  }
12
13
  def initialize(params = {})
13
14
  @params = DEFAULTS.merge(params)
@@ -17,7 +18,7 @@ class VideoTorrentInfo
17
18
  string = File.open(torrent_path){ |file| file.read }
18
19
  torrent = string.bdecode
19
20
  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
+ @torrent_client.load(torrent_path, files.keys.first, @params[:download_limit], @params[:temp_path], @params[:port1], @params[:port2], @params[:timeout])
21
22
  dest = @params[:temp_path] + '/' + files.values.first
22
23
  res = FFmpegVideoInfo.get(dest)
23
24
  File.unlink(dest)
@@ -6,12 +6,12 @@ describe VideoTorrentInfo::TorrentClient do
6
6
  context 'when #load' do
7
7
  context 'with wrong file' do
8
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')
9
+ expect { subject.load('abra', 0, 1000000, 'cadabra', 8661, 8662, 60) }.to raise_error('failed to load torrent info: No such file or directory')
10
10
  end
11
11
  end
12
12
  context 'with good file' do
13
13
  before do
14
- subject.load('spec/fixtures/test.torrent', 0, 1000000, '/tmp', 8661, 8662)
14
+ subject.load('spec/fixtures/test.torrent', 0, 1000000, '/tmp', 8661, 8662, 60)
15
15
  end
16
16
  after do
17
17
  File.unlink(target)
@@ -2,15 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: video-torrent-info 0.1.8 ruby lib
5
+ # stub: video-torrent-info 0.1.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "video-torrent-info"
9
- s.version = "0.1.8"
9
+ s.version = "0.1.9"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Pavel Tatarsky"]
13
- s.date = "2013-12-13"
13
+ s.date = "2013-12-14"
14
14
  s.description = "It simply loads small part of torrent that contains metadata and processes it with ffmpeg"
15
15
  s.email = "fazzzenda@mail.ru"
16
16
  s.extensions = ["ext/torrent_client/extconf.rb"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: video-torrent-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Tatarsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc