video-torrent-info 0.1.3 → 0.1.4

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: 877c422189d7bed20d478883f583f4d0af6ee649
4
- data.tar.gz: 18f749afa8ce9fa0c337ddd83aa12cfe99c4918a
3
+ metadata.gz: 2f90eb792d8378d639b88a82f7e5823e2977ce98
4
+ data.tar.gz: 6ca9b16d95cddd38925d7f844993a5ae96d9aedc
5
5
  SHA512:
6
- metadata.gz: 21e2d15e1569a513428e15f616ecaf891e9855053870dab48ec4e3ca97141fc738da39a6e8b07e66f99e0632404e37e73c81000c628e7901741ce68bf4ecbd62
7
- data.tar.gz: 69c7cde37aebb948e93dd4a47adf1dafe4e2b529e845923342463ba89d6ab8c8d1c936e7b6f680646b573718e8d1690aa2e5687c00502a50e333663381bd1629
6
+ metadata.gz: 1a76bc6c4f4625523b09d75b2fe16b92220eaee8747d35be1e6f4cd8ec03c111b27f891b93058070acf500bfe9c24a3814daa81be5dc2890e3da466675246782
7
+ data.tar.gz: 9c97cc14a725950d78d0db147ace9805c6d0b9ec464ff7014851daa202d0088bd1d16b38e2ebe917c316194d31f5291029c6a741f03039036c2cb0e2d04de282
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -0,0 +1,87 @@
1
+ #include <stdlib.h>
2
+ #include <sstream>
3
+ #include <iostream>
4
+ #include <exception>
5
+ #include "libtorrent/entry.hpp"
6
+ #include "libtorrent/bencode.hpp"
7
+ #include "libtorrent/session.hpp"
8
+ #include "rice/Class.hpp"
9
+ #include "rice/Exception.hpp"
10
+
11
+ using namespace Rice;
12
+
13
+ struct MyException : public std::exception
14
+ {
15
+ std::string s;
16
+ MyException(std::string ss) : s(ss) {}
17
+ ~MyException() throw () {}
18
+ const char* what() const throw() { return s.c_str(); }
19
+ };
20
+
21
+ void load(String torrent_path, int idx, int size, String save_path, int port1, int port2)
22
+ {
23
+ using namespace libtorrent;
24
+
25
+ session s;
26
+ error_code ec;
27
+ std::ostringstream err;
28
+ s.listen_on(std::make_pair(port1, port2), ec);
29
+ if (ec)
30
+ {
31
+ err << "failed to open listen socket: " << ec.message().c_str();
32
+ throw MyException(err.str());
33
+ }
34
+ add_torrent_params p;
35
+ p.save_path = save_path.c_str();
36
+ p.ti = new torrent_info(torrent_path.c_str(), ec);
37
+ if (ec)
38
+ {
39
+ err << "failed to load torrent info: " << ec.message().c_str();
40
+ throw MyException(err.str());
41
+ }
42
+ torrent_handle h = s.add_torrent(p, ec);
43
+ if (ec)
44
+ {
45
+ err << "failed to add torrent: " << ec.message().c_str();
46
+ throw MyException(err.str());
47
+ }
48
+ h.set_sequential_download(true);
49
+ int index = 0;
50
+ for (torrent_info::file_iterator i = p.ti->begin_files(); i != p.ti->end_files(); ++i, ++index)
51
+ {
52
+ if (index == idx) {
53
+ if (size > i->size) size = i->size;
54
+ } else {
55
+ h.file_priority(index, 0);
56
+ }
57
+ }
58
+
59
+ size_type temp = 0;
60
+
61
+ while (true)
62
+ {
63
+ torrent_status st = h.status();
64
+ if (st.total_done > temp)
65
+ {
66
+ temp = st.total_done;
67
+ }
68
+ if (temp >= size)
69
+ {
70
+ return;
71
+ }
72
+ sleep(1000);
73
+ }
74
+ }
75
+ void handle_my_exception(std::exception const & ex)
76
+ {
77
+ throw Exception(rb_eRuntimeError, ex.what());
78
+ }
79
+ extern "C"
80
+ void Init_torrent_client()
81
+ {
82
+ Class rb_cVideoTorrentInfo = define_class("VideoTorrentInfo");
83
+ Class rb_cTorrentClient =
84
+ define_class_under(rb_cVideoTorrentInfo, "TorrentClient")
85
+ .add_handler<MyException>(handle_my_exception)
86
+ .define_method("load", &load);
87
+ }
@@ -2,14 +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.4 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "video-torrent-info"
8
- s.version = "0.1.3"
9
+ s.version = "0.1.4"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Pavel Tatarsky"]
12
- s.date = "2013-12-10"
13
+ s.date = "2013-12-11"
13
14
  s.description = "It simply loads small part of torrent that contains metadata and processes it with ffmpeg"
14
15
  s.email = "fazzzenda@mail.ru"
15
16
  s.extensions = ["ext/torrent_client/extconf.rb"]
@@ -25,6 +26,8 @@ Gem::Specification.new do |s|
25
26
  "README.rdoc",
26
27
  "Rakefile",
27
28
  "VERSION",
29
+ "ext/torrent_client/extconf.rb",
30
+ "ext/torrent_client/torrent_client.cpp",
28
31
  "lib/torrent_client.bundle",
29
32
  "lib/video_torrent_info.rb",
30
33
  "spec/fixtures/test.torrent",
@@ -36,7 +39,7 @@ Gem::Specification.new do |s|
36
39
  s.homepage = "http://github.com/vintikzzz/video-torrent-info"
37
40
  s.licenses = ["MIT"]
38
41
  s.require_paths = ["lib"]
39
- s.rubygems_version = "2.0.5"
42
+ s.rubygems_version = "2.1.11"
40
43
  s.summary = "Gets video info for the torrent file"
41
44
 
42
45
  if s.respond_to? :specification_version then
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.3
4
+ version: 0.1.4
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-10 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -167,6 +167,8 @@ files:
167
167
  - README.rdoc
168
168
  - Rakefile
169
169
  - VERSION
170
+ - ext/torrent_client/extconf.rb
171
+ - ext/torrent_client/torrent_client.cpp
170
172
  - lib/torrent_client.bundle
171
173
  - lib/video_torrent_info.rb
172
174
  - spec/fixtures/test.torrent
@@ -174,7 +176,6 @@ files:
174
176
  - spec/lib/video_torrent_info_spec.rb
175
177
  - spec/spec_helper.rb
176
178
  - video-torrent-info.gemspec
177
- - ext/torrent_client/extconf.rb
178
179
  homepage: http://github.com/vintikzzz/video-torrent-info
179
180
  licenses:
180
181
  - MIT
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  version: '0'
196
197
  requirements: []
197
198
  rubyforge_project:
198
- rubygems_version: 2.0.5
199
+ rubygems_version: 2.1.11
199
200
  signing_key:
200
201
  specification_version: 4
201
202
  summary: Gets video info for the torrent file