Updated publish Daemon call for sdk 0.54
This commit is contained in:
parent
c72c6f8543
commit
5c6a16acdd
1 changed files with 38 additions and 36 deletions
|
@ -21,51 +21,53 @@ class LBRY_Network_Publisher
|
||||||
$converted = LBRY()->network->parser->convert_to_markdown($post);
|
$converted = LBRY()->network->parser->convert_to_markdown($post);
|
||||||
$write_status = $file && fwrite($file, $converted);
|
$write_status = $file && fwrite($file, $converted);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
$endtime = microtime(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!$write_status) {
|
||||||
|
throw new \Exception('Write Status failure', 1);
|
||||||
|
}
|
||||||
|
|
||||||
// If everything went well with the conversion, carry on
|
// If everything went well with the conversion, carry on
|
||||||
if ($write_status) {
|
$args = array(
|
||||||
$args = array(
|
'name' => $post->post_name,
|
||||||
'name' => $post->post_name,
|
'bid' => number_format(floatval(get_option(LBRY_SETTINGS)[LBRY_LBC_PUBLISH]), 2, '.', ''),
|
||||||
'bid' => number_format(floatval(get_option(LBRY_SETTINGS)[LBRY_LBC_PUBLISH]), 2, '.', ''),
|
'file_path' => $filepath,
|
||||||
'file_path' => $filepath,
|
'title' => $post->post_title,
|
||||||
'title' => $post->post_title,
|
'languages' => array(substr(get_locale(), 0, 2)),
|
||||||
'language' => substr(get_locale(), 0, 2),
|
'license' => get_option(LBRY_SETTINGS)[LBRY_LICENSE]
|
||||||
'license' => get_option(LBRY_SETTINGS)[LBRY_LICENSE]
|
);
|
||||||
);
|
|
||||||
|
|
||||||
// Setup channel
|
// Setup channel
|
||||||
if ($channel && $channel != 'null') {
|
if ($channel && $channel != 'null') {
|
||||||
$args['channel_id'] = $channel;
|
$args['channel_id'] = $channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup featured image
|
// Setup featured image
|
||||||
$featured_id = get_post_thumbnail_id($post);
|
$featured_id = get_post_thumbnail_id($post);
|
||||||
$featured_image = wp_get_attachment_image_src($featured_id, 'medium');
|
$featured_image = wp_get_attachment_image_src($featured_id, 'medium');
|
||||||
|
|
||||||
if ($featured_image[0]) {
|
if ($featured_image[0]) {
|
||||||
$args['thumbnail'] = $featured_image[0];
|
$args['thumbnail_url'] = $featured_image[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build description using Yoast if installed and its used, excerpt/title otherwise
|
// Build description using Yoast if installed and its used, excerpt/title otherwise
|
||||||
$description = false;
|
$description = false;
|
||||||
if (class_exists('WPSEO_META')) {
|
if (class_exists('WPSEO_META')) {
|
||||||
$description = WPSEO_META::get_value('opengraph-description', $post->ID);
|
$description = WPSEO_META::get_value('opengraph-description', $post->ID);
|
||||||
}
|
}
|
||||||
if (!$description) {
|
if (!$description) {
|
||||||
$excerpt = get_the_excerpt($post);
|
$excerpt = get_the_excerpt($post);
|
||||||
$description = $excerpt ? $excerpt : $post->post_title;
|
$description = $excerpt ? $excerpt : $post->post_title;
|
||||||
}
|
}
|
||||||
$description .= ' | Originally published at ' . get_permalink($post);
|
$description .= ' | Originally published at ' . get_permalink($post);
|
||||||
|
|
||||||
$args['description'] = $description;
|
$args['description'] = $description;
|
||||||
|
|
||||||
$result = LBRY()->daemon->publish($args);
|
$result = LBRY()->daemon->publish($args);
|
||||||
if ($result->success) {
|
$outputs = $result->outputs;
|
||||||
error_log(print_r($result, true));
|
|
||||||
update_post_meta($post->ID, LBRY_PERM_URL, $result->output->permanent_url);
|
if ($outputs && is_array($outputs)) {
|
||||||
}
|
update_post_meta($post->ID, LBRY_PERM_URL, $result->outputs[0]->permanent_url);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log('Issue publishing post ' . $post->ID . ' to LBRY: ' . $e->getMessage());
|
error_log('Issue publishing post ' . $post->ID . ' to LBRY: ' . $e->getMessage());
|
||||||
|
|
Loading…
Reference in a new issue