fix: bad parsing of torrentio episode results
This commit is contained in:
@@ -21,29 +21,32 @@ class ResultFactory
|
|||||||
string $bingeGroup = "-",
|
string $bingeGroup = "-",
|
||||||
string $imdbId = "-",
|
string $imdbId = "-",
|
||||||
) {
|
) {
|
||||||
$ptn = (object) (new PTN())->parse($title);
|
$title = trim(preg_replace('/\s+/', ' ', $title));
|
||||||
return new TorrentioResult(
|
$ptn = (object) new PTN()->parse(self::setFilename($url));
|
||||||
|
$result = new TorrentioResult(
|
||||||
self::trimTitle($title),
|
self::trimTitle($title),
|
||||||
urldecode($url),
|
self::setUrl($url),
|
||||||
self::setFilename($url),
|
self::setFilename($url),
|
||||||
self::setSize($title),
|
self::setSize($title),
|
||||||
self::setSeeders($title),
|
self::setSeeders($title),
|
||||||
self::setProvider($title),
|
self::setProvider($title),
|
||||||
self::setEpisode($title),
|
self::setEpisode($title),
|
||||||
$ptn->season ?? "-",
|
self::setSeason($ptn),
|
||||||
$bingeGroup,
|
$bingeGroup,
|
||||||
$ptn->resolution ?? "-",
|
self::setResolution($ptn),
|
||||||
self::setCodec($ptn->codec ?? "-"),
|
self::setCodec($ptn),
|
||||||
$ptn->quality ?? "-",
|
self::setQuality($ptn),
|
||||||
$ptn,
|
$ptn,
|
||||||
substr(base64_encode($url), strlen($url) - 10),
|
self::setKey($url),
|
||||||
$ptn->episode ?? "-",
|
self::setEpisodeNumber($ptn),
|
||||||
self::setLanguages($title),
|
self::setLanguages($title),
|
||||||
self::setLanguageFlags($title),
|
self::setLanguageFlags($title),
|
||||||
false,
|
false,
|
||||||
uniqid(),
|
uniqid(),
|
||||||
$imdbId,
|
$imdbId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setFilename(string $url)
|
public static function setFilename(string $url)
|
||||||
@@ -52,6 +55,11 @@ class ResultFactory
|
|||||||
return end($file);
|
return end($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setUrl(string $url): string
|
||||||
|
{
|
||||||
|
return urldecode($url);
|
||||||
|
}
|
||||||
|
|
||||||
public static function setSize(string $title): string
|
public static function setSize(string $title): string
|
||||||
{
|
{
|
||||||
$sizeMatch = [];
|
$sizeMatch = [];
|
||||||
@@ -112,9 +120,15 @@ class ResultFactory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setCodec(string $codec): string
|
public static function setCodec(object $ptn): string
|
||||||
{
|
{
|
||||||
return self::$codecMap[strtolower($codec)] ?? $codec;
|
if (isset($ptn->codec) && array_key_exists($ptn->codec, self::$codecMap)) {
|
||||||
|
return self::$codecMap[strtolower($ptn->codec)];
|
||||||
|
} elseif (isset($ptn->codec)) {
|
||||||
|
return $ptn->codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function setEpisode(string $title)
|
private static function setEpisode(string $title)
|
||||||
@@ -124,6 +138,36 @@ class ResultFactory
|
|||||||
return array_key_exists(0, $value) ? strtoupper($value[0]) : "n/a";
|
return array_key_exists(0, $value) ? strtoupper($value[0]) : "n/a";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setSeason(object $ptn): string
|
||||||
|
{
|
||||||
|
return $ptn->season ?? "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setBingeGroup(string $bingeGroup): string
|
||||||
|
{
|
||||||
|
return $bingeGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setResolution(object $ptn): string
|
||||||
|
{
|
||||||
|
return $ptn->resolution ?? "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setQuality(object $ptn): string
|
||||||
|
{
|
||||||
|
return $ptn->quality ?? "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setKey(string $url): string
|
||||||
|
{
|
||||||
|
return substr(base64_encode($url), strlen($url) - 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setEpisodeNumber(object $ptn): string
|
||||||
|
{
|
||||||
|
return $ptn->episode ?? "-";
|
||||||
|
}
|
||||||
|
|
||||||
private static function trimTitle(string $title)
|
private static function trimTitle(string $title)
|
||||||
{
|
{
|
||||||
$emoji = \Emoji\detect_emoji($title);
|
$emoji = \Emoji\detect_emoji($title);
|
||||||
|
|||||||
Reference in New Issue
Block a user