Skip to content

Commit

Permalink
Merge pull request #3784 from Roardom/api-votes
Browse files Browse the repository at this point in the history
(Add) Tmdb votes and count to api
  • Loading branch information
HDVinnie committed Apr 27, 2024
2 parents 1706578 + c4371a3 commit 5556655
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/Helpers/TorrentHelper.php
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

0 comments on commit 5556655

Please sign in to comment.