forked from leftypol/leftypol
Compare commits
4 commits
fe5368f096
...
9f9fba63d9
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9f9fba63d9 | ||
![]() |
a5770a2de5 | ||
![]() |
871e8d78dc | ||
![]() |
9df6cdbf28 |
3 changed files with 15 additions and 4 deletions
|
@ -115,7 +115,7 @@ class HttpDriver {
|
|||
$opt = (\PHP_MAJOR_VERSION >= 8 && \PHP_MINOR_VERSION >= 2) ? \CURLOPT_XFERINFOFUNCTION : \CURLOPT_PROGRESSFUNCTION;
|
||||
\curl_setopt_array($this->inner, [
|
||||
\CURLOPT_NOPROGRESS => false,
|
||||
$opt => fn($res, $next_dl, $dl, $next_up, $up) => (int)($dl <= $this->max_file_size),
|
||||
$opt => fn($res, $next_dl, $dl, $next_up, $up) => (int)($dl > $this->max_file_size),
|
||||
\CURLOPT_FAILONERROR => true,
|
||||
\CURLOPT_FOLLOWLOCATION => false,
|
||||
\CURLOPT_FILE => $fd,
|
||||
|
|
|
@ -16,11 +16,20 @@ class EmbedService {
|
|||
private int $thumb_download_timeout;
|
||||
|
||||
|
||||
public function __construct(LogDriver $log, OembedExtractor $oembed_extractor, array $embed_entries, int $thumb_download_timeout) {
|
||||
public function __construct(
|
||||
LogDriver $log,
|
||||
OembedExtractor $oembed_extractor,
|
||||
HttpDriver $http,
|
||||
array $embed_entries,
|
||||
int $thumb_download_timeout,
|
||||
string $tmp_dir,
|
||||
) {
|
||||
$this->log = $log;
|
||||
$this->oembed_extractor = $oembed_extractor;
|
||||
$this->http = $http;
|
||||
$this->embed_entries = $embed_entries;
|
||||
$this->thumb_download_timeout = $thumb_download_timeout;
|
||||
$this->tmp_dir = $tmp_dir;
|
||||
}
|
||||
|
||||
private function make_tmp_file(): string {
|
||||
|
@ -104,7 +113,7 @@ class EmbedService {
|
|||
public function getEmbedThumb(string $url, int $entry_index): ?array {
|
||||
$ret = $this->extractThumb($url, $entry_index);
|
||||
list($thumbnail_url, $thumbnail_url_fallback) = $ret;
|
||||
if (!isset($thumbnail_url, $thumbnail_url_fallback)) {
|
||||
if (!isset($thumbnail_url)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,8 +94,10 @@ function build_context(array $config): Context {
|
|||
return new EmbedService(
|
||||
$c->get(LogDriver::class),
|
||||
$c->get(OembedExtractor::class),
|
||||
$c->get(HttpDriver::class),
|
||||
$config['embedding_2'],
|
||||
$config['embed_thumb_timeout']
|
||||
$config['embed_thumb_timeout'],
|
||||
$config['tmp'],
|
||||
);
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue