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));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
$result =
|
||||
[
|
||||
'xt' => null,
|
||||
'dn' => null,
|
||||
'xl' => 0,
|
||||
'xt' => [],
|
||||
'tr' => [],
|
||||
'ws' => [],
|
||||
'as' => [],
|
||||
|
|
@ -37,6 +60,7 @@ class Magnet {
|
|||
[
|
||||
'magnet:',
|
||||
'?',
|
||||
'xt=',
|
||||
'tr=',
|
||||
'ws=',
|
||||
'as=',
|
||||
|
|
@ -47,6 +71,7 @@ class Magnet {
|
|||
[
|
||||
false,
|
||||
false,
|
||||
'xt[]=',
|
||||
'tr[]=',
|
||||
'ws[]=',
|
||||
'as[]=',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue