diff --git a/core/downloaders/BlackHole.py b/core/downloaders/BlackHole.py index f9f56408..923e1eae 100644 --- a/core/downloaders/BlackHole.py +++ b/core/downloaders/BlackHole.py @@ -165,7 +165,38 @@ def _download_magnet(data, path): continue logging.warning('Torrent hash {} not found on any torrent cache.'.format(magnet_hash)) - return False + + logging.warning('Creating a torrent file from hash {}.'.format(magnet_hash)) + + tf_elements = ['d10:magnet-uri', + 'LENGTH', + 'magnet:?xt=urn:btih:', + magnet_hash, + '&dn=', + magnet_hash, + '&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce', + '&tr=udp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce', + '&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337', + '&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969', + '&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337', + '&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce', + '&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce', + '&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce', + 'e'] + + # calculate and update the lenght of magnet file + mlenght = 0 + + for a in tf_elements[2:-1]: + mlenght += len(a) + + tf_elements[1] = str(mlenght) + ":" + + torrent_file = "".join(tf_elements) + + with open(path, 'w') as f: + f.write(torrent_file) + return True def _verify_torrent(stream, magnet):