video-torrent-info 0.1.15 → 0.1.16

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: 082713f2508e9fadfad84ac92241763a06883393
4
- data.tar.gz: 9ea61a608bb666fdb011816748e8d0964174d95e
3
+ metadata.gz: 2db267eadd752409c38dc33beeb0d9903f4e5307
4
+ data.tar.gz: b3c963fb20e24dfd5261e7787f52e5e5df00260f
5
5
  SHA512:
6
- metadata.gz: b716966aca9da16c8a76a21c15642e13a5d65b03adf313cb905f788f791c56ef5bdb31f9fdf0f3d2b219cf8834c9db9e2d4f4c3d6e747deaa253221c07d6a384
7
- data.tar.gz: 1ae3f7d8c04dba00a3a89fb935e3854bd86dae83a2079e1dc1dbabb99d1043e36aea8b7c0f7eb2363c2967b915858d84b52e429955d0faeb4d6f5d35e7172100
6
+ metadata.gz: 610b7b35c335b6ca45778d215dbe6975d73a8460556c127baccf578e295b4c3e21d0135f2c13f1cc81838a7d4dc84e16043219e77fd16af042aafbbd56bd556b
7
+ data.tar.gz: a7975a11a5573afbe0621a59680583ba947ee10a1638cee9a921f1bae1b24009fa67e09b34e057b6d1f1ef8a9ea09e1730651722e3288bcf3cccadd442d4248d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.15
1
+ 0.1.16
@@ -2,6 +2,8 @@
2
2
  #include <sstream>
3
3
  #include <iostream>
4
4
  #include <exception>
5
+ #include <stdio.h>
6
+ #include <unistd.h>
5
7
  #include "libtorrent/entry.hpp"
6
8
  #include "libtorrent/bencode.hpp"
7
9
  #include "libtorrent/session.hpp"
@@ -17,14 +19,19 @@ struct MyException : public std::exception
17
19
  ~MyException() throw () {}
18
20
  const char* what() const throw() { return s.c_str(); }
19
21
  };
22
+ void term(int signum)
23
+ {
24
+ exit(1);
25
+ }
20
26
 
21
27
  void load(String torrent_path, int idx, int size, String save_path, int port1, int port2, int timeout)
22
28
  {
23
29
  using namespace libtorrent;
24
30
 
25
31
  session s;
26
- error_code ec;
27
32
  std::ostringstream err;
33
+ signal(SIGINT, term);
34
+ signal(SIGTERM, term);
28
35
  s.listen_on(std::make_pair(port1, port2), ec);
29
36
  if (ec)
30
37
  {
@@ -60,12 +67,13 @@ void load(String torrent_path, int idx, int size, String save_path, int port1, i
60
67
 
61
68
  size_type temp = 0;
62
69
  int t = 0;
70
+ bool finish = false;
63
71
 
64
72
  while (true)
65
73
  {
66
74
  torrent_status st = h.status();
67
75
  if (st.is_finished == true) {
68
- return;
76
+ finish = true;
69
77
  }
70
78
  if (st.total_done > temp)
71
79
  {
@@ -74,10 +82,14 @@ void load(String torrent_path, int idx, int size, String save_path, int port1, i
74
82
  }
75
83
  if (size > 0 && temp >= size)
76
84
  {
77
- return;
85
+ finish = true;
78
86
  }
79
87
  if (t >= timeout * 1000)
80
88
  {
89
+ finish = true;
90
+ }
91
+ if (finish) {
92
+ s.abort();
81
93
  return;
82
94
  }
83
95
  t++;
@@ -7,8 +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 .mp4 },
10
- download_limit: -1,
11
- timeout: 60
10
+ download_limit: 100000,
11
+ timeout: 30
12
12
  }
13
13
  def initialize(params = {})
14
14
  @params = DEFAULTS.merge(params)
Binary file
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
  require 'torrent_client'
3
3
  describe VideoTorrentInfo::TorrentClient do
4
- let(:torrent) { 'spec/fixtures/test.torrent' }
5
- let(:target) { '/tmp/Соседи.На тропе войны.(Logan1995).avi' }
4
+ let(:torrent) { 'spec/fixtures/test3.torrent' }
5
+ let(:target) { '/tmp/44.2015.WEB-DLRip.1.46GB.avi' }
6
6
  let(:port1) { 8661 }
7
7
  let(:port2) { port1 + 1 }
8
8
  let(:path) { '/tmp' }
9
9
  let(:size) { 100000 }
10
- let(:timeout) { 6000 }
10
+ let(:timeout) { 60 }
11
11
  subject { VideoTorrentInfo::TorrentClient.new }
12
12
  context 'when #load' do
13
13
  context 'with wrong file' do
@@ -24,20 +24,7 @@ describe VideoTorrentInfo::TorrentClient do
24
24
  File.unlink(target) rescue nil
25
25
  end
26
26
  specify do
27
- expect(File.exist?(target)).to be_true
28
- end
29
- end
30
- context 'full file' do
31
- let(:torrent) { 'spec/fixtures/test2.torrent' }
32
- let(:target) { '/tmp/Tom_&_Jerry/TOM-1/07. Мышонок-стратег.avi' }
33
- before do
34
- subject.load(torrent, 0, -1, path, port1, port2, timeout)
35
- end
36
- after do
37
- File.unlink(target)
38
- end
39
- specify do
40
- expect(File.exist?(target)).to be_true
27
+ expect(File.exist?(target)).to be_truthy
41
28
  end
42
29
  end
43
30
  end
@@ -5,7 +5,7 @@ describe VideoTorrentInfo do
5
5
  context 'when #load' do
6
6
  context 'with good file' do
7
7
  specify do
8
- expect(subject.load('spec/fixtures/test.torrent')['format_name']).to eql('avi')
8
+ expect(subject.load('spec/fixtures/test3.torrent')['format_name']).to eql('avi')
9
9
  end
10
10
  end
11
11
  end
@@ -2,17 +2,17 @@
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.15 ruby lib
5
+ # stub: video-torrent-info 0.1.16 ruby lib
6
6
  # stub: ext/torrent_client/extconf.rb
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "video-torrent-info"
10
- s.version = "0.1.15"
10
+ s.version = "0.1.16"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Pavel Tatarsky"]
15
- s.date = "2015-06-05"
15
+ s.date = "2015-07-10"
16
16
  s.description = "It simply loads small part of torrent that contains metadata and processes it with ffmpeg"
17
17
  s.email = "fazzzenda@mail.ru"
18
18
  s.extensions = ["ext/torrent_client/extconf.rb"]
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "lib/video_torrent_info.rb",
35
35
  "spec/fixtures/test.torrent",
36
36
  "spec/fixtures/test2.torrent",
37
+ "spec/fixtures/test3.torrent",
37
38
  "spec/lib/torrent_client_spec.rb",
38
39
  "spec/lib/video_torrent_info_spec.rb",
39
40
  "spec/spec_helper.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.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Tatarsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -145,6 +145,7 @@ files:
145
145
  - lib/video_torrent_info.rb
146
146
  - spec/fixtures/test.torrent
147
147
  - spec/fixtures/test2.torrent
148
+ - spec/fixtures/test3.torrent
148
149
  - spec/lib/torrent_client_spec.rb
149
150
  - spec/lib/video_torrent_info_spec.rb
150
151
  - spec/spec_helper.rb