Skip to content

Instantly share code, notes, and snippets.

@stephenl03
Created February 18, 2017 06:53
Show Gist options
  • Save stephenl03/1bf9d6e5d6287d9991774d702601f5c4 to your computer and use it in GitHub Desktop.
Save stephenl03/1bf9d6e5d6287d9991774d702601f5c4 to your computer and use it in GitHub Desktop.
help identify releases
<?php
/*
* This script will rename all releases posted by 'diamonds@Pussycat.com' to the rar filename.
* It will then reset all the values, so PostProcessing will check the release again and download all relevant info
* Written by stephenl03
*/
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'bootstrap.php');
use nzedb\db\DB;
use nzedb\Categorize;
use nzedb\Category;
use nzedb\ColorCLI;
use nzedb\ConsoleTools;
use nzedb\Groups;
use nzedb\NameFixer;
$pdo = new DB();
$cat = new Categorize(['Settings' => $pdo]);
$pdo->log = new ColorCLI();
$consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
$fixer = new NameFixer();
$poster = 'diamonds@Pussycat.com <pussy@cat.com>';
$regex = '^.*(x264)[[:space:]](720p-NPW.rar)';
$regex2 = '[a-f0-9]{32}[[:space:]]\\[[0-9]{2,3}/[0-9]{2,3}\\][[:space:]]-[[:space:]]"';
$count = 0;
$timestart = TIME();
echo $pdo->log->header("Getting releases to process...");
$sql = sprintf("SELECT rf.name AS textstring, rel.name, rel.searchname, rel.groups_id, rel.categories_id, rel.id AS releases_id FROM releases rel INNER JOIN release_files rf ON (rf.releases_id = rel.id) WHERE nzbstatus = 1 AND predb_id = 0 AND fromname = %s AND searchname REGEXP %s AND rf.name REGEXP %s;", $pdo->escapeString($poster), $pdo->escapeString($regex2), $pdo->escapeString($regex));
$result = $pdo->query($sql);
foreach ($result as $r) {
$rts = $r['textstring'];
$rts = preg_replace("#\.rar$#", "", $rts);
$searchname = sprintf("UPDATE releases SET searchname = %s WHERE id = %d;", $pdo->escapeString($rts), $r['releases_id'], $r['releases_id']);
$releases = sprintf("UPDATE releases SET consoleinfo_id = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfo_id = NULL, bookinfo_id = NULL, videos_id = 0, tv_episodes_id = 0, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1 WHERE id = %d", $r['releases_id']);
$resp = $pdo->queryExec($searchname);
$res = $pdo->queryExec($releases);
$catId = $cat->determineCategory($r['groups_id'], $rts);
if ($r['categories_id'] != $catId) {
$catup = $pdo->queryExec(sprintf("UPDATE releases SET iscategorized = 1, categories_id = %d WHERE id = %d", $catId, $r['releases_id']));
}
$echodata = array('new_name' => $rts, 'old_name' => $r['searchname'], 'old_category' => $cats->getNameByID($r['categories_id']), 'new_category' => $cats->getNameByID($catId), 'group' => $groups->getNameByID($r['groups_id']), 'release_id' => $r['releases_id'], 'method' => 'File Name Match');
$fixer->echoChangedReleaseName($echodata);
if ($resp && $res && $catup) {
echo $pdo->log->info("Done!");
} else {
var_dump($res);
}
$count++;
}
$time = $consoletools->convertTime(TIME() - $timestart);
echo $pdo->log->primary("Updated " . $count . " releases in ". $time .".");
@CollinChaffin
Copy link

Doesn't work. Anyone else reading - save your friggig time none of these nzedb php scripts posted here actually work anymore (assuming they briefly did) and I just had to waste more hours trying to make them work without any luck.

Like many of these nzedb scripts as I just opened several more issues showing where these critical scripts aren't even firing due to syntax errors. So now I have all these releases on my other monitor literally staring me in the face that match this script's regex......making it one of the few that actually may be worthwhile in renaming right now......only now in the last few months someone else on your team went and rewrote the base fixReleasenames.php to better written as classes and calling NameFixer.php.......which is all actually a step in the right direction but once again something else apparently changed....I'm guessing in the friggin DB since despite having hundreds of matches on my screen, this php runs fine and returns nothing from the DB. Any chance you guys might actually document any of these changes, particularly when you're posting these 'newer' versions as gists with the usual zero documentation and they either stop working suddenly or never work because we don't have your magic DEV team decoder ring....? :)

Since this poster is only about 90 friggin percent of the current non-scene releases but hashed, boy it might be really helpful for one of you to copy and adjust this already written code into NameFixer and make it the new #11 call, right? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment