mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-24 18:36:59 +03:00
[InstagramBridge] Fixed item thumb on video entries (#1387)
This commit is contained in:
parent
c9e5f6c9dd
commit
3179c1e884
2 changed files with 19 additions and 9 deletions
|
@ -123,6 +123,12 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
$item['title'] = substr($item['title'], 0, $titleLinePos) . '...';
|
$item['title'] = substr($item['title'], 0, $titleLinePos) . '...';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($directLink) {
|
||||||
|
$mediaURI = $media->display_url;
|
||||||
|
} else {
|
||||||
|
$mediaURI = self::URI . 'p/' . $media->shortcode . '/media?size=l';
|
||||||
|
}
|
||||||
|
|
||||||
switch($media->__typename) {
|
switch($media->__typename) {
|
||||||
case 'GraphSidecar':
|
case 'GraphSidecar':
|
||||||
$data = $this->getInstagramSidecarData($item['uri'], $item['title']);
|
$data = $this->getInstagramSidecarData($item['uri'], $item['title']);
|
||||||
|
@ -130,24 +136,20 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
$item['enclosures'] = $data[1];
|
$item['enclosures'] = $data[1];
|
||||||
break;
|
break;
|
||||||
case 'GraphImage':
|
case 'GraphImage':
|
||||||
if($directLink) {
|
|
||||||
$mediaURI = $media->display_url;
|
|
||||||
} else {
|
|
||||||
$mediaURI = self::URI . 'p/' . $media->shortcode . '/media?size=l';
|
|
||||||
}
|
|
||||||
$item['content'] = '<a href="' . htmlentities($item['uri']) . '" target="_blank">';
|
$item['content'] = '<a href="' . htmlentities($item['uri']) . '" target="_blank">';
|
||||||
$item['content'] .= '<img src="' . htmlentities($mediaURI) . '" alt="' . $item['title'] . '" />';
|
$item['content'] .= '<img src="' . htmlentities($mediaURI) . '" alt="' . $item['title'] . '" />';
|
||||||
$item['content'] .= '</a><br><br>' . nl2br(htmlentities($textContent));
|
$item['content'] .= '</a><br><br>' . nl2br(htmlentities($textContent));
|
||||||
$item['enclosures'] = array($mediaURI);
|
$item['enclosures'] = array($mediaURI);
|
||||||
break;
|
break;
|
||||||
case 'GraphVideo':
|
case 'GraphVideo':
|
||||||
$data = $this->getInstagramVideoData($item['uri']);
|
$data = $this->getInstagramVideoData($item['uri'], $mediaURI);
|
||||||
$item['content'] = $data[0];
|
$item['content'] = $data[0];
|
||||||
if($directLink) {
|
if($directLink) {
|
||||||
$item['enclosures'] = $data[1];
|
$item['enclosures'] = $data[1];
|
||||||
} else {
|
} else {
|
||||||
$item['enclosures'] = array(self::URI . 'p/' . $media->shortcode . '/media?size=l');
|
$item['enclosures'] = array($mediaURI);
|
||||||
}
|
}
|
||||||
|
$item['thumbnail'] = $mediaURI;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -185,11 +187,14 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns Video post's contents and enclosures
|
// returns Video post's contents and enclosures
|
||||||
protected function getInstagramVideoData($uri) {
|
protected function getInstagramVideoData($uri, $mediaURI) {
|
||||||
$mediaInfo = $this->getSinglePostData($uri);
|
$mediaInfo = $this->getSinglePostData($uri);
|
||||||
|
|
||||||
$textContent = $this->getTextContent($mediaInfo);
|
$textContent = $this->getTextContent($mediaInfo);
|
||||||
$content = '<video controls><source src="' . $mediaInfo->video_url . '" type="video/mp4"></video><br>';
|
$content = '<video controls>';
|
||||||
|
$content .= '<source src="' . $mediaInfo->video_url . '" poster="' . $mediaURI . '" type="video/mp4">';
|
||||||
|
$content .= '<img src="' . $mediaURI . '" alt="">';
|
||||||
|
$content .= '</video><br>';
|
||||||
$content .= '<br>' . nl2br(htmlentities($textContent));
|
$content .= '<br>' . nl2br(htmlentities($textContent));
|
||||||
|
|
||||||
return array($content, array($mediaInfo->video_url));
|
return array($content, array($mediaInfo->video_url));
|
||||||
|
|
|
@ -89,6 +89,10 @@ class AtomFormat extends FormatAbstract{
|
||||||
. PHP_EOL;
|
. PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entryThumbnail = $item->thumbnail;
|
||||||
|
if (!empty($entryThumbnail))
|
||||||
|
$entryThumbnail = '<media:thumbnail url="' . $this->xml_encode($entryThumbnail) . '"/>';
|
||||||
|
|
||||||
$entryLinkAlternate = '';
|
$entryLinkAlternate = '';
|
||||||
if (!empty($entryUri)) {
|
if (!empty($entryUri)) {
|
||||||
$entryLinkAlternate = '<link rel="alternate" type="text/html" href="'
|
$entryLinkAlternate = '<link rel="alternate" type="text/html" href="'
|
||||||
|
@ -114,6 +118,7 @@ class AtomFormat extends FormatAbstract{
|
||||||
<content type="html">{$entryContent}</content>
|
<content type="html">{$entryContent}</content>
|
||||||
{$entryEnclosures}
|
{$entryEnclosures}
|
||||||
{$entryCategories}
|
{$entryCategories}
|
||||||
|
{$entryThumbnail}
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
|
|
Loading…
Reference in a new issue