https://github.com/jphp-group/jphp-torrent-ext
JBit Torrent API for jphp
https://github.com/jphp-group/jphp-torrent-ext
Last synced: 11 months ago
JSON representation
JBit Torrent API for jphp
- Host: GitHub
- URL: https://github.com/jphp-group/jphp-torrent-ext
- Owner: jphp-group
- Created: 2018-07-08T17:19:57.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-08T17:53:48.000Z (almost 8 years ago)
- Last Synced: 2024-12-23T19:23:17.834Z (over 1 year ago)
- Language: Java
- Size: 96.7 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Torrent API for JPHP
> JBit Torrent API
### Examples
Get torrent info :
```php
use php\torrent\TorrentFile;
$file = TorrentFile::of("path/to/torrentFile");
for ($i = 0; $i < count($file->length); $i++)
$size += $file->length[$i];
echo "-> Torrent info : \n";
echo " -> CreatedBy : " . $file->createdBy . "\n";
echo " -> CreationDate : " . $file->creationDate . "\n";
echo " -> Encoding : " . $file->encoding . "\n";
echo " -> SaveAs : " . $file->saveAs . "\n";
echo " -> Comment : " . $file->comment . "\n";
echo " -> AnnounceURL : " . $file->announceURL . "\n";
echo " -> Size : " . $size . " Bytes \n";
echo " -> files :\n";
for ($i = 0; $i < count($file->length); $i++)
{
echo " -> [{$file->name[$i]}], size : {$file->length[$i]} Bytes \n";
}
```
Download :
```php
use php\torrent\{ TorrentFile, DownloadManager };
$dm = new DownloadManager(TorrentFile::of("path/to/torrentFile"));
$dm->startDownload(function () {
// callback running every 1 second if download doesn't complete
// callback running not in graphical stream!
});
```
Create torrent file :
```php
use php\torrent\TorrentProcessor;
$tp = TorrentProcessor();
$tp->setCreationDate(date as int);
$tp->setCreator("jphp torrent api");
$tp->setEncoding("UTF-8");
$tp->setComment("test");
$tp->setPieceLength(100);
$tp->setAnnounceURL(null); // Often, you can leave empty, because the tracker itself overwrites this header.
$tp->setName("test"); // In what folder will be the data downloaded through our torrent file
$tp->addFile("path/to/file");
$tp->save("./test.torrent");
```