adds thumbnail download to media ingester
This commit is contained in:
parent
ded1d57d16
commit
76e5b24bdc
|
@ -9,6 +9,8 @@ video and audio media.
|
||||||
cd ./modules
|
cd ./modules
|
||||||
https://git.hangar.org/arcHIVE-tech/ArchiveOrg/archive/main.zip
|
https://git.hangar.org/arcHIVE-tech/ArchiveOrg/archive/main.zip
|
||||||
unzip main.zip
|
unzip main.zip
|
||||||
|
mv archiveorg/ ArchiveOrg
|
||||||
|
rm main.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
## LISENCE
|
## LISENCE
|
||||||
|
|
|
@ -5,16 +5,20 @@ use Omeka\Api\Request;
|
||||||
use Omeka\Entity\Media;
|
use Omeka\Entity\Media;
|
||||||
use Omeka\Media\Ingester\IngesterInterface;
|
use Omeka\Media\Ingester\IngesterInterface;
|
||||||
use Omeka\Stdlib\ErrorStore;
|
use Omeka\Stdlib\ErrorStore;
|
||||||
|
use Omeka\File\Downloader;
|
||||||
use Zend\Form\Element\Text;
|
use Zend\Form\Element\Text;
|
||||||
use Zend\Http\Client;
|
use Zend\Http\Client;
|
||||||
use Zend\View\Renderer\PhpRenderer;
|
use Zend\View\Renderer\PhpRenderer;
|
||||||
|
|
||||||
class ArchiveOrgMediaIngester implements IngesterInterface
|
class ArchiveOrgMediaIngester implements IngesterInterface
|
||||||
{
|
{
|
||||||
|
protected $downloader;
|
||||||
protected $client;
|
protected $client;
|
||||||
public function __construct($client)
|
|
||||||
|
public function __construct($client, Downloader $downloader)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
$this->downloader = $downloader;
|
||||||
}
|
}
|
||||||
public function getLabel()
|
public function getLabel()
|
||||||
{
|
{
|
||||||
|
@ -43,7 +47,16 @@ class ArchiveOrgMediaIngester implements IngesterInterface
|
||||||
$errorStore->addError('o:identifier', 'No identifier specified');
|
$errorStore->addError('o:identifier', 'No identifier specified');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$url = 'https://archive.org/embed/' . $data['o:identifier'];
|
$identifier = trim($data['o:identifier']);
|
||||||
|
$mediaData = ['identifier' => $identifier];
|
||||||
|
|
||||||
|
$url = 'https://archive.org/embed/' . $identifier;
|
||||||
|
$thumbnail_url = 'https://archive.org/services/img/' . $identifier;
|
||||||
|
$tempFile = $this->downloader->download($thumbnail_url);
|
||||||
|
if ($tempFile) {
|
||||||
|
$tempFile->mediaIngestFile($media, $request, $errorStore, false);
|
||||||
|
}
|
||||||
|
$media->setData($mediaData);
|
||||||
$media->setSource($url);
|
$media->setSource($url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ class ArchiveOrgMediaFactory implements FactoryInterface
|
||||||
$requestedName,
|
$requestedName,
|
||||||
array $options = null)
|
array $options = null)
|
||||||
{
|
{
|
||||||
return new ArchiveOrgMediaIngester($services->get('Omeka\HttpClient'));
|
return new ArchiveOrgMediaIngester(
|
||||||
|
$services->get('Omeka\HttpClient'),
|
||||||
|
$services->get('Omeka\File\Downloader')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue