mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Fix couple of issues introduced after shift update
This commit is contained in:
@@ -43,7 +43,7 @@ abstract class Videos
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $echooutput;
|
||||
public bool $echooutput;
|
||||
|
||||
/**
|
||||
* @var array sites The sites that we have an ID columns for in our video table.
|
||||
@@ -53,7 +53,7 @@ abstract class Videos
|
||||
/**
|
||||
* @var array Temp Array of cached failed lookups
|
||||
*/
|
||||
public $titleCache;
|
||||
public array $titleCache;
|
||||
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
@@ -71,18 +71,21 @@ abstract class Videos
|
||||
* Main processing director function for scrapers
|
||||
* Calls work query function and initiates processing.
|
||||
*
|
||||
* @param bool $local
|
||||
* @param int $groupID
|
||||
* @param string $guidChar
|
||||
* @param $process
|
||||
* @param bool $local
|
||||
*/
|
||||
abstract protected function processSite($groupID, $guidChar, $process, $local = false): void;
|
||||
abstract protected function processSite(int $groupID, string $guidChar, int $process, bool $local = false): void;
|
||||
|
||||
/**
|
||||
* Get video info from a Video ID and column.
|
||||
*
|
||||
* @param string $siteColumn
|
||||
* @param int $videoID
|
||||
* @param string $siteColumn
|
||||
* @param int $videoID
|
||||
* @return array|false False if invalid site, or ID not found; Site id value otherwise.
|
||||
*/
|
||||
protected function getSiteIDFromVideoID($siteColumn, $videoID)
|
||||
protected function getSiteIDFromVideoID(string $siteColumn, int $videoID): bool|array
|
||||
{
|
||||
if (\in_array($siteColumn, self::$sites, false)) {
|
||||
$result = Video::query()->where('id', $videoID)->first([$siteColumn]);
|
||||
@@ -96,10 +99,10 @@ abstract class Videos
|
||||
/**
|
||||
* Get TV show local timezone from a Video ID.
|
||||
*
|
||||
* @param int $videoID
|
||||
* @param int $videoID
|
||||
* @return string Empty string if no query return or tz style timezone
|
||||
*/
|
||||
protected function getLocalZoneFromVideoID($videoID): string
|
||||
protected function getLocalZoneFromVideoID(int $videoID): string
|
||||
{
|
||||
$result = TvInfo::query()->where('videos_id', $videoID)->first(['localzone']);
|
||||
|
||||
@@ -110,9 +113,11 @@ abstract class Videos
|
||||
* Get video info from a Site ID and column.
|
||||
*
|
||||
*
|
||||
* @param string $siteColumn
|
||||
* @param int $siteID
|
||||
* @return bool|int
|
||||
*/
|
||||
protected function getVideoIDFromSiteID($siteColumn, $siteID)
|
||||
protected function getVideoIDFromSiteID(string $siteColumn, int $siteID): bool|int
|
||||
{
|
||||
$result = null;
|
||||
if (\in_array($siteColumn, self::$sites, false)) {
|
||||
@@ -123,10 +128,10 @@ abstract class Videos
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $source
|
||||
* @param int $source
|
||||
* @return $this|array|bool|false|\Illuminate\Database\Eloquent\Model|mixed|null
|
||||
*/
|
||||
public function getByTitle($title, $type, $source = 0)
|
||||
public function getByTitle(string $title, $type, int $source = 0): mixed
|
||||
{
|
||||
// Check if we already have an entry for this show.
|
||||
$res = $this->getTitleExact($title, $type, $source);
|
||||
@@ -195,10 +200,10 @@ abstract class Videos
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $source
|
||||
* @param int $source
|
||||
* @return bool|\Illuminate\Database\Eloquent\Model|null|static
|
||||
*/
|
||||
public function getTitleExact($title, $type, $source = 0)
|
||||
public function getTitleExact(string $title, int $type, int $source = 0): \Illuminate\Database\Eloquent\Model|bool|null|static
|
||||
{
|
||||
$return = false;
|
||||
if (! empty($title)) {
|
||||
@@ -231,10 +236,10 @@ abstract class Videos
|
||||
/**
|
||||
* Supplementary function for getByTitle that queries for a like match.
|
||||
*
|
||||
* @param int $source
|
||||
* @param int $source
|
||||
* @return array|false
|
||||
*/
|
||||
public function getTitleLoose($title, $type, $source = 0)
|
||||
public function getTitleLoose($title, $type, int $source = 0): bool|array
|
||||
{
|
||||
$return = false;
|
||||
|
||||
@@ -272,10 +277,10 @@ abstract class Videos
|
||||
* Supplementary function for getByTitle that replaces special chars to find an exact match.
|
||||
* Add more ->whereRaw() methods if needed. Might slow TV PP down though.
|
||||
*
|
||||
* @param int $source
|
||||
* @param int $source
|
||||
* @return bool|\Illuminate\Database\Eloquent\Model|null|static
|
||||
*/
|
||||
public function getAlternativeTitleExact($title, $type, $source = 0)
|
||||
public function getAlternativeTitleExact(string $title, int $type, int $source = 0): \Illuminate\Database\Eloquent\Model|bool|null|static
|
||||
{
|
||||
$return = false;
|
||||
if (! empty($title)) {
|
||||
@@ -328,7 +333,7 @@ abstract class Videos
|
||||
*
|
||||
* @return VideoAlias[]|bool|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|mixed
|
||||
*/
|
||||
public function getAliases(int $videoId, string $alias = '')
|
||||
public function getAliases(int $videoId, string $alias = ''): mixed
|
||||
{
|
||||
$return = false;
|
||||
$expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium'));
|
||||
|
||||
@@ -183,12 +183,12 @@ class TMDB extends TV
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
protected function getShowInfo(string $cleanName): bool|array
|
||||
protected function getShowInfo(string $name): bool|array
|
||||
{
|
||||
$return = $response = false;
|
||||
|
||||
try {
|
||||
$response = TmdbClient::getSearchApi()->searchTv($cleanName);
|
||||
$response = TmdbClient::getSearchApi()->searchTv($name);
|
||||
} catch (TmdbApiException|\ErrorException $e) {
|
||||
return false;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ class TMDB extends TV
|
||||
sleep(1);
|
||||
|
||||
if (\is_array($response) && ! empty($response['results'])) {
|
||||
$return = $this->matchShowInfo($response['results'], $cleanName);
|
||||
$return = $this->matchShowInfo($response['results'], $name);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
@@ -50,30 +50,24 @@ abstract class TV extends Videos
|
||||
|
||||
protected const FAILED_PARSE = -100; // Failed Parsing
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $tvqty;
|
||||
public int $tvqty;
|
||||
|
||||
/**
|
||||
* @string Path to Save Images
|
||||
*/
|
||||
public $imgSavePath;
|
||||
public string $imgSavePath;
|
||||
|
||||
/**
|
||||
* @var array Site ID columns for TV
|
||||
*/
|
||||
public $siteColumns;
|
||||
public array $siteColumns;
|
||||
|
||||
/**
|
||||
* @var string The TV categories_id lookup SQL language
|
||||
*/
|
||||
public $catWhere;
|
||||
public string $catWhere;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\ColorCLI
|
||||
*/
|
||||
protected $colorCli;
|
||||
protected ColorCLI $colorCli;
|
||||
|
||||
/**
|
||||
* TV constructor.
|
||||
@@ -93,27 +87,22 @@ abstract class TV extends Videos
|
||||
|
||||
/**
|
||||
* Retrieve banner image from site using its API.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function getBanner($videoID, $siteId);
|
||||
abstract protected function getBanner(int $videoID, int $siteId): mixed;
|
||||
|
||||
/**
|
||||
* Retrieve info of TV episode from site using its API.
|
||||
*
|
||||
* @param int $siteId
|
||||
* @param int $series
|
||||
* @param int $episode
|
||||
* @return array|false False on failure, an array of information fields otherwise.
|
||||
*/
|
||||
abstract protected function getEpisodeInfo($siteId, $series, $episode);
|
||||
abstract protected function getEpisodeInfo(int $siteId, int $series, int $episode): array|bool;
|
||||
|
||||
/**
|
||||
* Retrieve poster image for TV episode from site using its API.
|
||||
*
|
||||
* @param int $videoId ID from videos table.
|
||||
*/
|
||||
abstract protected function getPoster($videoId): int;
|
||||
abstract protected function getPoster(int $videoId): int;
|
||||
|
||||
/**
|
||||
* Retrieve info of TV programme from site using it's API.
|
||||
@@ -121,7 +110,7 @@ abstract class TV extends Videos
|
||||
* @param string $name Title of programme to look up. Usually a cleaned up version from releases table.
|
||||
* @return array|false False on failure, an array of information fields otherwise.
|
||||
*/
|
||||
abstract protected function getShowInfo($name);
|
||||
abstract protected function getShowInfo(string $name): bool|array;
|
||||
|
||||
/**
|
||||
* Assigns API show response values to a formatted array for insertion
|
||||
@@ -136,16 +125,9 @@ abstract class TV extends Videos
|
||||
abstract protected function formatEpisodeInfo($episode): array;
|
||||
|
||||
/**
|
||||
* Retrieve releases for TV processing.
|
||||
*
|
||||
*
|
||||
* @param string $groupID
|
||||
* @param string $guidChar
|
||||
* @param int $lookupSetting
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Collection|int|static[]
|
||||
* @return \App\Models\Release[]|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection|int
|
||||
*/
|
||||
public function getTvReleases($groupID = '', $guidChar = '', $lookupSetting = 1, $status = 0)
|
||||
public function getTvReleases(string $groupID = '', string $guidChar = '', int $lookupSetting = 1, int $status = 0): array|\Illuminate\Database\Eloquent\Collection|int|\Illuminate\Support\Collection
|
||||
{
|
||||
$ret = 0;
|
||||
if ($lookupSetting === 0) {
|
||||
@@ -172,12 +154,7 @@ abstract class TV extends Videos
|
||||
return $qry->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the release when match for the current scraper is found.
|
||||
*
|
||||
* @param int $episodeId
|
||||
*/
|
||||
public function setVideoIdFound($videoId, $releaseId, $episodeId): void
|
||||
public function setVideoIdFound(int $videoId, int $releaseId, int $episodeId): void
|
||||
{
|
||||
Release::query()
|
||||
->where('id', $releaseId)
|
||||
@@ -255,12 +232,7 @@ abstract class TV extends Videos
|
||||
return $videoId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new TV episode into the tv_episodes table following a match to a Video ID.
|
||||
*
|
||||
* @return false|int
|
||||
*/
|
||||
public function addEpisode($videoId, array $episode = [])
|
||||
public function addEpisode(int $videoId, array $episode = []): bool|int
|
||||
{
|
||||
$episodeId = $this->getBySeasonEp($videoId, $episode['series'], $episode['episode'], $episode['firstaired']);
|
||||
|
||||
@@ -281,13 +253,7 @@ abstract class TV extends Videos
|
||||
return $episodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the show info with data from the supplied array
|
||||
* Only called when a duplicate show is found during insert.
|
||||
*
|
||||
* @param int $videoId
|
||||
*/
|
||||
public function update($videoId, array $show = []): void
|
||||
public function update(int $videoId, array $show = []): void
|
||||
{
|
||||
if ($show['country'] !== '') {
|
||||
$show['country'] = Country::countryCode($show['country']);
|
||||
@@ -324,14 +290,9 @@ abstract class TV extends Videos
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a TV show entirely from all child tables via the Video ID.
|
||||
*
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function delete($id)
|
||||
public function delete(int $id): mixed
|
||||
{
|
||||
return DB::transaction(function () use ($id) {
|
||||
DB::delete(
|
||||
@@ -349,22 +310,15 @@ abstract class TV extends Videos
|
||||
}, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the TV show's image column to found (1).
|
||||
*/
|
||||
public function setCoverFound($videoId): void
|
||||
public function setCoverFound(int $videoId): void
|
||||
{
|
||||
TvInfo::query()->where('videos_id', $videoId)->update(['image' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get site ID from a Video ID and the site's respective column.
|
||||
* Returns the ID value or false if none found.
|
||||
*
|
||||
*
|
||||
* @return bool|\Illuminate\Database\Eloquent\Model|mixed|null|static
|
||||
* @return \App\Models\Video|false|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function getSiteByID($column, $id)
|
||||
public function getSiteByID(string $column, int $id): \Illuminate\Database\Eloquent\Model|bool|\Illuminate\Database\Eloquent\Builder|Video
|
||||
{
|
||||
$return = false;
|
||||
$video = Video::query()->where('id', $id)->first([$column]);
|
||||
@@ -383,10 +337,9 @@ abstract class TV extends Videos
|
||||
*
|
||||
* Returns the Episode ID or false if not found
|
||||
*
|
||||
* @param string $airdate
|
||||
* @return int|false
|
||||
*/
|
||||
public function getBySeasonEp($id, $series, $episode, $airdate = '')
|
||||
public function getBySeasonEp(int $id, int $series, int $episode, string $airdate = ''): bool|int
|
||||
{
|
||||
if ($series > 0 && $episode > 0) {
|
||||
$queryString = sprintf('tve.series = %d AND tve.episode = %d', $series, $episode);
|
||||
@@ -414,7 +367,7 @@ abstract class TV extends Videos
|
||||
/**
|
||||
* Returns (true) if episodes for a given Video ID exist or don't (false).
|
||||
*/
|
||||
public function countEpsByVideoID($videoId): bool
|
||||
public function countEpsByVideoID(int $videoId): bool
|
||||
{
|
||||
$count = TvEpisode::query()
|
||||
->where('videos_id', $videoId)->count(['id']);
|
||||
@@ -423,12 +376,9 @@ abstract class TV extends Videos
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a release searchname for specific TV show data
|
||||
* Returns an array of show data.
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function parseInfo($relname)
|
||||
public function parseInfo(string $relname): bool|array
|
||||
{
|
||||
$showInfo['name'] = $this->parseName($relname);
|
||||
|
||||
@@ -464,11 +414,8 @@ abstract class TV extends Videos
|
||||
|
||||
/**
|
||||
* Parses the release searchname and returns a show title.
|
||||
*
|
||||
* @param string $relname
|
||||
* @return string
|
||||
*/
|
||||
private function parseName($relname)
|
||||
private function parseName(string $relname): string
|
||||
{
|
||||
$showName = '';
|
||||
|
||||
@@ -497,10 +444,8 @@ abstract class TV extends Videos
|
||||
|
||||
/**
|
||||
* Parses the release searchname for the season/episode/airdate information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseSeasonEp($relname)
|
||||
private function parseSeasonEp(string $relname): array
|
||||
{
|
||||
$episodeArr = [];
|
||||
|
||||
@@ -586,10 +531,8 @@ abstract class TV extends Videos
|
||||
|
||||
/**
|
||||
* Parses the cleaned release name to determine if it has a country appended.
|
||||
*
|
||||
* @param string $showName
|
||||
*/
|
||||
private function parseCountry($showName): string
|
||||
private function parseCountry(string $showName): string
|
||||
{
|
||||
// Country or origin matching.
|
||||
if (preg_match('/[^a-z0-9](US|UK|AU|NZ|CA|NL|Canada|Australia|America|United[^a-z0-9]States|United[^a-z0-9]Kingdom)/i', $showName, $countryMatch)) {
|
||||
@@ -617,7 +560,7 @@ abstract class TV extends Videos
|
||||
* Cleans a derived local 'showname' for better matching probability
|
||||
* Returns the cleaned string.
|
||||
*/
|
||||
public function cleanName($str): string
|
||||
public function cleanName(string $str): string
|
||||
{
|
||||
$str = str_replace(['.', '_'], ' ', $str);
|
||||
|
||||
@@ -643,10 +586,8 @@ abstract class TV extends Videos
|
||||
/**
|
||||
* Simple function that compares two strings of text
|
||||
* Returns percentage of similarity.
|
||||
*
|
||||
* @return int|float
|
||||
*/
|
||||
public function checkMatch($ourName, $scrapeName, $probability)
|
||||
public function checkMatch($ourName, $scrapeName, $probability): float|int
|
||||
{
|
||||
similar_text($ourName, $scrapeName, $matchpct);
|
||||
|
||||
@@ -664,10 +605,8 @@ abstract class TV extends Videos
|
||||
*
|
||||
* This shouldn't ever happen as I've never heard of a date starting with year being followed by day value.
|
||||
* Could this be a mistake? i.e. trying to solve the mm-dd-yyyy/dd-mm-yyyy confusion into a yyyy-mm-dd?
|
||||
*
|
||||
* @param string|bool|null $date
|
||||
*/
|
||||
public function checkDate($date): string
|
||||
public function checkDate(bool|string|null $date): string
|
||||
{
|
||||
if (! empty($date)) {
|
||||
$chk = explode(' ', $date);
|
||||
|
||||
@@ -207,19 +207,19 @@ class TVDB extends TV
|
||||
* @param string $country
|
||||
* @return array|bool
|
||||
*/
|
||||
protected function getShowInfo($cleanName, $country = ''): bool|array
|
||||
protected function getShowInfo(string $name): bool|array
|
||||
{
|
||||
$return = $response = false;
|
||||
$highestMatch = 0;
|
||||
try {
|
||||
$response = $this->client->search()->search($cleanName, ['type' => 'series']);
|
||||
$response = $this->client->search()->search($name, ['type' => 'series']);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$this->colorCli->climate()->error('Show not found on TVDB');
|
||||
}
|
||||
|
||||
if ($response === false && $country !== '') {
|
||||
try {
|
||||
$response = $this->client->search()->search(rtrim(str_replace($country, '', $cleanName)));
|
||||
$response = $this->client->search()->search(rtrim(str_replace($country, '', $name)));
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$response = false;
|
||||
$this->colorCli->climate()->error('Show not found on TVDB', true);
|
||||
@@ -232,13 +232,13 @@ class TVDB extends TV
|
||||
foreach ($response as $show) {
|
||||
if ($this->checkRequiredAttr($show, 'tvdbS')) {
|
||||
// Check for exact title match first and then terminate if found
|
||||
if (strtolower($show->name) === strtolower($cleanName)) {
|
||||
if (strtolower($show->name) === strtolower($name)) {
|
||||
$highest = $show;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check each show title for similarity and then find the highest similar value
|
||||
$matchPercent = $this->checkMatch(strtolower($show->name), strtolower($cleanName), self::MATCH_PROBABILITY);
|
||||
$matchPercent = $this->checkMatch(strtolower($show->name), strtolower($name), self::MATCH_PROBABILITY);
|
||||
|
||||
// If new match has a higher percentage, set as new matched title
|
||||
if ($matchPercent > $highestMatch) {
|
||||
@@ -249,7 +249,7 @@ class TVDB extends TV
|
||||
// Check for show aliases and try match those too
|
||||
if (! empty($show->aliases)) {
|
||||
foreach ($show->aliases as $key => $name) {
|
||||
$matchPercent = $this->checkMatch(strtolower($name), strtolower($cleanName), $matchPercent);
|
||||
$matchPercent = $this->checkMatch(strtolower($name), strtolower($name), $matchPercent);
|
||||
if ($matchPercent > $highestMatch) {
|
||||
$highestMatch = $matchPercent;
|
||||
$highest = $show;
|
||||
|
||||
@@ -213,27 +213,27 @@ class TVMaze extends TV
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
protected function getShowInfo(string $cleanName)
|
||||
protected function getShowInfo(string $name)
|
||||
{
|
||||
$return = $response = false;
|
||||
|
||||
// TVMaze does NOT like shows with the year in them even without the parentheses
|
||||
// Do this for the API Search only as a local lookup should require it
|
||||
$cleanName = preg_replace('# \((19|20)\d{2}\)$#', '', $cleanName);
|
||||
$name = preg_replace('# \((19|20)\d{2}\)$#', '', $name);
|
||||
|
||||
//Try for the best match with AKAs embedded
|
||||
$response = $this->client->singleSearchAkas($cleanName);
|
||||
$response = $this->client->singleSearchAkas($name);
|
||||
|
||||
sleep(1);
|
||||
|
||||
if (\is_array($response)) {
|
||||
$return = $this->matchShowInfo($response, $cleanName);
|
||||
$return = $this->matchShowInfo($response, $name);
|
||||
}
|
||||
if ($return === false) {
|
||||
//Try for the best match via full search (no AKAs can be returned but the search is better)
|
||||
$response = $this->client->search($cleanName);
|
||||
$response = $this->client->search($name);
|
||||
if (\is_array($response)) {
|
||||
$return = $this->matchShowInfo($response, $cleanName);
|
||||
$return = $this->matchShowInfo($response, $name);
|
||||
}
|
||||
}
|
||||
//If we didn't get any aliases do a direct alias lookup
|
||||
|
||||
@@ -65,7 +65,7 @@ class TraktTv extends TV
|
||||
* Main processing director function for scrapers
|
||||
* Calls work query function and initiates processing.
|
||||
*/
|
||||
public function processSite($groupID, $guidChar, $process, bool $local = false): void
|
||||
public function processSite($groupID, $guidChar, int $process, bool $local = false): void
|
||||
{
|
||||
$res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TRAKT);
|
||||
|
||||
@@ -193,11 +193,9 @@ class TraktTv extends TV
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve info of TV episode from site using its API.
|
||||
*
|
||||
* @return array|false False on failure, an array of information fields otherwise.
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getEpisodeInfo(int $siteId, int $series, int $episode)
|
||||
public function getEpisodeInfo(int $siteId, int $series, int $episode): array|bool
|
||||
{
|
||||
$return = false;
|
||||
|
||||
@@ -247,12 +245,11 @@ class TraktTv extends TV
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve info of TV programme from site using it's API.
|
||||
* @return array|false
|
||||
*
|
||||
* @param string|null|array $name Title of programme to look up. Usually a cleaned up version from releases table.
|
||||
* @return array|false False on failure, an array of information fields otherwise.
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getShowInfo($name)
|
||||
public function getShowInfo(string $name): array|bool
|
||||
{
|
||||
$return = $response = false;
|
||||
$highestMatch = 0;
|
||||
|
||||
@@ -81,9 +81,6 @@ class LoginController extends Controller
|
||||
}
|
||||
|
||||
if ($user !== null) {
|
||||
if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) {
|
||||
}
|
||||
|
||||
$rememberMe = $request->has('rememberme') && $request->input('rememberme') === 'on';
|
||||
|
||||
if (! $user->isVerified() || $user->isPendingVerification()) {
|
||||
@@ -118,7 +115,7 @@ class LoginController extends Controller
|
||||
return $this->showLoginForm();
|
||||
}
|
||||
|
||||
public function showLoginForm(): void
|
||||
public function showLoginForm()
|
||||
{
|
||||
$theme = Settings::settingValue('site.main.style');
|
||||
|
||||
@@ -127,14 +124,14 @@ class LoginController extends Controller
|
||||
$meta_description = 'Login';
|
||||
$content = app('smarty.view')->fetch($theme.'/login.tpl');
|
||||
app('smarty.view')->assign(compact('content', 'meta_title', 'meta_keywords', 'meta_description'));
|
||||
app('smarty.view')->display($theme.'/basepage.tpl');
|
||||
return app('smarty.view')->display($theme.'/basepage.tpl');
|
||||
}
|
||||
|
||||
public function logout(Request $request): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$this->guard()->logout();
|
||||
|
||||
$request->session()->flush();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->to('login')->with('message', 'You have been logged out successfully');
|
||||
|
||||
@@ -9,11 +9,11 @@ use Illuminate\Http\Request;
|
||||
class ContentController extends BasePageController
|
||||
{
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse|void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function show(Request $request): JsonResponse
|
||||
public function show(Request $request)
|
||||
{
|
||||
$this->setPreferences();
|
||||
$contents = new Contents();
|
||||
|
||||
@@ -14,12 +14,12 @@ class FailedReleasesController extends BasePageController
|
||||
public function failed(Request $request): \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Contracts\Foundation\Application|\Illuminate\Http\Response
|
||||
{
|
||||
if ($request->missing('api_token')) {
|
||||
return response('Bad request, please supply all parameters!', 400)->withHeaders(['X-DNZB-RCode' => , 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
|
||||
return response('Bad request, please supply all parameters!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
|
||||
}
|
||||
|
||||
$res = User::getByRssToken($request->input('api_token'));
|
||||
if ($res === null) {
|
||||
return response('Unauthorised, wrong rss key!', 401)->withHeaders(['X-DNZB-RCode' => , 'X-DNZB-RText' => 'Unauthorised, wrong rss key!']);
|
||||
return response('Unauthorised, wrong rss key!', 401)->withHeaders(['X-DNZB-RCode' => 401, 'X-DNZB-RText' => 'Unauthorised, wrong rss key!']);
|
||||
}
|
||||
|
||||
$uid = $res['id'];
|
||||
@@ -29,12 +29,12 @@ class FailedReleasesController extends BasePageController
|
||||
$alt = Release::getAlternate($request->input('guid'), $uid);
|
||||
|
||||
if (empty($alt)) {
|
||||
return response('No NZB found for alternate match!', 404)->withHeaders(['X-DNZB-RCode' => , 'X-DNZB-RText' => 'No NZB found for alternate match.']);
|
||||
return response('No NZB found for alternate match!', 404)->withHeaders(['X-DNZB-RCode' => 404, 'X-DNZB-RText' => 'No NZB found for alternate match.']);
|
||||
}
|
||||
|
||||
return response('Success')->withHeaders(['Location' => url('/').'/getnzb?id='.$alt['guid'].'&r='.$rssToken]);
|
||||
}
|
||||
|
||||
return response('Bad request, please supply all parameters!', 400)->withHeaders(['X-DNZB-RCode' => , 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
|
||||
return response('Bad request, please supply all parameters!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@ class LoginLoginRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'g-recaptcha-response' => [
|
||||
'required',
|
||||
'captcha',
|
||||
],
|
||||
];
|
||||
if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) {
|
||||
return [
|
||||
'g-recaptcha-response' => [
|
||||
'required',
|
||||
'captcha',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class Settings extends Model
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $key)
|
||||
public function __get($key)
|
||||
{
|
||||
$override = self::query()->where('name', $key)->first();
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used during authentication for various
|
||||
| messages that we need to display to the user. You are free to modify
|
||||
| these language lines according to your application's requirements.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pagination Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used by the paginator library to build
|
||||
| the simple pagination links. You are free to change them to anything
|
||||
| you want to customize your views to better match your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'previous' => '« Previous',
|
||||
'next' => 'Next »',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are the default lines which match reasons
|
||||
| that are given by the password broker for a password update attempt
|
||||
| has failed, such as for an invalid token or invalid new password.
|
||||
|
|
||||
*/
|
||||
|
||||
'password' => 'Passwords must be at least six characters and match the confirmation.',
|
||||
'reset' => 'Your password has been reset!',
|
||||
'sent' => 'We have e-mailed your password reset link!',
|
||||
'token' => 'This password reset token is invalid.',
|
||||
'user' => "We can't find a user with that e-mail address.",
|
||||
|
||||
];
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => 'The :attribute must be accepted.',
|
||||
'active_url' => 'The :attribute is not a valid URL.',
|
||||
'after' => 'The :attribute must be a date after :date.',
|
||||
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
|
||||
'alpha' => 'The :attribute may only contain letters.',
|
||||
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
|
||||
'alpha_num' => 'The :attribute may only contain letters and numbers.',
|
||||
'array' => 'The :attribute must be an array.',
|
||||
'before' => 'The :attribute must be a date before :date.',
|
||||
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
|
||||
'between' => [
|
||||
'numeric' => 'The :attribute must be between :min and :max.',
|
||||
'file' => 'The :attribute must be between :min and :max kilobytes.',
|
||||
'string' => 'The :attribute must be between :min and :max characters.',
|
||||
'array' => 'The :attribute must have between :min and :max items.',
|
||||
],
|
||||
'boolean' => 'The :attribute field must be true or false.',
|
||||
'confirmed' => 'The :attribute confirmation does not match.',
|
||||
'date' => 'The :attribute is not a valid date.',
|
||||
'date_format' => 'The :attribute does not match the format :format.',
|
||||
'different' => 'The :attribute and :other must be different.',
|
||||
'digits' => 'The :attribute must be :digits digits.',
|
||||
'digits_between' => 'The :attribute must be between :min and :max digits.',
|
||||
'dimensions' => 'The :attribute has invalid image dimensions.',
|
||||
'distinct' => 'The :attribute field has a duplicate value.',
|
||||
'email' => 'The :attribute must be a valid email address.',
|
||||
'exists' => 'The selected :attribute is invalid.',
|
||||
'file' => 'The :attribute must be a file.',
|
||||
'filled' => 'The :attribute field must have a value.',
|
||||
'image' => 'The :attribute must be an image.',
|
||||
'in' => 'The selected :attribute is invalid.',
|
||||
'in_array' => 'The :attribute field does not exist in :other.',
|
||||
'integer' => 'The :attribute must be an integer.',
|
||||
'ip' => 'The :attribute must be a valid IP address.',
|
||||
'ipv4' => 'The :attribute must be a valid IPv4 address.',
|
||||
'ipv6' => 'The :attribute must be a valid IPv6 address.',
|
||||
'json' => 'The :attribute must be a valid JSON string.',
|
||||
'max' => [
|
||||
'numeric' => 'The :attribute may not be greater than :max.',
|
||||
'file' => 'The :attribute may not be greater than :max kilobytes.',
|
||||
'string' => 'The :attribute may not be greater than :max characters.',
|
||||
'array' => 'The :attribute may not have more than :max items.',
|
||||
],
|
||||
'mimes' => 'The :attribute must be a file of type: :values.',
|
||||
'mimetypes' => 'The :attribute must be a file of type: :values.',
|
||||
'min' => [
|
||||
'numeric' => 'The :attribute must be at least :min.',
|
||||
'file' => 'The :attribute must be at least :min kilobytes.',
|
||||
'string' => 'The :attribute must be at least :min characters.',
|
||||
'array' => 'The :attribute must have at least :min items.',
|
||||
],
|
||||
'not_in' => 'The selected :attribute is invalid.',
|
||||
'numeric' => 'The :attribute must be a number.',
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'regex' => 'The :attribute format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
'required_with_all' => 'The :attribute field is required when :values is present.',
|
||||
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||
'same' => 'The :attribute and :other must match.',
|
||||
'size' => [
|
||||
'numeric' => 'The :attribute must be :size.',
|
||||
'file' => 'The :attribute must be :size kilobytes.',
|
||||
'string' => 'The :attribute must be :size characters.',
|
||||
'array' => 'The :attribute must contain :size items.',
|
||||
],
|
||||
'string' => 'The :attribute must be a string.',
|
||||
'timezone' => 'The :attribute must be a valid zone.',
|
||||
'unique' => 'The :attribute has already been taken.',
|
||||
'uploaded' => 'The :attribute failed to upload.',
|
||||
'url' => 'The :attribute format is invalid.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as E-Mail Address instead
|
||||
| of "email". This simply helps us make messages a little cleaner.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
|
||||
];
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
use App\Http\Controllers\RssController;
|
||||
|
||||
Route::middleware('auth:api')->group(['guard' => 'rss',], function () {
|
||||
Route::middleware(['auth:api', 'auth:rss'])->group(function () {
|
||||
Route::get('mymovies', [RssController::class, 'myMoviesRss']);
|
||||
Route::post('mymovies', [RssController::class, 'myMoviesRss']);
|
||||
Route::get('myshows', [RssController::class, 'myShowsRss']);
|
||||
|
||||
Reference in New Issue
Block a user