Skip to content

Commit

Permalink
Merge pull request #412 from pushrbx/hotfix/v3.0.0-missing-bits
Browse files Browse the repository at this point in the history
Rebased the v3.0.0 branch on master
  • Loading branch information
irfan-dahir authored Jun 5, 2022
2 parents e2094b9 + d916326 commit b37a90d
Show file tree
Hide file tree
Showing 86 changed files with 2,437 additions and 1,414 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"jakub-onderka/php-parallel-lint": "^1.0",
"jikan-me/jikan-fixtures": "dev-master",
"php-vcr/php-vcr": "^1.6",
"php-vcr/phpunit-testlistener-vcr": "^3.1",
"phpro/grumphp": "^1.7.0",
"phpunit/phpunit": "~9.0",
"squizlabs/php_codesniffer": "^3.3"
Expand Down
16 changes: 11 additions & 5 deletions src/Helper/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ class Constants
public const TOP_TV = 'tv';
public const TOP_MOVIE = 'movie';
public const TOP_OVA = 'ova';
public const TOP_ONA = 'ona';
public const TOP_SPECIAL = 'special';
public const TOP_ONA = 'ona';

public const TOP_MANGA = 'manga';
public const TOP_LIGHTNOVELS = 'lightnovels';
public const TOP_NOVEL = 'novels';
public const TOP_ONE_SHOT = 'oneshots';
public const TOP_DOUJINSHI = 'doujin';
Expand All @@ -51,9 +49,12 @@ class Constants
public const TOP_BY_POPULARITY = 'bypopularity';
public const TOP_BY_FAVORITES = 'favorite';

public const TOP_REVIEW_ANIME = 'anime';
public const TOP_REVIEW_MANGA = 'manga';
public const TOP_REVIEW_BEST_VOTED = 'bestvoted';
public const RECENT_REVIEW_ANIME = 'anime';
public const RECENT_REVIEW_MANGA = 'manga';
public const RECENT_REVIEW_BEST_VOTED = 'bestvoted';

public const RECENT_RECOMMENDATION_ANIME = 'anime';
public const RECENT_RECOMMENDATION_MANGA = 'manga';

// v3 status const // remove old ones
public const STATUS_ANIME_AIRING = 1;
Expand Down Expand Up @@ -132,6 +133,11 @@ class Constants
public const SEARCH_MANGA_ORDER_BY_TYPE = 8; // Default: Manhua, Manhwa, Doujinshi, One-shot, Novel, Manga
public const SEARCH_MANGA_ORDER_BY_ID = 9;

public const SEARCH_USER_GENDER_ANY = -1;
public const SEARCH_USER_GENDER_MALE = 1;
public const SEARCH_USER_GENDER_FEMALE = 2;
public const SEARCH_USER_GENDER_NONBINARY = 3;

public const GENRE_ANIME_ACTION = 1;
public const GENRE_ANIME_ADVENTURE = 2;
public const GENRE_ANIME_CARS = 3;
Expand Down
29 changes: 28 additions & 1 deletion src/Helper/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ public static function idFromUrl(string $url): int
return (int)preg_replace('#https://myanimelist.net(/\w+/)(\d+).*#', '$2', $url);
}

/**
* Extract club ID from MAL URl
*
* @param string $url
* @return int
*/
public static function clubIdFromUrl(string $url) : int
{
return (int) preg_replace('~.*\.php\?cid=([\d]+)$~', '$1', $url);
}

/**
* Extract the last property id from a mal url (e.g episode ID)
*
* @param string $url
*
* @return int
*/
public static function suffixIdFromUrl(string $url): int
{
return (int) preg_replace('#https://myanimelist.net/.*/(\d+)#', '$1', $url);
}

/**
* @param string $date
*
Expand Down Expand Up @@ -192,7 +215,7 @@ public static function textOrNull(Crawler $crawler): ?string
public static function parseImageQuality(string $imageUrl) : string
{
// adding `v` prefix returns a very small thumbnail, as opposed to adding `l`
$imageUrl = str_replace(['v.jpg'], '.jpg', $imageUrl);
$imageUrl = str_replace(['v.jpg', 't.jpg', 'l.jpg'], '.jpg', $imageUrl);
return preg_replace('~/r/\d+x\d+~', '', $imageUrl);
}

Expand All @@ -207,6 +230,10 @@ public static function parseImageThumbToHQ(string $imageUrl) : string
return str_replace(['thumbs/', '_thumb'], '', $imageUrl);
}

/**
* @param string $duration
* @return int|null
*/
public static function parseDurationToSeconds(string $duration): ?int
{
preg_match('~([0-9]{2}):([0-9]{2}):([0-9]{2})~', $duration, $match);
Expand Down
Loading

0 comments on commit b37a90d

Please sign in to comment.