bencview 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -6
  3. data/bencview.rb +11 -8
  4. data/package.gemspec +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92a0139e1908590118e2d0bd7e0db48b3f8a94e7
4
- data.tar.gz: a18f7b361bb9d4dcb5e83f45fd1d0773306db79f
3
+ metadata.gz: 40b976c6e332d26cb7c3bee2a5fbc22a575c64a1
4
+ data.tar.gz: a01ac7f191ca7638ff9dd099e8882b8ecdb8e622
5
5
  SHA512:
6
- metadata.gz: b8221a19897cc70e617566f8379def9e18fbe1085a4867a0265cf77566c4244383fe60b2d01700bdc99dd3ecbb0fff2ff7d298f8520825384acf081c4c9989a9
7
- data.tar.gz: ab6bc66c3b656aa476e673d352e23e8ec1bd1de14008d53799d54d7b7c0bbcdd23abe97bc414f82ac4b116ba48c85fabb5249d944ff04fd63440e374f9b1418a
6
+ metadata.gz: 9ab3c13e2634f35f38df043782a47c9362e51b492026ab40d6cb2ce470fe9a16ec8fdca09dbb4460aa67b3a53b745f29ab9d3d9771c185d7769f0617d58b720c
7
+ data.tar.gz: 664119ba1de4bb7f8a5a760f8d1e2ebd64399a9deb141a8a3540a1399b7e4eab55f2658c5a36f370583f5e4cc2247fe1169a699635a8ea1599357998514f3613
data/README.md CHANGED
@@ -31,8 +31,8 @@ View a torrent file:
31
31
 
32
32
  ~~~
33
33
  $ bencview gimp.torrent
34
- infohash: a85b7e7f035c55f684238d0e252b273fe2a1ccf5
35
- uri: magnet:?xt=urn:btih:a85b7e7f035c55f684238d0e252b273fe2a1ccf5&dn=gimp-2.8.14-setup-1.exe.torrent
34
+ *info-hash: a85b7e7f035c55f684238d0e252b273fe2a1ccf5
35
+ *uri: magnet:?xt=urn:btih:a85b7e7f035c55f684238d0e252b273fe2a1ccf5&dn=gimp-2.8.14-setup-1.exe
36
36
  announce: udp://tracker.publicbt.com:80
37
37
  announce-list: 2
38
38
  udp://tracker.publicbt.com:80
@@ -45,11 +45,14 @@ url-list: 34
45
45
  http://gimp.afri.cc/pub/gimp/v2.8/windows
46
46
  [...]
47
47
  info/name: gimp-2.8.14-setup-1.exe
48
+ info/*pieces: 351 x 262,144
48
49
  info/files: 1
49
50
  91,931,728 gimp-2.8.14-setup-1.exe
50
- info/files size: 91,931,728
51
+ info/*files size: 91,931,728
51
52
  ~~~
52
53
 
54
+ Properties prefixed w/ '*' don't exist in the torrent file.
55
+
53
56
  Remove all trackers from it:
54
57
 
55
58
  ~~~
@@ -59,8 +62,8 @@ $ file file.torrent
59
62
  file.torrent: BitTorrent file
60
63
 
61
64
  $ bencview file.torrent
62
- infohash: a85b7e7f035c55f684238d0e252b273fe2a1ccf5
63
- uri: magnet:?xt=urn:btih:a85b7e7f035c55f684238d0e252b273fe2a1ccf5&dn=gimp-2.8.14-setup-1.exe.torrent
65
+ *info-hash: a85b7e7f035c55f684238d0e252b273fe2a1ccf5
66
+ *uri: magnet:?xt=urn:btih:a85b7e7f035c55f684238d0e252b273fe2a1ccf5&dn=gimp-2.8.14-setup-1.exe
64
67
  comment: GIMP 2.8.14 Installer for Microsoft Windows - updated
65
68
  created by: mktorrent 1.0
66
69
  creation date: Tue, 2 Sep 2014 22:05:50 +0000
@@ -69,9 +72,10 @@ url-list: 34
69
72
  http://gimp.afri.cc/pub/gimp/v2.8/windows
70
73
  [...]
71
74
  info/name: gimp-2.8.14-setup-1.exe
75
+ info/*pieces: 351 x 262,144
72
76
  info/files: 1
73
77
  91,931,728 gimp-2.8.14-setup-1.exe
74
- info/files size: 91,931,728
78
+ info/*files size: 91,931,728
75
79
  ~~~
76
80
 
77
81
  Note that the infohash hasn't changed.
@@ -50,7 +50,7 @@ class Bencview::Torrent
50
50
  # BitTorrent specific
51
51
  def magnet name
52
52
  return nil unless @infohash
53
- "magnet:?xt=urn:btih:#{@infohash}" + (name ? "&dn=#{URI.escape name}.torrent" : "")
53
+ "magnet:?xt=urn:btih:#{@infohash}" + (name ? "&dn=#{URI.escape name}" : "")
54
54
  end
55
55
 
56
56
  # BitTorrent specific
@@ -62,8 +62,11 @@ class Bencview::Torrent
62
62
  r = []
63
63
  obj.each do |key,val|
64
64
  key = key.to_s.strip
65
- if key =~ /^piece/
66
- # TODO: calc the chunks
65
+ if key == 'piece length'
66
+ # ignore
67
+ elsif key == 'pieces' && obj['piece length']
68
+ pieces = val.bytesize / 20
69
+ r.push "#{rkey.call '*pieces'}: #{num pieces} x #{num obj['piece length']}"
67
70
  elsif key =~ /\.utf-8$/
68
71
  # ignore
69
72
  elsif key =~ /^(files|length)$/
@@ -89,7 +92,7 @@ class Bencview::Torrent
89
92
  arr.each do |file|
90
93
  files.push "%#{max}s %s" % [num(file['length']), file['path'].join('/')]
91
94
  end
92
- files.push "#{rkey.call 'files size'}: #{num bytes}"
95
+ files.push "#{rkey.call '*files size'}: #{num bytes}"
93
96
  end
94
97
 
95
98
  if obj['files']
@@ -98,7 +101,7 @@ class Bencview::Torrent
98
101
  files_add.call [{'length' => obj['length'], 'path' => [obj['name']]}]
99
102
  end
100
103
 
101
- r.concat files if files
104
+ r.concat files
102
105
  end
103
106
 
104
107
  def to_a obj=nil, prefix=''
@@ -110,8 +113,8 @@ class Bencview::Torrent
110
113
  rkey = -> key { "#{prefix}#{key}" }
111
114
 
112
115
  if @infohash && prefix == ''
113
- r.push "infohash: #{@infohash}"
114
- r.push "uri: #{magnet @input.dig 'info', 'name'}"
116
+ r.push "*info-hash: #{@infohash}"
117
+ r.push "*uri: #{magnet @input.dig 'info', 'name'}"
115
118
  end
116
119
 
117
120
  obj.each do |key,val|
@@ -129,7 +132,7 @@ class Bencview::Torrent
129
132
  end
130
133
  end
131
134
 
132
- r.concat info if info
135
+ r.concat info if info # add the info section to the very end
133
136
  r
134
137
  end
135
138
 
@@ -1,5 +1,5 @@
1
1
  Gem::Specification.new do |s|
2
- s.version = '1.0.0'
2
+ s.version = '1.0.1'
3
3
 
4
4
  s.name = 'bencview'
5
5
  s.summary = "View .torrent files; JSON export/import"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bencview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Gromnitsky
8
8
  autorequire:
9
9
  bindir: "."
10
10
  cert_chain: []
11
- date: 2017-06-05 00:00:00.000000000 Z
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bencode