mirror of
https://github.com/YGGverse/parser-php.git
synced 2026-03-31 17:25:28 +00:00
add info hash v2 support
This commit is contained in:
parent
80c94381ab
commit
6c73a68024
1 changed files with 26 additions and 1 deletions
|
|
@ -9,13 +9,36 @@ class Magnet {
|
||||||
return ('magnet' == parse_url($link, PHP_URL_SCHEME));
|
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:'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function filterInfoHash(string $value) : string
|
||||||
|
{
|
||||||
|
return str_replace(
|
||||||
|
[
|
||||||
|
'urn:',
|
||||||
|
'btih:',
|
||||||
|
'btmh:',
|
||||||
|
],
|
||||||
|
false,
|
||||||
|
$value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function parse(string $link) : mixed
|
public static function parse(string $link) : mixed
|
||||||
{
|
{
|
||||||
$result =
|
$result =
|
||||||
[
|
[
|
||||||
'xt' => null,
|
|
||||||
'dn' => null,
|
'dn' => null,
|
||||||
'xl' => 0,
|
'xl' => 0,
|
||||||
|
'xt' => [],
|
||||||
'tr' => [],
|
'tr' => [],
|
||||||
'ws' => [],
|
'ws' => [],
|
||||||
'as' => [],
|
'as' => [],
|
||||||
|
|
@ -37,6 +60,7 @@ class Magnet {
|
||||||
[
|
[
|
||||||
'magnet:',
|
'magnet:',
|
||||||
'?',
|
'?',
|
||||||
|
'xt=',
|
||||||
'tr=',
|
'tr=',
|
||||||
'ws=',
|
'ws=',
|
||||||
'as=',
|
'as=',
|
||||||
|
|
@ -47,6 +71,7 @@ class Magnet {
|
||||||
[
|
[
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
'xt[]=',
|
||||||
'tr[]=',
|
'tr[]=',
|
||||||
'ws[]=',
|
'ws[]=',
|
||||||
'as[]=',
|
'as[]=',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue