[InstagramBridge] Remove redundant data collection for sidecar and video (#1920)
getInstagramSidecarData and getInstagramVideoData were unnecessarily calling getSinglePostData to retrieve data already present in collectData's call of getInstagramJSON. getSinglePostData sometimes doesn't retrieve data properly resulting in incomplete post information. Since the information needed is already present, pass it from collectData instead, eliminating the redundant data collection and improving reliability.
This commit is contained in:
parent
1edec1aa45
commit
5ed161943c
1 changed files with 4 additions and 11 deletions
|
@ -131,7 +131,7 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
|
|
||||||
switch($media->__typename) {
|
switch($media->__typename) {
|
||||||
case 'GraphSidecar':
|
case 'GraphSidecar':
|
||||||
$data = $this->getInstagramSidecarData($item['uri'], $item['title']);
|
$data = $this->getInstagramSidecarData($item['uri'], $item['title'], $media, $textContent);
|
||||||
$item['content'] = $data[0];
|
$item['content'] = $data[0];
|
||||||
$item['enclosures'] = $data[1];
|
$item['enclosures'] = $data[1];
|
||||||
break;
|
break;
|
||||||
|
@ -142,7 +142,7 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
$item['enclosures'] = array($mediaURI);
|
$item['enclosures'] = array($mediaURI);
|
||||||
break;
|
break;
|
||||||
case 'GraphVideo':
|
case 'GraphVideo':
|
||||||
$data = $this->getInstagramVideoData($item['uri'], $mediaURI);
|
$data = $this->getInstagramVideoData($item['uri'], $mediaURI, $media, $textContent);
|
||||||
$item['content'] = $data[0];
|
$item['content'] = $data[0];
|
||||||
if($directLink) {
|
if($directLink) {
|
||||||
$item['enclosures'] = $data[1];
|
$item['enclosures'] = $data[1];
|
||||||
|
@ -160,11 +160,7 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns Sidecar(a post which has multiple media)'s contents and enclosures
|
// returns Sidecar(a post which has multiple media)'s contents and enclosures
|
||||||
protected function getInstagramSidecarData($uri, $postTitle) {
|
protected function getInstagramSidecarData($uri, $postTitle, $mediaInfo, $textContent) {
|
||||||
$mediaInfo = $this->getSinglePostData($uri);
|
|
||||||
|
|
||||||
$textContent = $this->getTextContent($mediaInfo);
|
|
||||||
|
|
||||||
$enclosures = array();
|
$enclosures = array();
|
||||||
$content = '';
|
$content = '';
|
||||||
foreach($mediaInfo->edge_sidecar_to_children->edges as $singleMedia) {
|
foreach($mediaInfo->edge_sidecar_to_children->edges as $singleMedia) {
|
||||||
|
@ -187,10 +183,7 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns Video post's contents and enclosures
|
// returns Video post's contents and enclosures
|
||||||
protected function getInstagramVideoData($uri, $mediaURI) {
|
protected function getInstagramVideoData($uri, $mediaURI, $mediaInfo, $textContent) {
|
||||||
$mediaInfo = $this->getSinglePostData($uri);
|
|
||||||
|
|
||||||
$textContent = $this->getTextContent($mediaInfo);
|
|
||||||
$content = '<video controls>';
|
$content = '<video controls>';
|
||||||
$content .= '<source src="' . $mediaInfo->video_url . '" poster="' . $mediaURI . '" type="video/mp4">';
|
$content .= '<source src="' . $mediaInfo->video_url . '" poster="' . $mediaURI . '" type="video/mp4">';
|
||||||
$content .= '<img src="' . $mediaURI . '" alt="">';
|
$content .= '<img src="' . $mediaURI . '" alt="">';
|
||||||
|
|
Loading…
Reference in a new issue