torckapi 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/torckapi/response/announce.rb +4 -0
- data/lib/torckapi/response/scrape.rb +2 -0
- data/lib/torckapi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e63d158cc83bd620b0e3f2671cbdc39e500404b1
|
4
|
+
data.tar.gz: 11b49a8e0d6b610f868197176be4abb2b4554c0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b122efcf5a5f877563e00a5de5ef64beb4b654792306ab83753514e415a25e7e6efe8a991144594af87d76ba58c38bce4403aaafbaaf9348f614f94482dc547a
|
7
|
+
data.tar.gz: 45b10ca430ede0a93ebfe6a239601daab5ff38e12f50f2f4d6fa7a649a6333cce0954591e86c59724f00a6f75626f2434ac347efc93534f3b91d2450446eae83
|
@@ -19,6 +19,8 @@ module Torckapi
|
|
19
19
|
# @param data [String] UDP response data (omit action and transaction_id)
|
20
20
|
# @return [Torckapi::Response::Announce] response
|
21
21
|
def self.from_udp info_hash, data
|
22
|
+
return new(info_hash, nil, nil, []) unless data
|
23
|
+
|
22
24
|
leechers, seeders = data[0..7].unpack('L>2')
|
23
25
|
|
24
26
|
new info_hash, leechers, seeders, peers_from_compact(data[8..-1], leechers + seeders)
|
@@ -30,6 +32,8 @@ module Torckapi
|
|
30
32
|
# @param compact [true, false] is peer data in compact format?
|
31
33
|
# @return [Torckapi::Response::Announce] response
|
32
34
|
def self.from_http info_hash, data, compact=true
|
35
|
+
return new(info_hash, nil, nil, []) unless data
|
36
|
+
|
33
37
|
bdecoded_data = BEncode.load(data)
|
34
38
|
leechers, seeders = bdecoded_data.values_at("incomplete", "complete")
|
35
39
|
|
@@ -11,6 +11,8 @@ module Torckapi
|
|
11
11
|
# @param data [String] UDP response data (omit action and transaction_id)
|
12
12
|
# @return [Torckapi::Response::Scrape] response
|
13
13
|
def self.from_udp info_hashes, data
|
14
|
+
return new({}) unless data
|
15
|
+
|
14
16
|
new Hash[info_hashes.zip(data.unpack('a12' * (info_hashes.count)).map { |i| Hash[[:seeders, :completed, :leechers].zip i.unpack('L>3').map(&:to_i)] })]
|
15
17
|
end
|
16
18
|
|
data/lib/torckapi/version.rb
CHANGED