Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Add) Tmdb votes and count to api #3784

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion app/Helpers/TorrentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
use App\Achievements\UserMadeUpload;
use App\Bots\IRCAnnounceBot;
use App\Models\AutomaticTorrentFreeleech;
use App\Models\Movie;
use App\Models\PrivateMessage;
use App\Models\Scopes\ApprovedScope;
use App\Models\Torrent;
use App\Models\Tv;
use App\Models\User;
use App\Models\Wish;
use App\Notifications\NewUpload;
Expand Down Expand Up @@ -118,10 +120,27 @@ public static function approveHelper(int $id): void

// Announce To IRC
if (config('irc-bot.enabled')) {
$meta = null;
$category = $torrent->category;

if ($torrent->tmdb > 0) {
$meta = match (true) {
$category->tv_meta => Tv::find($torrent->tmdb),
$category->movie_meta => Movie::find($torrent->tmdb),
default => null,
};
}

(new IRCAnnounceBot())
->to(config('irc-bot.channel'))
->say('['.config('app.name').'] '.($anon ? 'An anonymous user' : $username).' has uploaded '.$torrent->name.' grab it now!')
->say('[Category: '.$torrent->category->name.'] [Type: '.$torrent->type->name.'] [Size: '.$torrent->getSize().']')
->say(
'[Category: '.$category->name.'] '
.'[Type: '.$torrent->type->name.'] '
.'[Size: '.$torrent->getSize().'] '
.'[TMDB vote average: '.($meta->vote_average ?? 0).'] '
.'[TMDB vote count: '.($meta->vote_count ?? 0).']'
)
->say(sprintf('[Link: %s/torrents/', $appurl).$id.']');
}

Expand Down
Loading