@@ -5,7 +5,6 @@ |
||
5 | 5 | |
6 | 6 | // This script is simply so I can show sleep progress in bash script |
7 | 7 | $consoletools = new ConsoleTools(); |
8 | -if (isset($argv[1]) && is_numeric($argv[1])) |
|
9 | -{ |
|
8 | +if (isset($argv[1]) && is_numeric($argv[1])) { |
|
10 | 9 | $consoletools->showsleep($argv[1]); |
11 | 10 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | echo '.'; |
84 | 84 | } |
85 | 85 | |
86 | - $nntp->doQuit(); |
|
86 | + $nntp->doQuit(); |
|
87 | 87 | |
88 | 88 | } else if (isset($pieces[1]) && $pieces[0] == 'predbft') { |
89 | 89 | $pre = $pieces[1]; |
@@ -56,7 +56,7 @@ |
||
56 | 56 | } |
57 | 57 | $namefixer->checked++; |
58 | 58 | } |
59 | - }else if (isset($pieces[1]) && $pieces[0] == 'md5') { |
|
59 | + } else if (isset($pieces[1]) && $pieces[0] == 'md5') { |
|
60 | 60 | $release = $pieces[1]; |
61 | 61 | if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releases_id, r.name, r.searchname, r.categories_id, r.groups_id, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN release_files rf ON r.id = rf.releases_id WHERE r.id = %d', $release))) { |
62 | 62 | if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['name'], $matches)) { |
@@ -56,7 +56,7 @@ |
||
56 | 56 | } |
57 | 57 | $namefixer->checked++; |
58 | 58 | } |
59 | - }else if (isset($pieces[1]) && $pieces[0] == 'md5') { |
|
59 | + } else if (isset($pieces[1]) && $pieces[0] == 'md5') { |
|
60 | 60 | $release = $pieces[1]; |
61 | 61 | if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releases_id, r.name, r.searchname, r.categories_id, r.groups_id, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN release_files rf ON r.id = rf.releases_id WHERE r.id = %d', $release))) { |
62 | 62 | if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['name'], $matches)) { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | if (isset($pieces[6])) { |
23 | 23 | // Create the connection here and pass |
24 | 24 | $nntp = new NNTP(); |
25 | - if ($nntp->doConnect() === false) { |
|
25 | + if ($nntp->doConnect() === false) { |
|
26 | 26 | exit($c->error("Unable to connect to usenet.")); |
27 | 27 | } |
28 | 28 |
@@ -390,7 +390,7 @@ |
||
390 | 390 | exit; |
391 | 391 | } |
392 | 392 | |
393 | -function getTableRowCount(\PDOStatement &$ps, $table) |
|
393 | +function getTableRowCount(\PDOStatement & $ps, $table) |
|
394 | 394 | { |
395 | 395 | $success = $ps->execute([':table' => $table]); |
396 | 396 | if ($success) { |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $t = new \Tmux(); |
11 | 11 | $tmux = $t->get(); |
12 | 12 | $powerline = (isset($tmux->powerline)) ? $tmux->powerline : 0; |
13 | -$s= new Sites(); |
|
13 | +$s = new Sites(); |
|
14 | 14 | $site = $s->get(); |
15 | 15 | |
16 | 16 | $tmux_session = 'NNTPProxy'; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $nntpproxypy = $DIR . "update/nix/python/nntpproxy.py"; |
52 | 52 | if (file_exists($DIR . "update/nix/python/lib/nntpproxy.conf")) { |
53 | 53 | $nntpproxyconf = $DIR . "update/nix/python/lib/nntpproxy.conf"; |
54 | - shell_exec("cd ${DIR}/update/nix/tmux; tmux -f $tmuxconfig attach-session -t $tmux_session || tmux -f $tmuxconfig new-session -d -s $tmux_session -n NNTPProxy 'printf \"\033]2;\"NNTPProxy\"\033\" && python $nntpproxypy $nntpproxyconf'"); |
|
54 | + shell_exec("cd ${dir}/update/nix/tmux; tmux -f $tmuxconfig attach-session -t $tmux_session || tmux -f $tmuxconfig new-session -d -s $tmux_session -n NNTPProxy 'printf \"\033]2;\"NNTPProxy\"\033\" && python $nntpproxypy $nntpproxyconf'"); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
@@ -29,19 +29,24 @@ discard block |
||
29 | 29 | } else { |
30 | 30 | $util = new Utility(); |
31 | 31 | $path = (!$util->endsWith($argv[1], "/") ? $argv[1] . "/" : $argv[1]); |
32 | - if (isset($argv[2])) |
|
33 | - $usefilename = strtolower($argv[2]) == 'true'; |
|
34 | - if (isset($argv[3])) |
|
35 | - $dupecheck = strtolower($argv[3]) == 'true'; |
|
36 | - if (isset($argv[4])) |
|
37 | - $movefiles = strtolower($argv[4]) == 'true'; |
|
38 | - if (isset($argv[5]) && is_numeric($argv[5])) |
|
39 | - $categoryoverride = $argv[5]; |
|
40 | -} |
|
32 | + if (isset($argv[2])) { |
|
33 | + $usefilename = strtolower($argv[2]) == 'true'; |
|
34 | + } |
|
35 | + if (isset($argv[3])) { |
|
36 | + $dupecheck = strtolower($argv[3]) == 'true'; |
|
37 | + } |
|
38 | + if (isset($argv[4])) { |
|
39 | + $movefiles = strtolower($argv[4]) == 'true'; |
|
40 | + } |
|
41 | + if (isset($argv[5]) && is_numeric($argv[5])) { |
|
42 | + $categoryoverride = $argv[5]; |
|
43 | + } |
|
44 | + } |
|
41 | 45 | |
42 | 46 | $groups = $db->query("SELECT id, name FROM groups"); |
43 | -foreach ($groups as $group) |
|
47 | +foreach ($groups as $group) { |
|
44 | 48 | $siteGroups[$group["name"]] = $group["id"]; |
49 | +} |
|
45 | 50 | |
46 | 51 | echo "\nUsage: php import.php [path(string)] [usefilename(true/false)] [dupecheck(true/false)] [movefiles(true/false)] [overridecategory(number)]\n"; |
47 | 52 | |
@@ -66,8 +71,12 @@ discard block |
||
66 | 71 | if (!$nzbInfo->loadFromFile($nzbFile, true)) { |
67 | 72 | echo "Failed to load nzb from disk " . $nzbFile . "\n"; |
68 | 73 | if ($movefiles) { |
69 | - if (!file_exists($errorpath)) mkdir($errorpath); |
|
70 | - if (!file_exists($errorpath . basename($nzbFile))) rename($nzbFile, $errorpath . basename($nzbFile)); |
|
74 | + if (!file_exists($errorpath)) { |
|
75 | + mkdir($errorpath); |
|
76 | + } |
|
77 | + if (!file_exists($errorpath . basename($nzbFile))) { |
|
78 | + rename($nzbFile, $errorpath . basename($nzbFile)); |
|
79 | + } |
|
71 | 80 | } |
72 | 81 | } else { |
73 | 82 | if ($dupecheck) { |
@@ -75,8 +84,12 @@ discard block |
||
75 | 84 | if ($dupes['total'] > 0) { |
76 | 85 | echo sprintf("%0" . $digits . "d %.2f%% Error : Dupe %s - GID(%s)\n", $items - $num, $num / $items * 100, $nzbFile, $nzbInfo->gid); |
77 | 86 | if ($movefiles) { |
78 | - if (!file_exists($dupepath)) mkdir($dupepath); |
|
79 | - if (!file_exists($dupepath . basename($nzbFile))) rename($nzbFile, $dupepath . basename($nzbFile)); |
|
87 | + if (!file_exists($dupepath)) { |
|
88 | + mkdir($dupepath); |
|
89 | + } |
|
90 | + if (!file_exists($dupepath . basename($nzbFile))) { |
|
91 | + rename($nzbFile, $dupepath . basename($nzbFile)); |
|
92 | + } |
|
80 | 93 | } |
81 | 94 | continue; |
82 | 95 | } |
@@ -94,8 +107,12 @@ discard block |
||
94 | 107 | if ($groupID == -1) { |
95 | 108 | echo sprintf("%0" . $digits . "d %.2f%% Error : Missing group %s - Group(%s)\n", $items - $num, $num / $items * 100, $nzbFile, str_replace("alt.binaries.", "a.b.", implode(",", $nzbInfo->groups))); |
96 | 109 | if ($movefiles) { |
97 | - if (!file_exists($nogrouppath)) mkdir($nogrouppath); |
|
98 | - if (!file_exists($nogrouppath . basename($nzbFile))) rename($nzbFile, $nogrouppath . basename($nzbFile)); |
|
110 | + if (!file_exists($nogrouppath)) { |
|
111 | + mkdir($nogrouppath); |
|
112 | + } |
|
113 | + if (!file_exists($nogrouppath . basename($nzbFile))) { |
|
114 | + rename($nzbFile, $nogrouppath . basename($nzbFile)); |
|
115 | + } |
|
99 | 116 | $missinggroups = array_merge($missinggroups, $nzbInfo->groups); |
100 | 117 | } |
101 | 118 | continue; |
@@ -114,14 +131,22 @@ discard block |
||
114 | 131 | gzclose($fp); |
115 | 132 | echo sprintf("%0" . $digits . "d %.2f%% Imported %s\n", $items - $num, $num / $items * 100, $name); |
116 | 133 | if ($movefiles) { |
117 | - if (!file_exists($importedpath)) mkdir($importedpath); |
|
118 | - if (!file_exists($importedpath . basename($nzbFile))) rename($nzbFile, $importedpath . basename($nzbFile)); |
|
134 | + if (!file_exists($importedpath)) { |
|
135 | + mkdir($importedpath); |
|
136 | + } |
|
137 | + if (!file_exists($importedpath . basename($nzbFile))) { |
|
138 | + rename($nzbFile, $importedpath . basename($nzbFile)); |
|
139 | + } |
|
119 | 140 | } |
120 | 141 | } else { |
121 | 142 | echo sprintf("%0" . $digits . "d %.2f%% Error : Failed to write file to disk %s\n", $items - $num, $num / $items * 100, $nzbfilename); |
122 | 143 | if ($movefiles) { |
123 | - if (!file_exists($errorpath)) mkdir($errorpath); |
|
124 | - if (!file_exists($errorpath . basename($nzbFile))) rename($nzbFile, $errorpath . basename($nzbFile)); |
|
144 | + if (!file_exists($errorpath)) { |
|
145 | + mkdir($errorpath); |
|
146 | + } |
|
147 | + if (!file_exists($errorpath . basename($nzbFile))) { |
|
148 | + rename($nzbFile, $errorpath . basename($nzbFile)); |
|
149 | + } |
|
125 | 150 | } |
126 | 151 | $releases->deleteSingle(['g' => $relguid, 'i' => $relid], $nzb, $releaseImage); |
127 | 152 | } |
@@ -173,14 +198,22 @@ discard block |
||
173 | 198 | if ($binaryId != 0) { |
174 | 199 | echo sprintf("%0" . $digits . "d %.2f%% Imported %s (%d:%s-%d/%d)\n", $items - $num, $num / $items * 100, basename($nzbFile), $regexMatches['regcatid'], $regexMatches['regexid'], $numbins, $numparts); |
175 | 200 | if ($movefiles) { |
176 | - if (!file_exists($importedpath)) mkdir($importedpath); |
|
177 | - if (!file_exists($importedpath . basename($nzbFile))) rename($nzbFile, $importedpath . basename($nzbFile)); |
|
201 | + if (!file_exists($importedpath)) { |
|
202 | + mkdir($importedpath); |
|
203 | + } |
|
204 | + if (!file_exists($importedpath . basename($nzbFile))) { |
|
205 | + rename($nzbFile, $importedpath . basename($nzbFile)); |
|
206 | + } |
|
178 | 207 | } |
179 | 208 | } else { |
180 | 209 | echo sprintf("%0" . $digits . "d %.2f%% Error : No Regex Match %s\n", $items - $num, $num / $items * 100, basename($nzbFile)); |
181 | 210 | if ($movefiles) { |
182 | - if (!file_exists($noregexpath)) mkdir($noregexpath); |
|
183 | - if (!file_exists($noregexpath . basename($nzbFile))) rename($nzbFile, $noregexpath . basename($nzbFile)); |
|
211 | + if (!file_exists($noregexpath)) { |
|
212 | + mkdir($noregexpath); |
|
213 | + } |
|
214 | + if (!file_exists($noregexpath . basename($nzbFile))) { |
|
215 | + rename($nzbFile, $noregexpath . basename($nzbFile)); |
|
216 | + } |
|
184 | 217 | } |
185 | 218 | } |
186 | 219 | } |
@@ -192,8 +225,9 @@ discard block |
||
192 | 225 | $missinggroups = array_unique($missinggroups); |
193 | 226 | $grpsql = "INSERT INTO groups (name, backfill_target, first_record, first_record_postdate, last_record, last_record_postdate, last_updated, minfilestoformrelease, minsizetoformrelease, active, regexmatchonly, description) VALUES ('%s', 0, 0, null, 0, null, null, null, null, 0, 1, 'Added by import');\n"; |
194 | 227 | $grpout = ""; |
195 | - foreach ($missinggroups as $mg) |
|
196 | - $grpout .= sprintf($grpsql, $mg); |
|
228 | + foreach ($missinggroups as $mg) { |
|
229 | + $grpout .= sprintf($grpsql, $mg); |
|
230 | + } |
|
197 | 231 | |
198 | 232 | @file_put_contents(sprintf("missing_groups_%s.sql", uniqid()), $grpout); |
199 | 233 | } |
@@ -26,15 +26,15 @@ |
||
26 | 26 | $time = 0; |
27 | 27 | |
28 | 28 | if (isset($argv[1])) |
29 | - $time = strtotime($argv[1]); |
|
29 | + $time = strtotime($argv[1]); |
|
30 | 30 | |
31 | 31 | if (($time > 1) && ($time < time())) { |
32 | - $groupName = (isset($argv[2]) ? $argv[2] : ''); |
|
32 | + $groupName = (isset($argv[2]) ? $argv[2] : ''); |
|
33 | 33 | |
34 | - if (isset($argv[3]) && $argv[3] == true) |
|
35 | - $regexOnly = true; |
|
36 | - else |
|
37 | - $regexOnly = false; |
|
34 | + if (isset($argv[3]) && $argv[3] == true) |
|
35 | + $regexOnly = true; |
|
36 | + else |
|
37 | + $regexOnly = false; |
|
38 | 38 | |
39 | 39 | $backfill = new Backfill(); |
40 | 40 | $backfill->backfillAllGroups($groupName, strtotime($argv[1]), $regexOnly); |
@@ -25,16 +25,18 @@ |
||
25 | 25 | |
26 | 26 | $time = 0; |
27 | 27 | |
28 | -if (isset($argv[1])) |
|
28 | +if (isset($argv[1])) { |
|
29 | 29 | $time = strtotime($argv[1]); |
30 | +} |
|
30 | 31 | |
31 | 32 | if (($time > 1) && ($time < time())) { |
32 | 33 | $groupName = (isset($argv[2]) ? $argv[2] : ''); |
33 | 34 | |
34 | - if (isset($argv[3]) && $argv[3] == true) |
|
35 | - $regexOnly = true; |
|
36 | - else |
|
37 | - $regexOnly = false; |
|
35 | + if (isset($argv[3]) && $argv[3] == true) { |
|
36 | + $regexOnly = true; |
|
37 | + } else { |
|
38 | + $regexOnly = false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | $backfill = new Backfill(); |
40 | 42 | $backfill->backfillAllGroups($groupName, strtotime($argv[1]), $regexOnly); |
@@ -71,7 +71,7 @@ |
||
71 | 71 | |
72 | 72 | $postProcess = new PostProcess(['Settings' => $pdo, 'Echo' => ($argv[2] === 'true' ? true : false)]); |
73 | 73 | |
74 | -$charArray = ['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9']; |
|
74 | +$charArray = ['a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; |
|
75 | 75 | |
76 | 76 | switch ($argv[1]) { |
77 | 77 |
@@ -32,13 +32,13 @@ |
||
32 | 32 | |
33 | 33 | if (count($movies) == 0) |
34 | 34 | { |
35 | - echo "No records selected to update - either uncomment case or no matches found.\n"; |
|
36 | - die(); |
|
35 | + echo "No records selected to update - either uncomment case or no matches found.\n"; |
|
36 | + die(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | echo "Updating ".count($movies)." records - Sleep interval ".$sleepsecsbetweenscrape." second(s)\n"; |
40 | 40 | foreach ($movies as $mov) { |
41 | - echo "Updating ".$mov['imdbid']." (".$counter++."/".count($movies).")\n"; |
|
41 | + echo "Updating ".$mov['imdbid']." (".$counter++."/".count($movies).")\n"; |
|
42 | 42 | $mov = $movie->updateMovieInfo($mov['imdbid']); |
43 | 43 | sleep($sleepsecsbetweenscrape); |
44 | 44 | } |
@@ -36,9 +36,9 @@ |
||
36 | 36 | die(); |
37 | 37 | } |
38 | 38 | |
39 | -echo "Updating ".count($movies)." records - Sleep interval ".$sleepsecsbetweenscrape." second(s)\n"; |
|
39 | +echo "Updating " . count($movies) . " records - Sleep interval " . $sleepsecsbetweenscrape . " second(s)\n"; |
|
40 | 40 | foreach ($movies as $mov) { |
41 | - echo "Updating ".$mov['imdbid']." (".$counter++."/".count($movies).")\n"; |
|
41 | + echo "Updating " . $mov['imdbid'] . " (" . $counter++ . "/" . count($movies) . ")\n"; |
|
42 | 42 | $mov = $movie->updateMovieInfo($mov['imdbid']); |
43 | 43 | sleep($sleepsecsbetweenscrape); |
44 | 44 | } |
@@ -30,8 +30,7 @@ |
||
30 | 30 | //$movies = $db->query("SELECT imdbid from movieinfo where trailer is null and tmdbid is not null"); |
31 | 31 | |
32 | 32 | |
33 | -if (count($movies) == 0) |
|
34 | -{ |
|
33 | +if (count($movies) == 0) { |
|
35 | 34 | echo "No records selected to update - either uncomment case or no matches found.\n"; |
36 | 35 | die(); |
37 | 36 | } |