[VkBridge] Several improvements (#1802)

* Improved post author computation
* Show repost sources
* Handle second copy quote
* Fixed incorrect image uri's
This commit is contained in:
Eugene Molotov 2020-12-18 07:58:51 +05:00 committed by GitHub
parent 2ddd357a62
commit 59bbc9d2e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -232,11 +232,16 @@ class VkBridge extends BridgeAbstract
$div->outertext = '';
}
// get sign
// get sign / post author
$post_author = $pageName;
foreach($post->find('a.wall_signed_by') as $a) {
$post_author = $a->innertext;
$a->outertext = '';
$author_selectors = array('a.wall_signed_by', 'a.author');
foreach($author_selectors as $author_selector) {
$a = $post->find($author_selector, 0);
if (is_object($a)) {
$post_author = $a->innertext;
$a->outertext = '';
break;
}
}
// fix links and get post hashtags
@ -274,16 +279,24 @@ class VkBridge extends BridgeAbstract
}
}
if (is_object($post->find('div.copy_quote', 0))) {
$copy_quote = $post->find('div.copy_quote', 0);
if (is_object($copy_quote)) {
if ($this->getInput('hide_reposts') === true) {
continue;
}
$copy_quote = $post->find('div.copy_quote', 0);
if ($copy_post_header = $copy_quote->find('div.copy_post_header', 0)) {
$copy_post_header->outertext = '';
}
$second_copy_quote = $copy_quote->find('div.published_sec_quote', 0);
if (is_object($second_copy_quote)) {
$second_copy_quote_author = $second_copy_quote->find('a.copy_author', 0)->outertext;
$second_copy_quote_content = $second_copy_quote->find('div.copy_post_date', 0)->outertext;
$second_copy_quote->outertext = "<br>Reposted ($second_copy_quote_author): $second_copy_quote_content";
}
$copy_quote_author = $copy_quote->find('a.copy_author', 0)->outertext;
$copy_quote_content = $copy_quote->innertext;
$copy_quote->outertext = "<br>Reposted: <br>$copy_quote_content";
$copy_quote->outertext = "<br>Reposted ($copy_quote_author): <br>$copy_quote_content";
}
$item = array();
@ -333,7 +346,7 @@ class VkBridge extends BridgeAbstract
$data = json_decode($arg, true);
if ($data == null) return;
$thumb = $data['temp']['base'] . $data['temp']['x_'][0] . '.jpg';
$thumb = $data['temp']['base'] . $data['temp']['x_'][0];
$original = '';
foreach(array('y_', 'z_', 'w_') as $key) {
if (!isset($data['temp'][$key])) continue;
@ -343,7 +356,7 @@ class VkBridge extends BridgeAbstract
} else {
$base = $data['temp']['base'];
}
$original = $base . $data['temp'][$key][0] . '.jpg';
$original = $base . $data['temp'][$key][0];
}
if ($original) {