Skip to content

Instantly share code, notes, and snippets.

@doersino
Last active September 8, 2016 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doersino/e8411703304fbbacd3e79e2cbbc32a2c to your computer and use it in GitHub Desktop.
Save doersino/e8411703304fbbacd3e79e2cbbc32a2c to your computer and use it in GitHub Desktop.
Will attempt to (re-)get titles and sources for all articles in ReAD where the title is empty.
<?php
// Put this in the same folder as your https://github.com/doersino/ReAD install.
// This will attempt to (re-)get titles and sources for all articles where the
// title is empty.
require_once "lib/meekrodb.2.3.class.php";
require_once "Helper.class.php";
$q = DB::query("SELECT * FROM `read` WHERE `title` = ''");
echo count($q) . "\n";
foreach ($q as $a) {
$id = $a["id"];
$url = $a["url"];
$source = @Helper::getSource($url);
$title = @Helper::getTitle($source, $url);
echo $id . "\n";
echo $url . "\n";
echo $title . "\n";
$q = DB::queryFirstRow("SELECT * FROM `read_sources` WHERE `id` = %i", $id);
echo strlen($q["source"]) . "\n";
echo "-------------------------------------------------------------------------------\n";
if (!empty($title)) {
DB::query("UPDATE `read` SET `title` = %s WHERE `id` = %i", $title, $id);
DB::query("UPDATE `read_sources` SET `source` = %s WHERE `id` = %i", $source, $id);
echo "updated! ";
echo "----------------------------------------------------------------------\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment