Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.