mirror of
https://github.com/YGGverse/parser-php.git
synced 2026-03-31 17:25:28 +00:00
Compare commits
6 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74de022cd5 | ||
|
|
26111fce28 | ||
|
|
47c7d13697 | ||
|
|
81f019be7a | ||
|
|
c32a3b5f7d | ||
|
|
6c73a68024 |
4 changed files with 32 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace YGGverse\Parser;
|
||||
namespace Yggverse\Parser;
|
||||
|
||||
class Magnet {
|
||||
|
||||
|
|
@ -9,13 +9,38 @@ class Magnet {
|
|||
return ('magnet' == parse_url($link, PHP_URL_SCHEME));
|
||||
}
|
||||
|
||||
public static function isXTv1(string $xt) : bool
|
||||
{
|
||||
return ('urn' == parse_url($xt, PHP_URL_SCHEME) && false !== strpos($xt, ':btih:'));
|
||||
}
|
||||
|
||||
public static function isXTv2(string $xt) : bool
|
||||
{
|
||||
return ('urn' == parse_url($xt, PHP_URL_SCHEME) && false !== strpos($xt, ':btmh:1220'));
|
||||
}
|
||||
|
||||
public static function filterInfoHash(string $value) : string
|
||||
{
|
||||
return trim(
|
||||
str_replace(
|
||||
[
|
||||
'urn:',
|
||||
'btih:',
|
||||
'btmh:1220',
|
||||
],
|
||||
false,
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function parse(string $link) : mixed
|
||||
{
|
||||
$result =
|
||||
[
|
||||
'xt' => null,
|
||||
'dn' => null,
|
||||
'xl' => 0,
|
||||
'xt' => [],
|
||||
'tr' => [],
|
||||
'ws' => [],
|
||||
'as' => [],
|
||||
|
|
@ -37,6 +62,7 @@ class Magnet {
|
|||
[
|
||||
'magnet:',
|
||||
'?',
|
||||
'xt=',
|
||||
'tr=',
|
||||
'ws=',
|
||||
'as=',
|
||||
|
|
@ -47,6 +73,7 @@ class Magnet {
|
|||
[
|
||||
false,
|
||||
false,
|
||||
'xt[]=',
|
||||
'tr[]=',
|
||||
'ws[]=',
|
||||
'as[]=',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace YGGverse\Parser;
|
||||
namespace Yggverse\Parser;
|
||||
|
||||
class Url {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace YGGverse\Parser;
|
||||
namespace Yggverse\Parser;
|
||||
|
||||
class Urn {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace YGGverse\Parser\Tests;
|
||||
namespace Yggverse\Parser\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue