<html>
<head>
<title>Neue Thumbnails laden</title>
</head>
<body>
<a href="list_pods.php">Zur Liste</a>
<?php
require_once("../config.php");
require_once("lib/db_utils.php");
require_once("lib/path_utils.php");
require_once("lib/guid_utils.php");
require_once("lib/img_utils.php");
require_once("lib/ingest_utils.php");
require_once("lib/form_utils.php");
require_once("lib/xml.php");
$my_log = LoggerManager::getLogger("update_pods");
$sql = "select item.id from item, podcast where item.podcast_id = podcast.id and item.item_type like 'image%' and item.has_icon=1 and item.deleted != 1 and podcast.deleted!=1 order by item.pubdate desc";
echo $sql."<br/>\n";
$items = array();
$rs = db_query($sql);
while ($row = db_next_row($rs)) {
$items[] = get_item($row["id"]);
}
$i = 0;
foreach ($items as $item) {
$i++;
echo ("handling item ".$i." von ".count($items)." - ".$item["title"]."<br/>\n");
$icon_dir = FS_BASE_ICONS.get_item_icon_dir($item);
if (!is_dir($icon_dir)) {
mkdir($icon_dir);
}
$icon = FS_BASE_ICONS.get_item_icon_path_base($item);
$icon_big = FS_BASE_ICONS.get_item_icon_path_big_base($item);
$icon_png = FS_BASE_ICONS.get_item_icon_path($item, "png");
$icon_png_big = FS_BASE_ICONS.get_item_icon_path_big($item, "png");
if (is_file($icon_png) && is_file($icon_png_big)) continue;
$podcast = get_podcast($item["podcast_id"]);
if (starts_with($item["item_type"], "image")) {
$local_filename_src = FS_BASE_PODCASTS.get_item_path_converted($item, "image/png/400");
if (is_file($local_filename_src)) {
echo ("creating thumbnails for item ".$i." von ".count($items)." - ".$item["title"]."<br/>\n");
$e1 = makeThumbnail($local_filename_src, $icon, 32, true);
$e2 = makeThumbnail($local_filename_src, $icon_big, 96, true);
if ($e1 == null) {
$item["has_icon"] = 1;
} else {
$item["has_icon"] = 0;
}
} else {
$item["has_icon"] = 0;
}
update_item($item);
}
if (isset($argv)) {
shell_exec("chown -R www-data.www-data ".$icon_dir."*");
}
flush();
}
?>
</body>
</html>