|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\DnzbFailure; |
|
6
|
|
|
use App\Models\Predb; |
|
7
|
|
|
use App\Models\Release; |
|
8
|
|
|
use App\Models\ReleaseComment; |
|
9
|
|
|
use App\Models\ReleaseFile; |
|
10
|
|
|
use App\Models\ReleaseNfo; |
|
11
|
|
|
use App\Models\ReleaseRegex; |
|
12
|
|
|
use App\Models\Settings; |
|
13
|
|
|
use App\Models\UserDownload; |
|
14
|
|
|
use App\Models\Video; |
|
15
|
|
|
use Blacklight\AniDB; |
|
16
|
|
|
use Blacklight\Books; |
|
17
|
|
|
use Blacklight\Console; |
|
18
|
|
|
use Blacklight\Games; |
|
19
|
|
|
use Blacklight\Movie; |
|
20
|
|
|
use Blacklight\Music; |
|
21
|
|
|
use Blacklight\ReleaseExtra; |
|
22
|
|
|
use Blacklight\Releases; |
|
23
|
|
|
use Blacklight\XXX; |
|
24
|
|
|
use Illuminate\Http\Request; |
|
25
|
|
|
|
|
26
|
|
|
class DetailsController extends BasePageController |
|
27
|
|
|
{ |
|
28
|
|
|
public function show(Request $request, string $guid) |
|
29
|
|
|
{ |
|
30
|
|
|
if ($guid !== null) { |
|
|
|
|
|
|
31
|
|
|
$releases = new Releases; |
|
32
|
|
|
$re = new ReleaseExtra; |
|
33
|
|
|
$data = Release::getByGuid($guid); |
|
34
|
|
|
$releaseRegex = ''; |
|
35
|
|
|
if (! empty($data)) { |
|
36
|
|
|
$releaseRegex = ReleaseRegex::query()->where('releases_id', '=', $data['id'])->first(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
if (! $data) { |
|
40
|
|
|
return redirect()->back(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if ($this->isPostBack($request)) { |
|
44
|
|
|
ReleaseComment::addComment($data['id'], $data['gid'], $request->input('txtAddComment'), $this->userdata->id, $request->ip()); |
|
45
|
|
|
|
|
46
|
|
|
return redirect()->route('details', ['guid' => $guid])->with('success', 'Comment posted successfully!'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$nfoData = ReleaseNfo::getReleaseNfo($data['id']); |
|
50
|
|
|
$nfo = $nfoData ? $nfoData->nfo : null; |
|
51
|
|
|
$reVideo = $re->getVideo($data['id']); |
|
52
|
|
|
$reAudio = $re->getAudio($data['id']); |
|
53
|
|
|
$reSubs = $re->getSubs($data['id']); |
|
54
|
|
|
$comments = ReleaseComment::getComments($data['id']); |
|
55
|
|
|
$similars = $releases->searchSimilar($data['id'], $data['searchname'], $this->userdata->categoryexclusions); |
|
56
|
|
|
$failed = DnzbFailure::getFailedCount($data['id']); |
|
57
|
|
|
$downloadedBy = UserDownload::query()->with('user')->where('releases_id', $data['id'])->get(['users_id']); |
|
58
|
|
|
|
|
59
|
|
|
$showInfo = ''; |
|
60
|
|
|
if ($data['videos_id'] > 0) { |
|
61
|
|
|
$showInfo = Video::getByVideoID($data['videos_id']); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$mov = ''; |
|
65
|
|
|
if ($data['imdbid'] !== '' && $data['imdbid'] !== 0000000) { |
|
66
|
|
|
$movie = new Movie(['Settings' => $this->settings]); |
|
|
|
|
|
|
67
|
|
|
$mov = $movie->getMovieInfo($data['imdbid']); |
|
68
|
|
|
if (! empty($mov['title'])) { |
|
69
|
|
|
$mov['title'] = str_replace(['/', '\\'], '', $mov['title']); |
|
70
|
|
|
$mov['actors'] = makeFieldLinks($mov, 'actors', 'movies'); |
|
71
|
|
|
$mov['genre'] = makeFieldLinks($mov, 'genre', 'movies'); |
|
72
|
|
|
$mov['director'] = makeFieldLinks($mov, 'director', 'movies'); |
|
73
|
|
|
if (Settings::settingValue('trailers_display')) { |
|
74
|
|
|
$trailer = empty($mov['trailer']) || $mov['trailer'] === '' ? $movie->getTrailer($data['imdbid']) : $mov['trailer']; |
|
75
|
|
|
if ($trailer) { |
|
76
|
|
|
$mov['trailer'] = sprintf('<iframe width="%d" height="%d" src="%s"></iframe>', Settings::settingValue('trailers_size_x'), Settings::settingValue('trailers_size_y'), $trailer); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$xxx = ''; |
|
83
|
|
|
if ($data['xxxinfo_id'] !== '' && $data['xxxinfo_id'] !== 0) { |
|
84
|
|
|
$x = new XXX; |
|
85
|
|
|
$xxx = $x->getXXXInfo($data['xxxinfo_id']); |
|
86
|
|
|
|
|
87
|
|
|
if (isset($xxx['trailers'])) { |
|
88
|
|
|
$xxx['trailers'] = $x->insertSwf($xxx['classused'], $xxx['trailers']); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
if ($xxx && isset($xxx['title'])) { |
|
92
|
|
|
$xxx['title'] = str_replace(['/', '\\'], '', $xxx['title']); |
|
93
|
|
|
$xxx['actors'] = makeFieldLinks($xxx, 'actors', 'xxx'); |
|
94
|
|
|
$xxx['genre'] = makeFieldLinks($xxx, 'genre', 'xxx'); |
|
95
|
|
|
$xxx['director'] = makeFieldLinks($xxx, 'director', 'xxx'); |
|
96
|
|
|
} else { |
|
97
|
|
|
$xxx = false; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
$game = ''; |
|
102
|
|
|
if ($data['gamesinfo_id'] !== '') { |
|
103
|
|
|
$game = (new Games)->getGamesInfoById($data['gamesinfo_id']); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$mus = ''; |
|
107
|
|
|
if ($data['musicinfo_id'] !== '') { |
|
108
|
|
|
$mus = (new Music)->getMusicInfo($data['musicinfo_id']); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$book = ''; |
|
112
|
|
|
if ($data['bookinfo_id'] !== '') { |
|
113
|
|
|
$book = (new Books)->getBookInfo($data['bookinfo_id']); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
$con = ''; |
|
117
|
|
|
if ($data['consoleinfo_id'] !== '') { |
|
118
|
|
|
$con = (new Console)->getConsoleInfo($data['consoleinfo_id']); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
$AniDBAPIArray = ''; |
|
122
|
|
|
if ($data['anidbid'] > 0) { |
|
123
|
|
|
$AniDBAPIArray = (new AniDB)->getAnimeInfo($data['anidbid']); |
|
124
|
|
|
|
|
125
|
|
|
// If we have anilist_id but missing details, fetch from AniList |
|
126
|
|
|
if ($AniDBAPIArray && !empty($AniDBAPIArray->anilist_id)) { |
|
127
|
|
|
$anilistId = is_object($AniDBAPIArray) ? $AniDBAPIArray->anilist_id : ($AniDBAPIArray['anilist_id'] ?? null); |
|
128
|
|
|
if ($anilistId && (empty($AniDBAPIArray->country) && empty($AniDBAPIArray->media_type))) { |
|
129
|
|
|
// Fetch fresh data from AniList if country/media_type is missing |
|
130
|
|
|
try { |
|
131
|
|
|
$palist = new \Blacklight\PopulateAniList; |
|
132
|
|
|
$palist->populateTable('info', $anilistId); |
|
133
|
|
|
// Refresh the data |
|
134
|
|
|
$AniDBAPIArray = (new AniDB)->getAnimeInfo($data['anidbid']); |
|
135
|
|
|
} catch (\Exception $e) { |
|
136
|
|
|
// Silently fail, use existing data |
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
$pre = Predb::getForRelease($data['predb_id']); |
|
143
|
|
|
|
|
144
|
|
|
$releasefiles = ReleaseFile::getReleaseFiles($data['id']); |
|
145
|
|
|
|
|
146
|
|
|
$this->viewData = array_merge($this->viewData, [ |
|
147
|
|
|
'releasefiles' => $releasefiles, |
|
148
|
|
|
'release' => $data, |
|
149
|
|
|
'reVideo' => $reVideo, |
|
150
|
|
|
'reAudio' => $reAudio, |
|
151
|
|
|
'reSubs' => $reSubs, |
|
152
|
|
|
'nfo' => $nfo, |
|
153
|
|
|
'show' => $showInfo, |
|
154
|
|
|
'movie' => $mov, |
|
155
|
|
|
'xxx' => $xxx, |
|
156
|
|
|
'anidb' => $AniDBAPIArray, |
|
157
|
|
|
'music' => $mus, |
|
158
|
|
|
'con' => $con, |
|
159
|
|
|
'game' => $game, |
|
160
|
|
|
'book' => $book, |
|
161
|
|
|
'predb' => $pre, |
|
162
|
|
|
'comments' => $comments, |
|
163
|
|
|
'files' => $releasefiles, |
|
164
|
|
|
'searchname' => getSimilarName($data['searchname']), |
|
165
|
|
|
'similars' => $similars !== false ? $similars : [], |
|
|
|
|
|
|
166
|
|
|
'privateprofiles' => config('nntmux_settings.private_profiles'), |
|
167
|
|
|
'failed' => $failed, |
|
168
|
|
|
'regex' => $releaseRegex, |
|
169
|
|
|
'downloadedby' => $downloadedBy, |
|
170
|
|
|
'meta_title' => 'View NZB', |
|
171
|
|
|
'meta_keywords' => 'view,nzb,description,details', |
|
172
|
|
|
'meta_description' => 'View NZB for '.$data['searchname'], |
|
173
|
|
|
]); |
|
174
|
|
|
|
|
175
|
|
|
return view('details.index', $this->viewData); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
return redirect()->back()->with('error', 'Release not found'); |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
|