Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 10 update #183

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
241 changes: 122 additions & 119 deletions app/Console/Commands/AvmooCrawler.php

Large diffs are not rendered by default.

279 changes: 153 additions & 126 deletions app/Console/Commands/BaseCrawler.php

Large diffs are not rendered by default.

150 changes: 69 additions & 81 deletions app/Console/Commands/Bttool.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;

class Bttool extends Command
{
/**
Expand Down Expand Up @@ -36,16 +37,14 @@ public function __construct()
*/
public function handle()
{


/*
$encoder = new \PHP\BitTorrent\Encoder();
$decoder = new \PHP\BitTorrent\Decoder($encoder);

// $decodedFile = $decoder->decodeFile('resources/t2.torrent');
$torrent = \PHP\BitTorrent\Torrent::createFromTorrentFile('resources/t2.torrent');
var_dump($torrent->getFileList());
die;*/
/*
$encoder = new \PHP\BitTorrent\Encoder();
$decoder = new \PHP\BitTorrent\Decoder($encoder);

// $decodedFile = $decoder->decodeFile('resources/t2.torrent');
$torrent = \PHP\BitTorrent\Torrent::createFromTorrentFile('resources/t2.torrent');
var_dump($torrent->getFileList());
die;*/
// $data = Bencode::load('resources/t2.torrent');
// var_dump(json_encode($data,true));

Expand All @@ -58,114 +57,103 @@ public function handle()

// decode Torrent file
// var_dump(file_get_contents('resources/t2.torrent')[0]);die;
$torrent = $bcoder->bdecode( file_get_contents('resources/t2.torrent'));
$torrent = $bcoder->bdecode(file_get_contents('resources/t2.torrent'));
// var_dump(array_keys($torrent['info']));
// die;
// print_r($torrent['info']['files']);
$Files = $torrent['info']['files'];
function create_ed2k($fname, $fsize, $fhash){
$ed2k_out = 'ed2k://|file|' . $fname . '|' . $fsize . '|' . $fhash . '|/';
function create_ed2k($fname, $fsize, $fhash)
{
$ed2k_out = 'ed2k://|file|'.$fname.'|'.$fsize.'|'.$fhash.'|/';

return $ed2k_out;
}
function create_magnet($dn, $xl = false, $btih = '', $sha1 = '', $ed2k = '', $tree_tiger = '', $md5 = '')
{
$magnet = 'magnet:?';
if ($dn){
$magnet .= 'dn=' . $dn; // download name
if ($dn) {
$magnet .= 'dn='.$dn; // download name
}
if ($xl){
$magnet .= '&xl=' . $xl; // size
if ($xl) {
$magnet .= '&xl='.$xl; // size
}
if ($btih){
$magnet .= '&xt=urn:btih:' . $btih; // bittorrent info_hash (Base32)
if ($btih) {
$magnet .= '&xt=urn:btih:'.$btih; // bittorrent info_hash (Base32)
}
if ($sha1){
$magnet .= '&xt=urn:sha1:' . $sha1; // gnutella sha1 (base32)
if ($sha1) {
$magnet .= '&xt=urn:sha1:'.$sha1; // gnutella sha1 (base32)
}
if ($ed2k){
$magnet .= '&xt=urn:ed2k:' . $ed2k; // emule hash (Hex)
if ($ed2k) {
$magnet .= '&xt=urn:ed2k:'.$ed2k; // emule hash (Hex)
}
if ($tree_tiger){
$magnet .= '&xt=urn:tree:tiger:' . $tree_tiger; // tiger (Base32)
if ($tree_tiger) {
$magnet .= '&xt=urn:tree:tiger:'.$tree_tiger; // tiger (Base32)
}
if ($sha1 && $tree_tiger) {
$magnet .= '&xt=urn:bitprint:' . $sha1 . '.' . $tree_tiger; // Gnutella 2 (Shareaza) bitprint (Base32)
$magnet .= '&xt=urn:bitprint:'.$sha1.'.'.$tree_tiger; // Gnutella 2 (Shareaza) bitprint (Base32)
}
if ($md5){
$magnet .= '&xt=urn:md5:' . $md5; // md5 hash (Hex)
if ($md5) {
$magnet .= '&xt=urn:md5:'.$md5; // md5 hash (Hex)
}

return $magnet;
}




//var_dump($Files);//
foreach($Files as $File) {

if(isset( $File['ed2k'])){


foreach ($Files as $File) {
if (isset($File['ed2k'])) {
// $hex = bin2hex($File['ed2k'] );//二进制转成16进制
$f = $File;
$f["filehash"] =isset($f["filehash"]) ? bin2hex($f["filehash"]) : '';
$f["ed2k"] =bin2hex($f["ed2k"]);
$f['filehash'] = isset($f['filehash']) ? bin2hex($f['filehash']) : '';
$f['ed2k'] = bin2hex($f['ed2k']);
var_dump($f);
$sha1 ='';//isset($f["filehash"]) ? strtoupper(base32_encode($f["filehash"])) : ''; //isset($f["sha1"]) ? strtoupper(base32_encode($f["sha1"])) : '';
$ed2k = $f["ed2k"];
$tiger = isset($f["tiger"]) ? strtoupper(base32_encode($f["tiger"])) : '';
$md5 = isset($f["md5sum"]) ? bin2hex($f["md5sum"]) : '';
$sha1 = ''; //isset($f["filehash"]) ? strtoupper(base32_encode($f["filehash"])) : ''; //isset($f["sha1"]) ? strtoupper(base32_encode($f["sha1"])) : '';
$ed2k = $f['ed2k'];
$tiger = isset($f['tiger']) ? strtoupper(base32_encode($f['tiger'])) : '';
$md5 = isset($f['md5sum']) ? bin2hex($f['md5sum']) : '';
//hashes is set?
$ext_hashes = (isset($f["ed2k"]) || isset($f["sha1"]) || isset($f["tiger"]) || isset($f["md5sum"]));
if ($ext_hashes && isset($f["length"]))
{
if (isset($f["ed2k"]))
{
echo create_ed2k(max($f['path']), $f["length"], $f["ed2k"] ) ."\n";
}
else
{

$ext_hashes = (isset($f['ed2k']) || isset($f['sha1']) || isset($f['tiger']) || isset($f['md5sum']));
if ($ext_hashes && isset($f['length'])) {
if (isset($f['ed2k'])) {
echo create_ed2k(max($f['path']), $f['length'], $f['ed2k'])."\n";
} else {
}
// echo @create_magnet(max($f['path']), $f["length"], '', $sha1, $ed2k, $tiger, $md5)."\n\n";

}
/*
$s = create_ed2k(max($f['path']), $f["length"], bin2hex($f["ed2k"]));
var_dump($s);
die;

var_dump($hex);//die;
var_dump(chr(hexdec($hex)));
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2){
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
// echo @create_magnet(max($f['path']), $f["length"], '', $sha1, $ed2k, $tiger, $md5)."\n\n";
}
// $string = iconv("GBK","utf-8", $string);
/*
$s = create_ed2k(max($f['path']), $f["length"], bin2hex($f["ed2k"]));
var_dump($s);
die;

var_dump($string);die;
// $s =iconv('UTF-8//TRANSLIT', 'utf-8//TRANSLIT', $File['ed2k']);
var_dump($hex);//die;
var_dump(chr(hexdec($hex)));
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2){
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
// $string = iconv("GBK","utf-8", $string);

var_dump($string);die;
// $s =iconv('UTF-8//TRANSLIT', 'utf-8//TRANSLIT', $File['ed2k']);

// $encode = mb_detect_encoding($File['ed2k']);
$encode = mb_detect_encoding($File['ed2k'],array("ASCII","GB2312","GBK",'BIG5','UTF-8'));
var_dump($encode);

var_dump($File['ed2k']);

$s =iconv( $encode,'UTF-8//IGNORE', $File['ed2k']);;
// $s = utf8_encode( $File['ed2k']) ;
var_dump($s);
die;*/
}
// $encode = mb_detect_encoding($File['ed2k']);
$encode = mb_detect_encoding($File['ed2k'],array("ASCII","GB2312","GBK",'BIG5','UTF-8'));
var_dump($encode);

var_dump($File['ed2k']);

$s =iconv( $encode,'UTF-8//IGNORE', $File['ed2k']);;
// $s = utf8_encode( $File['ed2k']) ;
var_dump($s);
die;*/
}
}

// show Torrent contents
$files = $bcoder->filelist( $torrent );
$files = $bcoder->filelist($torrent);
// print_r($files);
die;
exit;
//
//
// $bcoder = new \Bhutanio\BEncode\BEncode();
Expand All @@ -190,6 +178,6 @@ function create_magnet($dn, $xl = false, $btih = '', $sha1 = '', $ed2k = '', $tr
// foreach ($decodedFile as $item) {
// var_dump(json_encode($item));
// }
die;
exit;
}
}