|
|
@@ -1261,6 +1261,24 @@ def cmd_list(options, persona, objstr, cache): |
|
|
|
@init_datastructs |
|
|
|
def cmd_container(options, persona, objstr, cache): |
|
|
|
for i in options.files: |
|
|
|
with open(i, 'rb') as fp: |
|
|
|
torrent = bencode.bdecode(fp.read()) |
|
|
|
bencodedinfo = bencode.bencode(torrent['info']) |
|
|
|
infohash = hashlib.sha1(bencodedinfo).hexdigest() |
|
|
|
|
|
|
|
# XXX - not entirely happy w/ URI |
|
|
|
uri = 'magnet:?xt=urn:btih:%s&dn=%s' % (infohash, |
|
|
|
torrent['info']['name'].decode('utf-8')) |
|
|
|
|
|
|
|
try: |
|
|
|
cont = objstr.by_id(Container.make_id(uri)) |
|
|
|
except KeyError: |
|
|
|
pass |
|
|
|
else: |
|
|
|
if not 'incomplete' in cont: |
|
|
|
print('Warning, container already complete, skipping %s.' % repr(i), file=sys.stderr) |
|
|
|
continue |
|
|
|
|
|
|
|
good, bad = validate_file(i) |
|
|
|
|
|
|
|
if bad: |
|
|
@@ -1283,15 +1301,6 @@ def cmd_container(options, persona, objstr, cache): |
|
|
|
# XXX - ensure only one is added? |
|
|
|
hashes.extend(fobj.hashes) |
|
|
|
|
|
|
|
with open(i, 'rb') as fp: |
|
|
|
torrent = bencode.bdecode(fp.read()) |
|
|
|
bencodedinfo = bencode.bencode(torrent['info']) |
|
|
|
infohash = hashlib.sha1(bencodedinfo).hexdigest() |
|
|
|
|
|
|
|
# XXX - not entirely happy w/ URI |
|
|
|
uri = 'magnet:?xt=urn:btih:%s&dn=%s' % (infohash, |
|
|
|
torrent['info']['name'].decode('utf-8')) |
|
|
|
|
|
|
|
kwargs = dict(files=files, hashes=hashes, |
|
|
|
uri=uri) |
|
|
|
|
|
|
|