mirror of
https://github.com/friendica/friendica
synced 2025-05-05 17:04:11 +02:00
Unused OEmbed functionality is removed
This commit is contained in:
parent
0ff37c0075
commit
821a135033
5 changed files with 48 additions and 274 deletions
|
@ -99,8 +99,6 @@ class ParseUrl
|
|||
* Search for cached embeddable data of an url otherwise fetch it
|
||||
*
|
||||
* @param string $url The url of the page which should be scraped
|
||||
* @param bool $do_oembed The false option is used by the function fetch_oembed()
|
||||
* to avoid endless loops
|
||||
*
|
||||
* @return array which contains needed data for embedding
|
||||
* string 'url' => The url of the parsed page
|
||||
|
@ -115,7 +113,7 @@ class ParseUrl
|
|||
* @see ParseUrl::getSiteinfo() for more information about scraping
|
||||
* embeddable content
|
||||
*/
|
||||
public static function getSiteinfoCached(string $url, bool $do_oembed = true): array
|
||||
public static function getSiteinfoCached(string $url): array
|
||||
{
|
||||
if (empty($url)) {
|
||||
return [
|
||||
|
@ -127,14 +125,14 @@ class ParseUrl
|
|||
$urlHash = hash('sha256', $url);
|
||||
|
||||
$parsed_url = DBA::selectFirst('parsed_url', ['content'],
|
||||
['url_hash' => $urlHash, 'oembed' => $do_oembed]
|
||||
['url_hash' => $urlHash, 'oembed' => false]
|
||||
);
|
||||
if (!empty($parsed_url['content'])) {
|
||||
$data = unserialize($parsed_url['content']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data = self::getSiteinfo($url, $do_oembed);
|
||||
$data = self::getSiteinfo($url);
|
||||
|
||||
$expires = $data['expires'];
|
||||
|
||||
|
@ -144,7 +142,7 @@ class ParseUrl
|
|||
'parsed_url',
|
||||
[
|
||||
'url_hash' => $urlHash,
|
||||
'oembed' => $do_oembed,
|
||||
'oembed' => false,
|
||||
'url' => $url,
|
||||
'content' => serialize($data),
|
||||
'created' => DateTimeFormat::utcNow(),
|
||||
|
@ -194,7 +192,7 @@ class ParseUrl
|
|||
* </body>
|
||||
* @endverbatim
|
||||
*/
|
||||
public static function getSiteinfo(string $url, bool $do_oembed = true, int $count = 1): array
|
||||
public static function getSiteinfo(string $url, int $count = 1): array
|
||||
{
|
||||
if (empty($url)) {
|
||||
return [
|
||||
|
@ -254,41 +252,6 @@ class ParseUrl
|
|||
|
||||
$body = $curlResult->getBodyString();
|
||||
|
||||
if ($do_oembed) {
|
||||
$oembed_data = OEmbed::fetchURL($url, false, false);
|
||||
|
||||
if (!empty($oembed_data->type)) {
|
||||
if (!in_array($oembed_data->type, ['error', 'rich', 'image', 'video', 'audio', ''])) {
|
||||
$siteinfo['type'] = $oembed_data->type;
|
||||
}
|
||||
|
||||
// See https://github.com/friendica/friendica/pull/5763#discussion_r217913178
|
||||
if ($siteinfo['type'] != 'photo') {
|
||||
if (!empty($oembed_data->title)) {
|
||||
$siteinfo['title'] = trim($oembed_data->title);
|
||||
}
|
||||
if (!empty($oembed_data->description)) {
|
||||
$siteinfo['text'] = trim($oembed_data->description);
|
||||
}
|
||||
if (!empty($oembed_data->author_name)) {
|
||||
$siteinfo['author_name'] = trim($oembed_data->author_name);
|
||||
}
|
||||
if (!empty($oembed_data->author_url)) {
|
||||
$siteinfo['author_url'] = Network::sanitizeUrl($oembed_data->author_url);
|
||||
}
|
||||
if (!empty($oembed_data->provider_name)) {
|
||||
$siteinfo['publisher_name'] = trim($oembed_data->provider_name);
|
||||
}
|
||||
if (!empty($oembed_data->provider_url)) {
|
||||
$siteinfo['publisher_url'] = Network::sanitizeUrl($oembed_data->provider_url);
|
||||
}
|
||||
if (!empty($oembed_data->thumbnail_url)) {
|
||||
$siteinfo['image'] = $oembed_data->thumbnail_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$charset = '';
|
||||
try {
|
||||
// Look for a charset, first in headers
|
||||
|
@ -351,7 +314,7 @@ class ParseUrl
|
|||
}
|
||||
}
|
||||
if ($content != '') {
|
||||
$siteinfo = self::getSiteinfo($content, $do_oembed, ++$count);
|
||||
$siteinfo = self::getSiteinfo($content, ++$count);
|
||||
return $siteinfo;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue