Last active
September 8, 2016 19:45
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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