finish implementing torrent verb
This commit is contained in:
parent
9b0a84c02f
commit
4cb06525a4
2 changed files with 49 additions and 7 deletions
|
@ -1,5 +1,34 @@
|
|||
import time
|
||||
import hashlib
|
||||
|
||||
import bencode
|
||||
import resumablehashlib
|
||||
|
||||
from app import app
|
||||
|
||||
|
||||
TRACKER_ANNOUNCE_URL = app.config.get('BT_TRACKER_ANNOUNCE_URL')
|
||||
NAMING_SALT = app.config.get('BT_NAMING_SALT')
|
||||
|
||||
def private_torrent_name(user_uuid, blob_uuid):
|
||||
return hashlib.sha256(blob_uuid + user_uuid + NAMING_SALT).hexdigest()
|
||||
|
||||
|
||||
def make_torrent(name, webseed, length, piece_length, pieces):
|
||||
return bencode.bencode({
|
||||
'announce': TRACKER_ANNOUNCE_URL,
|
||||
'url-list': webseed,
|
||||
'encoding': 'UTF-8',
|
||||
'created by': 'Quay Container Registry',
|
||||
'creation date': int(time.time()),
|
||||
'info': {
|
||||
'name': name,
|
||||
'length': length,
|
||||
'piece length': piece_length,
|
||||
'pieces': pieces,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
class PieceHasher(object):
|
||||
def __init__(self, piece_size, starting_offset, starting_piece_hash_bytes, hash_fragment_to_resume):
|
||||
|
|
Reference in a new issue