/** * Returns a bencoded string that represents a .torrent file and can be * read by BitTorrent clients. * * First item in the $announce_list will be used in the 'announce' key of * the .torrent file, which is compatible with the BitTorrent specification * ('announce-list' is an unofficial extension). * * @return string */ public function createTorrentFile() { $torrent_data = array(); // Info self::addDataToTorrentFile($torrent_data, 'info', $this->getInfo()); // Announce-list/Nodes if (self::addDataToTorrentFile($torrent_data, 'announce-list', Utils::listToListOfLists($this->announce_list))) { self::addDataToTorrentFile($torrent_data, 'announce', reset($this->announce_list)); } else { self::addDataToTorrentFile($torrent_data, 'nodes', $this->nodes); } // Url-list self::addDataToTorrentFile($torrent_data, 'url-list', $this->url_list); // Created by self::addDataToTorrentFile($torrent_data, 'created-by', $this->created_by); return Builder::build($torrent_data); }