Improvements
This commit is contained in:
parent
7555b94345
commit
ff21216885
1 changed files with 10 additions and 9 deletions
|
|
@ -7,6 +7,8 @@
|
||||||
*/
|
*/
|
||||||
final class YouTubeExtension extends Minz_Extension
|
final class YouTubeExtension extends Minz_Extension
|
||||||
{
|
{
|
||||||
|
public const EXT_NAME = 'YouTube Video Feed';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video player width
|
* Video player width
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,7 +61,13 @@ final class YouTubeExtension extends Minz_Extension
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once(LIB_PATH . '/favicons.php');
|
// Return early if the icon had already been downloaded before
|
||||||
|
$oldAttributes = $feed->attributes();
|
||||||
|
if (file_exists($feed->setCustomFavicon(extName: self::EXT_NAME, disallowDelete: true))) {
|
||||||
|
Minz_Log::debug('[xExtension-YouTube] icon had already been downloaded before for feed "' . $feed->name(true) . '" - returning early!');
|
||||||
|
return $feed;
|
||||||
|
}
|
||||||
|
$feed->_attributes($oldAttributes);
|
||||||
|
|
||||||
$url = $feed->website();
|
$url = $feed->website();
|
||||||
/** @var $curlOptions array<int,int|bool|string> */
|
/** @var $curlOptions array<int,int|bool|string> */
|
||||||
|
|
@ -93,11 +101,8 @@ final class YouTubeExtension extends Minz_Extension
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldCustom = $feed->attributeBoolean('customFavicon');
|
|
||||||
$oldHash = $feed->hashFavicon();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$feed->setCustomFavicon($contents, extName: 'YouTube Video Feed', disallowDelete: true);
|
$feed->setCustomFavicon($contents, extName: self::EXT_NAME, disallowDelete: true);
|
||||||
} catch (FreshRSS_UnsupportedImageFormat_Exception $_) {
|
} catch (FreshRSS_UnsupportedImageFormat_Exception $_) {
|
||||||
Minz_Log::warning('[xExtension-YouTube] failed to set custom favicon for feed "' . $feed->name(true) . '": unsupported image format');
|
Minz_Log::warning('[xExtension-YouTube] failed to set custom favicon for feed "' . $feed->name(true) . '": unsupported image format');
|
||||||
return $feed;
|
return $feed;
|
||||||
|
|
@ -106,10 +111,6 @@ final class YouTubeExtension extends Minz_Extension
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oldCustom) {
|
|
||||||
FreshRSS_Feed::faviconDelete($oldHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue