Skip to content

Commit

Permalink
[TelegramBridge] Fix entries for "media too big" (RSS-Bridge#1184)
Browse files Browse the repository at this point in the history
When a large video is posted, "Media is too big" appears in web preview. This adds code to detect this and offer a link.
  • Loading branch information
triatic authored and logmanoriginal committed Jun 23, 2019
1 parent 5dd1baf commit 04b9a33
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bridges/TelegramBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ private function processContent($messageDiv) {
$message .= $this->processPhoto($messageDiv);
}

if ($messageDiv->find('a.not_supported', 0)) {
$message .= $this->processNotSupported($messageDiv);
}

if ($messageDiv->find('div.tgme_widget_message_text.js-message_text', 0)) {
$message .= $messageDiv->find('div.tgme_widget_message_text.js-message_text', 0);

Expand Down Expand Up @@ -250,6 +254,24 @@ private function processPhoto($messageDiv) {
return $photos;
}

private function processNotSupported($messageDiv) {

if (empty($this->itemTitle)) {
$this->itemTitle = '@' . $this->processUsername() . ' posted a video';
}

preg_match($this->backgroundImageRegex, $messageDiv->find('i.tgme_widget_message_video_thumb', 0)->style, $photo);

$this->enclosures[] = $photo[1];

return <<<EOD
<a href="{$messageDiv->find('a.not_supported', 0)->href}">
{$messageDiv->find('div.message_media_not_supported_label', 0)->innertext}<br><br>
{$messageDiv->find('span.message_media_view_in_telegram', 0)->innertext}<br><br>
<img src="{$photo[1]}"/></a>
EOD;
}

private function processDate($messageDiv) {

$messageMeta = $messageDiv->find('span.tgme_widget_message_meta', 0);
Expand Down

0 comments on commit 04b9a33

Please sign in to comment.