Move files around.

This commit is contained in:
Darko
2015-05-28 12:36:00 +02:00
parent a5ea73deec
commit ae0434ac11
1403 changed files with 13 additions and 18 deletions
@@ -0,0 +1,34 @@
<?php
//This script will update all records in the consoleinfo table
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$console = new \Konsole(['Echo' => true, 'Settings' => $pdo]);
$res = $pdo->queryDirect(sprintf("SELECT searchname, id FROM releases WHERE consoleinfoid IS NULL AND categoryid BETWEEN 1000 AND 1999 ORDER BY id DESC" ));
if ($res instanceof \Traversable) {
echo $pdo->log->header("Updating console info for " . number_format($res->rowCount()) . " releases.");
foreach ($res as $arr) {
$starttime = microtime(true);
$gameInfo = $console->parseTitle($arr['searchname']);
if ($gameInfo !== false) {
$game = $console->updateConsoleInfo($gameInfo);
if ($game === false) {
echo $pdo->log->primary($gameInfo['release'] . ' not found');
}
}
// amazon limits are 1 per 1 sec
$diff = floor((microtime(true) - $starttime) * 1000000);
if (1000000 - $diff > 0) {
echo $pdo->log->alternate("Sleeping");
usleep(1000000 - $diff);
}
}
}
@@ -0,0 +1,41 @@
<?php
//This script will update all records in the gamesinfo table
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$game = new \Games(['Echo' => true, 'Settings' => $pdo]);
$res = $pdo->query(
sprintf("SELECT id, title FROM gamesinfo WHERE cover = 0 ORDER BY id DESC LIMIT 100")
);
$total = count($res);
if ($total > 0) {
echo $pdo->log->header("Updating game covers for " . number_format($total) . " releases.");
foreach ($res as $arr) {
$starttime = microtime(true);
$gameInfo = $game->parseTitle($arr['title']);
if ($gameInfo !== false) {
echo $pdo->log->primary('Looking up: ' . $gameInfo['release']);
$gameData = $game->updateGamesInfo($gameInfo);
if ($gameData === false) {
echo $pdo->log->primary($gameInfo['release'] . ' not found');
} else {
if (file_exists(NN_COVERS . 'games' . DS . $gameData . '.jpg')) {
$pdo->queryExec(sprintf('UPDATE gamesinfo SET cover = 1 WHERE id = %d', $arr['id']));
}
}
}
// amazon limits are 1 per 1 sec
$diff = floor((microtime(true) - $starttime) * 1000000);
if (1000000 - $diff > 0) {
echo $pdo->log->alternate("Sleeping");
usleep(1000000 - $diff);
}
}
}
@@ -0,0 +1,28 @@
<?php
//This script will update all records in the movieinfo table
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$c = new \ColorCLI();
$movie = new \Film(['Echo' => true, 'Settings' => $pdo]);
$movies = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE tmdbid IS NULL ORDER BY id ASC");
if ($movies instanceof \Traversable) {
echo $pdo->log->header("Updating movie info for " . number_format($movies->rowCount()) . " movies.");
foreach ($movies as $mov) {
$starttime = microtime(true);
$mov = $movie->updateMovieInfo($mov['imdbid']);
// tmdb limits are 30 per 10 sec, not certain for imdb
$diff = floor((microtime(true) - $starttime) * 1000000);
if (333333 - $diff > 0) {
echo "sleeping\n";
usleep(333333 - $diff);
}
}
echo "\n";
}
@@ -0,0 +1,26 @@
<?php
//This script will update all records in the movieinfo table where there is no cover
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$movie = new \Film(array('Echo' => true, 'Settings' => $pdo));
$movies = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE cover = 0 ORDER BY year ASC, id DESC");
if ($movies instanceof \Traversable) {
echo $pdo->log->primary("Updating " . number_format($movies->rowCount()) . " movie covers.");
foreach ($movies as $mov) {
$starttime = microtime(true);
$mov = $movie->updateMovieInfo($mov['imdbid']);
// tmdb limits are 30 per 10 sec, not certain for imdb
$diff = floor((microtime(true) - $starttime) * 1000000);
if (333333 - $diff > 0) {
echo "\nsleeping\n";
usleep(333333 - $diff);
}
}
echo "\n";
}
@@ -0,0 +1,27 @@
<?php
//This script will update all records in the xxxinfo table where there is no cover
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$movie = new XXX();
$c = new ColorCLI();
$movies = $pdo->queryDirect("SELECT title FROM xxxinfo WHERE cover = 0");
if ($movies instanceof Traversable) {
echo $c->primary("Updating " . number_format($movies->rowCount()) . " XXX movie covers.");
foreach ($movies as $mov) {
$starttime = microtime(true);
$mov = $movie->updateXXXInfo($mov['title']);
// sleep so that it's not ddos' the site
$diff = floor((microtime(true) - $starttime) * 1000000);
if (333333 - $diff > 0) {
echo "\nsleeping\n";
usleep(333333 - $diff);
}
}
echo "\n";
}
@@ -0,0 +1,44 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
if (!isset($argv[1]) || $argv[1] != 'true') {
exit($pdo->log->error("\nThis script will download all tvrage shows and insert into the db.\n\n"
. "php $argv[0] true ...: To run.\n"));
}
$newnames = $updated = 0;
echo "Attempting to fetch data file from TVRage...\n";
$tvshows = @simplexml_load_file('http://services.tvrage.com/feeds/show_list.php');
if ($tvshows !== false) {
echo "Starting to process file entries...\n";
foreach ($tvshows->show as $rage) {
echo "RageID: " . $rage->id . ", name: " . $rage->name . " - ";
$dupecheck = $pdo->queryOneRow(sprintf('SELECT COUNT(id) AS count FROM tvrage WHERE id = %s', $pdo->escapeString($rage->id)));
if (isset($rage->id) && isset($rage->name) && !empty($rage->id) && !empty($rage->name) &&
$dupecheck !== false && $dupecheck['count'] == 0) {
$pdo->queryInsert(sprintf('INSERT INTO tvrage (rageid, releasetitle, country) VALUES (%s, %s, %s)', $pdo->escapeString($rage->id), $pdo->escapeString($rage->name), $pdo->escapeString($rage->country)));
$updated++;
echo "added\n";
} elseif (isset($rage->id) && isset($rage->name) && !empty($rage->id) && !empty($rage->name) &&
$dupecheck !== false && $dupecheck['count'] > 0) {
echo "Up to date\n";
} else {
echo "FAILED\n";
}
}
} else {
exit($pdo->log->info("TVRage site has a hard limit of 400 concurrent API requests. At the moment, they have reached that limit. Please wait before retrying\n"));
}
if ($updated != 0) {
echo $pdo->log->info("Inserted " . $updated . " new shows into the TvRage table. To fill out the newly populated TvRage table\n"
. "php misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateTvRage.php\n");
} else {
echo "\n";
echo $pdo->log->info("TvRage database is already up to date!\n");
}
@@ -0,0 +1,47 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$covers = $updated = $deleted = 0;
if ($argc == 1 || $argv[1] != 'true') {
exit($pdo->log->error("\nThis script will check all images in covers/book and compare to db->bookinfo.\nTo run:\nphp $argv[0] true\n"));
}
$path2covers = NN_COVERS . 'book' . DS;
$dirItr = new \RecursiveDirectoryIterator($path2covers);
$itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
if (is_file($filePath) && preg_match('/\d+\.jpg/', $filePath)) {
preg_match('/(\d+)\.jpg/', basename($filePath), $match);
if (isset($match[1])) {
$run = $pdo->queryDirect("UPDATE bookinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
if ($run->rowCount() >= 1) {
$covers++;
} else {
$run = $pdo->queryDirect("SELECT id FROM bookinfo WHERE id = " . $match[1]);
if ($run->rowCount() == 0) {
echo $pdo->log->info($filePath . " not found in db.");
}
}
}
}
}
$qry = $pdo->queryDirect("SELECT id FROM bookinfo WHERE cover = 1");
if ($qry instanceof \Traversable) {
foreach ($qry as $rows) {
if (!is_file($path2covers . $rows['id'] . '.jpg')) {
$pdo->queryDirect("UPDATE bookinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
echo $pdo->log->info($path2covers . $rows['id'] . ".jpg does not exist.");
$deleted++;
}
}
}
echo $pdo->log->header($covers . " covers set.");
echo $pdo->log->header($deleted . " books unset.");
@@ -0,0 +1,47 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$covers = $updated = $deleted = 0;
if ($argc == 1 || $argv[1] != 'true') {
exit($pdo->log->error("\nThis script will check all images in covers/console and compare to db->consoleinfo.\nTo run:\nphp $argv[0] true\n"));
}
$path2covers = NN_COVERS . 'console' . DS;
$dirItr = new \RecursiveDirectoryIterator($path2covers);
$itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
if (is_file($filePath) && preg_match('/\d+\.jpg/', $filePath)) {
preg_match('/(\d+)\.jpg/', basename($filePath), $match);
if (isset($match[1])) {
$run = $pdo->queryDirect("UPDATE consoleinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
if ($run->rowCount() >= 1) {
$covers++;
} else {
$run = $pdo->queryDirect("SELECT id FROM consoleinfo WHERE id = " . $match[1]);
if ($run->rowCount() == 0) {
echo $pdo->log->info($filePath . " not found in db.");
}
}
}
}
}
$qry = $pdo->queryDirect("SELECT id FROM consoleinfo WHERE cover = 1");
if ($qry instanceof \Traversable) {
foreach ($qry as $rows) {
if (!is_file($path2covers . $rows['id'] . '.jpg')) {
$pdo->queryDirect("UPDATE consoleinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
echo $pdo->log->info($path2covers . $rows['id'] . ".jpg does not exist.");
$deleted++;
}
}
}
echo $pdo->log->header($covers . " covers set.");
echo $pdo->log->header($deleted . " consoles unset.");
@@ -0,0 +1,45 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$covers = $updated = $deleted = 0;
$c = new ColorCLI();
if ($argc == 1 || $argv[1] != 'true') {
exit($c->error("\nThis script will check all images in covers/games and compare to db->gamesinfo.\nTo run:\nphp $argv[0] true\n"));
}
$path2covers = NN_COVERS . 'games' . DS;
$dirItr = new RecursiveDirectoryIterator($path2covers);
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
if (is_file($filePath) && preg_match('/\d+\.jpg/', $filePath)) {
preg_match('/(\d+)\.jpg/', basename($filePath), $match);
if (isset($match[1])) {
$run = $pdo->queryDirect("UPDATE gamesinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
if ($run !== false) {
if ($run->rowCount() >= 1) {
$covers++;
} else {
$run = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE id = " . $match[1]);
if ($run !== false && $run->rowCount() == 0) {
echo $c->info($filePath . " not found in db.");
}
}
}
}
}
}
$qry = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE cover = 1");
foreach ($qry as $rows) {
if (!is_file($path2covers . $rows['id'] . '.jpg')) {
$pdo->queryDirect("UPDATE gamesinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
echo $c->info($path2covers . $rows['id'] . ".jpg does not exist.");
$deleted++;
}
}
echo $c->header($covers . " covers set.");
echo $c->header($deleted . " games unset.");
@@ -0,0 +1,72 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$covers = $updated = $deleted = 0;
if ($argc == 1 || $argv[1] != 'true') {
exit($pdo->log->error("\nThis script will check all images in covers/movies and compare to db->movieinfo.\nTo run:\nphp $argv[0] true\n"));
}
$path2covers = NN_COVERS . 'movies' . DS;
$dirItr = new \RecursiveDirectoryIterator($path2covers);
$itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
if (is_file($filePath) && preg_match('/-cover\.jpg/', $filePath)) {
preg_match('/(\d+)-cover\.jpg/', basename($filePath), $match);
if (isset($match[1])) {
$run = $pdo->queryDirect("UPDATE movieinfo SET cover = 1 WHERE cover = 0 AND imdbid = " . $match[1]);
if ($run->rowCount() >= 1) {
$covers++;
} else {
$run = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE imdbid = " . $match[1]);
if ($run->rowCount() == 0) {
echo $pdo->log->info($filePath . " not found in db.");
}
}
}
}
if (is_file($filePath) && preg_match('/-backdrop\.jpg/', $filePath)) {
preg_match('/(\d+)-backdrop\.jpg/', basename($filePath), $match1);
if (isset($match1[1])) {
$run = $pdo->queryDirect("UPDATE movieinfo SET backdrop = 1 WHERE backdrop = 0 AND imdbid = " . $match1[1]);
if ($run->rowCount() >= 1) {
$updated++;
printf("UPDATE movieinfo SET backdrop = 1 WHERE backdrop = 0 AND imdbid = " . $match1[1] . "\n");
} else {
$run = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE imdbid = " . $match1[1]);
if ($run->rowCount() == 0) {
echo $pdo->log->info($filePath . " not found in db.");
}
}
}
}
}
$qry = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE cover = 1");
if ($qry instanceof \Traversable) {
foreach ($qry as $rows) {
if (!is_file($path2covers . $rows['imdbid'] . '-cover.jpg')) {
$pdo->queryDirect("UPDATE movieinfo SET cover = 0 WHERE cover = 1 AND imdbid = " . $rows['imdbid']);
echo $pdo->log->info($path2covers . $rows['imdbid'] . "-cover.jpg does not exist.");
$deleted++;
}
}
}
$qry1 = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE backdrop = 1");
if ($qry1 instanceof \Traversable) {
foreach ($qry1 as $rows) {
if (!is_file($path2covers . $rows['imdbid'] . '-backdrop.jpg')) {
$pdo->queryDirect("UPDATE movieinfo SET backdrop = 0 WHERE backdrop = 1 AND imdbid = " . $rows['imdbid']);
echo $pdo->log->info($path2covers . $rows['imdbid'] . "-backdrop.jpg does not exist.");
$deleted++;
}
}
}
echo $pdo->log->header($covers . " covers set.");
echo $pdo->log->header($updated . " backdrops set.");
echo $pdo->log->header($deleted . " movies unset.");
@@ -0,0 +1,46 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$covers = $updated = $deleted = 0;
if ($argc == 1 || $argv[1] != 'true') {
exit($pdo->log->error("\nThis script will check all images in covers/music and compare to db->musicinfo.\nTo run:\nphp $argv[0] true\n"));
}
$path2covers = NN_COVERS . 'music' . DS;
$dirItr = new \RecursiveDirectoryIterator($path2covers);
$itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
if (is_file($filePath) && preg_match('/\d+\.jpg/', $filePath)) {
preg_match('/(\d+)\.jpg/', basename($filePath), $match);
if (isset($match[1])) {
$run = $pdo->queryDirect("UPDATE musicinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
if ($run->rowCount() >= 1) {
$covers++;
} else {
$run = $pdo->queryDirect("SELECT id FROM musicinfo WHERE id = " . $match[1]);
if ($run->rowCount() == 0) {
echo $pdo->log->info($filePath . " not found in db.");
}
}
}
}
}
$qry = $pdo->queryDirect("SELECT id FROM musicinfo WHERE cover = 1");
if ($qry instanceof \Traversable) {
foreach ($qry as $rows) {
if (!is_file($path2covers . $rows['id'] . '.jpg')) {
$pdo->queryDirect("UPDATE musicinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
echo $pdo->log->info($path2covers . $rows['id'] . ".jpg does not exist.");
$deleted++;
}
}
}
echo $pdo->log->header($covers . " covers set.");
echo $pdo->log->header($deleted . " music unset.");
@@ -0,0 +1,65 @@
<?php
//This script downloads covert art for Tv Shows -- it is intended to be run at interval, generally after the TvRage database is populated
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
use newznab\utility\Utility;
$pdo = new DB();
$tvrage = new \TvAnger(['Settings' => $pdo, 'Echo' => true]);
$shows = $pdo->queryDirect("SELECT rageid FROM tvrage WHERE imgdata IS NULL ORDER BY rageid DESC LIMIT 2000");
if ($shows->rowCount() > 0) {
echo "\n";
echo $pdo->log->header("Updating " . number_format($shows->rowCount()) . " tv shows.\n");
} else {
echo "\n";
echo $pdo->log->info("All shows in TvRage database have been updated.\n");
usleep(5000000);
}
$loop = 0;
if ($shows instanceof \Traversable) {
foreach ($shows as $show) {
$starttime = microtime(true);
$rageid = $show['rageid'];
$tvrShow = $tvrage->getRageInfoFromService($rageid);
$genre = '';
if (isset($tvrShow['genres']) && is_array($tvrShow['genres']) && !empty($tvrShow['genres'])) {
if (is_array($tvrShow['genres']['genre'])) {
$genre = @implode('|', $tvrShow['genres']['genre']);
} else {
$genre = $tvrShow['genres']['genre'];
}
}
$country = '';
if (isset($tvrShow['country']) && !empty($tvrShow['country'])) {
$country = $tvrage->countryCode($tvrShow['country']);
}
$rInfo = $tvrage->getRageInfoFromPage($rageid);
$desc = '';
if (isset($rInfo['desc']) && !empty($rInfo['desc'])) {
$desc = $rInfo['desc'];
}
$imgbytes = '';
if (isset($rInfo['imgurl']) && !empty($rInfo['imgurl'])) {
$img =Utility::getUrl(['url' => $rInfo['imgurl']]);
if ($img !== false) {
$im = @imagecreatefromstring($img);
if ($im !== false) {
$imgbytes = $img;
}
}
}
$pdo->queryDirect(sprintf("UPDATE tvrage SET description = %s, genre = %s, country = %s, imgdata = %s WHERE rageid = %d", $pdo->escapeString(substr($desc, 0, 10000)), $pdo->escapeString(substr($genre, 0, 64)), $pdo->escapeString($country), $pdo->escapeString($imgbytes), $rageid));
$name = $pdo->query("Select releasetitle from tvrage where rageid = " . $rageid);
echo $pdo->log->primary("Updated: " . $name[0]['releasetitle']);
$diff = floor((microtime(true) - $starttime) * 1000000);
if (1000000 - $diff > 0) {
echo $pdo->log->alternate("Sleeping");
usleep(1000000 - $diff);
}
}
}
@@ -0,0 +1,73 @@
<?php
require_once(dirname(__FILE__) . "/../../../bin/config.php");
use newznab\db\DB;
$pdo = new DB();
$c = new ColorCLI();
$covers = $updated = $deleted = 0;
if ($argc == 1 || $argv[1] != 'true') {
exit($c->error("\nThis script will check all images in covers/xxx and compare to db->xxxinfo.\nTo run:\nphp $argv[0] true\n"));
}
$path2covers = NN_COVERS . 'xxx' . DS;
$dirItr = new RecursiveDirectoryIterator($path2covers);
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
if (is_file($filePath) && preg_match('/-cover\.jpg/', $filePath)) {
preg_match('/(\d+)-cover\.jpg/', basename($filePath), $match);
if (isset($match[1])) {
$run = $pdo->queryDirect("UPDATE xxxinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
if ($run->rowCount() >= 1) {
$covers++;
} else {
$run = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE id = " . $match[1]);
if ($run->rowCount() == 0) {
echo $c->info($filePath . " not found in db.");
}
}
}
}
if (is_file($filePath) && preg_match('/-backdrop\.jpg/', $filePath)) {
preg_match('/(\d+)-backdrop\.jpg/', basename($filePath), $match1);
if (isset($match1[1])) {
$run = $pdo->queryDirect("UPDATE xxxinfo SET backdrop = 1 WHERE backdrop = 0 AND id = " . $match1[1]);
if ($run->rowCount() >= 1) {
$updated++;
printf("UPDATE xxxinfo SET backdrop = 1 WHERE backdrop = 0 AND id = " . $match1[1] . "\n");
} else {
$run = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE id = " . $match1[1]);
if ($run->rowCount() == 0) {
echo $c->info($filePath . " not found in db.");
}
}
}
}
}
$qry = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE cover = 1");
if ($qry instanceof Traversable) {
foreach ($qry as $rows) {
if (!is_file($path2covers . $rows['id'] . '-cover.jpg')) {
$pdo->queryDirect("UPDATE xxxinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
echo $c->info($path2covers . $rows['id'] . "-cover.jpg does not exist.");
$deleted++;
}
}
}
$qry1 = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE backdrop = 1");
if ($qry1 instanceof Traversable) {
foreach ($qry1 as $rows) {
if (!is_file($path2covers . $rows['id'] . '-backdrop.jpg')) {
$pdo->queryDirect("UPDATE xxxinfo SET backdrop = 0 WHERE backdrop = 1 AND id = " . $rows['id']);
echo $c->info($path2covers . $rows['id'] . "-backdrop.jpg does not exist.");
$deleted++;
}
}
}
echo $c->header($covers . " covers set.");
echo $c->header($updated . " backdrops set.");
echo $c->header($deleted . " movies unset.");