mirror of
https://github.com/friendica/friendica
synced 2024-11-11 19:02:54 +00:00
Integrate fetching of the content type into "getSiteinfo"
This commit is contained in:
parent
262ee2b0b1
commit
ffb92e3355
3 changed files with 13 additions and 11 deletions
|
@ -2257,10 +2257,10 @@ class BBCode
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = ParseUrl::getContentType($url);
|
$siteinfo = ParseUrl::getSiteinfoCached($url);
|
||||||
|
|
||||||
if (in_array($type, ['image', 'video', 'audio'])) {
|
if (in_array($siteinfo['type'], ['image', 'video', 'audio'])) {
|
||||||
switch ($type) {
|
switch ($siteinfo['type']) {
|
||||||
case 'video':
|
case 'video':
|
||||||
$bbcode = "\n" . '[video]' . $url . '[/video]' . "\n";
|
$bbcode = "\n" . '[video]' . $url . '[/video]' . "\n";
|
||||||
break;
|
break;
|
||||||
|
@ -2275,8 +2275,6 @@ class BBCode
|
||||||
return $bbcode;
|
return $bbcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
$siteinfo = ParseUrl::getSiteinfoCached($url);
|
|
||||||
|
|
||||||
unset($siteinfo['keywords']);
|
unset($siteinfo['keywords']);
|
||||||
|
|
||||||
// Bypass attachment if parse url for a comment
|
// Bypass attachment if parse url for a comment
|
||||||
|
|
|
@ -94,10 +94,10 @@ class ParseUrl extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($format == 'json') {
|
if ($format == 'json') {
|
||||||
$type = Util\ParseUrl::getContentType($url);
|
$siteinfo = Util\ParseUrl::getSiteinfoCached($url);
|
||||||
|
|
||||||
if (in_array($type, ['image', 'video', 'audio'])) {
|
if (in_array($siteinfo['type'], ['image', 'video', 'audio'])) {
|
||||||
switch ($type) {
|
switch ($siteinfo['type']) {
|
||||||
case 'video':
|
case 'video':
|
||||||
$content_type = 'video';
|
$content_type = 'video';
|
||||||
break;
|
break;
|
||||||
|
@ -113,8 +113,6 @@ class ParseUrl extends BaseModule
|
||||||
$ret['data'] = ['url' => $url];
|
$ret['data'] = ['url' => $url];
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
} else {
|
} else {
|
||||||
$siteinfo = Util\ParseUrl::getSiteinfoCached($url);
|
|
||||||
|
|
||||||
unset($siteinfo['keywords']);
|
unset($siteinfo['keywords']);
|
||||||
|
|
||||||
$ret['data'] = $siteinfo;
|
$ret['data'] = $siteinfo;
|
||||||
|
|
|
@ -210,6 +210,12 @@ class ParseUrl
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type = self::getContentType($url);
|
||||||
|
if (in_array($type, ['image', 'video', 'audio'])) {
|
||||||
|
$siteinfo['type'] = $type;
|
||||||
|
return $siteinfo;
|
||||||
|
}
|
||||||
|
|
||||||
$curlResult = DI::httpRequest()->get($url);
|
$curlResult = DI::httpRequest()->get($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
return $siteinfo;
|
return $siteinfo;
|
||||||
|
@ -251,7 +257,7 @@ class ParseUrl
|
||||||
$oembed_data = OEmbed::fetchURL($url);
|
$oembed_data = OEmbed::fetchURL($url);
|
||||||
|
|
||||||
if (!empty($oembed_data->type)) {
|
if (!empty($oembed_data->type)) {
|
||||||
if (!in_array($oembed_data->type, ['error', 'rich', ''])) {
|
if (!in_array($oembed_data->type, ['error', 'rich', 'image', 'video', 'audio', ''])) {
|
||||||
$siteinfo['type'] = $oembed_data->type;
|
$siteinfo['type'] = $oembed_data->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue