Skip to content

Commit

Permalink
Merge pull request #42 from Kunstmaan/feature/fixes-for-new-bundles-m…
Browse files Browse the repository at this point in the history
…igration

check if pdf files still exists before transforming + do not fail on rem...
  • Loading branch information
Wim Vandersmissen committed Oct 30, 2014
2 parents c3dee51 + 2edda08 commit 9e3fffc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions src/Kunstmaan/MediaBundle/Helper/RemoteVideo/RemoteVideoHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,27 @@ public function prepareMedia(Media $media)
$video->setThumbnailUrl('http://img.youtube.com/vi/' . $code . '/0.jpg');
break;
case 'vimeo':
$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $code . '.xml');
$video->setThumbnailUrl((string) $xml->video->thumbnail_large);
try {
$xml = simplexml_load_file('http://vimeo.com/api/v2/video/' . $code . '.xml');
$video->setThumbnailUrl((string) $xml->video->thumbnail_large);
} catch (\Exception $e) {

}
break;
case 'dailymotion':
$json = json_decode(
file_get_contents('https://api.dailymotion.com/video/' . $code . '?fields=thumbnail_large_url')
);
$thumbnailUrl = $json->{'thumbnail_large_url'};
/* dirty hack to fix urls for imagine */
if (!$this->endsWith($thumbnailUrl, '.jpg') && !$this->endsWith($thumbnailUrl, '.png')) {
$thumbnailUrl = $thumbnailUrl . '&ext=.jpg';
try {
$json = json_decode(
file_get_contents('https://api.dailymotion.com/video/' . $code . '?fields=thumbnail_large_url')
);
$thumbnailUrl = $json->{'thumbnail_large_url'};
/* dirty hack to fix urls for imagine */
if (!$this->endsWith($thumbnailUrl, '.jpg') && !$this->endsWith($thumbnailUrl, '.png')) {
$thumbnailUrl = $thumbnailUrl . '&ext=.jpg';
}
$video->setThumbnailUrl($thumbnailUrl);
} catch (\Exception $e) {

}
$video->setThumbnailUrl($thumbnailUrl);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function apply($absolutePath)
{
$info = pathinfo($absolutePath);

if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf')) {
if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf') && file_exists($absolutePath)) {
// If it doesn't exist yet, extract the first page of the PDF
$previewFilename = $this->getPreviewFilename($absolutePath);
if (!file_exists($previewFilename)) {
Expand Down

0 comments on commit 9e3fffc

Please sign in to comment.