Skip to content

Commit b69a204

Browse files
committed
Merge branch 'release/1.2.5' into v1
2 parents 139f196 + 2e9a38b commit b69a204

File tree

9 files changed

+106
-88
lines changed

9 files changed

+106
-88
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Transcoder Changelog
22

3+
## 1.2.5 - 2019.05.23
4+
### Changed
5+
* Updated build system
6+
7+
## 1.2.4 - 2019.04.22
8+
### Changed
9+
* Updated Twig namespacing to be compliant with deprecated class aliases in 2.7.x
10+
311
## 1.2.3 - 2019.03.20
412
### Changed
513
* Allow setting threads in config

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft-transcoder",
33
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
44
"type": "craft-plugin",
5-
"version": "1.2.3",
5+
"version": "1.2.5",
66
"keywords": [
77
"craft",
88
"cms",
@@ -17,8 +17,8 @@
1717
"format"
1818
],
1919
"support": {
20-
"docs": "https://github.com/nystudio107/craft-transcoder/blob/v1/README.md",
21-
"issues": "https://github.com/nystudio107/craft-transcoder/issues"
20+
"docs": "https://nystudio107.com/plugins/transcoder/documentation",
21+
"issues": "https://nystudio107.com/plugins/transcoder/support"
2222
},
2323
"license": "proprietary",
2424
"authors": [

package.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
"name": "transcoder",
33
"version": "1.0.0",
44
"description": "Transcode video & audio files to various formats, and provide video thumbnails",
5-
"copyright": "nystudio107",
6-
"main": "index.js",
7-
"scripts": {
8-
"dev": "webpack-dev-server --config webpack.dev.js --progress --hide-modules",
9-
"build": "webpack --config webpack.prod.js"
5+
"keywords": [],
6+
"homepage": "https://nystudio107.com/plugins/transcoder",
7+
"bugs": {
8+
"email": "info@nystudio107.com",
9+
"url": "https://nystudio107.com/plugins/transcoder/support"
10+
},
11+
"license": "SEE LICENSE IN LICENSE.md",
12+
"author": {
13+
"name": "Andrew Welch",
14+
"email": "andrew@nystudio107.com",
15+
"url": "https://nystudio107.com/"
1016
},
17+
"browser": "./src/Transcoder.php",
1118
"repository": {
1219
"type": "git",
1320
"url": "git+https://github.com/nystudio107/craft-transcoder.git"
1421
},
15-
"author": "andrew@nystudio107.com",
16-
"license": "proprietary",
17-
"bugs": {
18-
"url": "https://github.com/nystudio107/craft-transcoder/issues"
22+
"private": true,
23+
"scripts": {
24+
"dev": "webpack-dev-server --config webpack.dev.js --progress --hide-modules",
25+
"build": "webpack --config webpack.prod.js"
1926
},
20-
"homepage": "https://github.com/nystudio107/craft-transcoder",
2127
"paths": {
2228
"src": {
2329
"base": "./src/assetbundles/transcoder/src/",

src/Transcoder.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
use yii\base\ErrorException;
3535
use yii\base\Event;
36-
use yii\base\InvalidArgumentException;
3736

3837
/**
3938
* Class Transcode
@@ -90,7 +89,7 @@ public function init()
9089
*/
9190
public function clearAllCaches()
9291
{
93-
$transcoderPaths = Transcoder::$plugin->getSettings()->transcoderPaths;
92+
$transcoderPaths = self::$plugin->getSettings()->transcoderPaths;
9493

9594
foreach ($transcoderPaths as $key => $value) {
9695
$dir = Craft::getAlias($value);

src/models/Settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Settings extends Model
5050
* The path where the transcoded videos are stored; must have a trailing /
5151
* Yii2 aliases are supported here
5252
*
53-
* @var string
53+
* @var array
5454
*/
5555
public $transcoderPaths = [
5656
'default' => '@webroot/transcoder/',
@@ -63,7 +63,7 @@ class Settings extends Model
6363
* The URL where the transcoded videos are stored; must have a trailing /
6464
* Yii2 aliases are supported here
6565
*
66-
* @var string
66+
* @var array
6767
*/
6868
public $transcoderUrls = [
6969
'default' => '@web/transcoder/',

src/services/Transcode.php

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,34 @@ class Transcode extends Component
8181
// =========================================================================
8282

8383
/**
84-
* Returns a URL to the transcoded video or "" if it doesn't exist (at which
84+
* Returns a URL to the transcoded video or "" if it doesn't exist (at
85+
* which
8586
* time it will create it).
8687
*
87-
* @param $filePath string path to the original video -OR- an Asset
88-
* @param $videoOptions array of options for the video
89-
* @param bool $generate whether the video should be encoded
88+
* @param $filePath string path to the original video -OR- an
89+
* Asset
90+
* @param $videoOptions array of options for the video
91+
* @param bool $generate whether the video should be encoded
9092
*
9193
* @return string URL of the transcoded video or ""
9294
*/
9395
public function getVideoUrl($filePath, $videoOptions, $generate = true): string
9496
{
95-
9697
$result = '';
9798
$settings = Transcoder::$plugin->getSettings();
98-
$subfolder = '';
99-
100-
// sub folder check
101-
if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
102-
$subfolder = $filePath->folderPath;
103-
}
104-
105-
// file path
99+
$subfolder = '';
100+
101+
// sub folder check
102+
if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
103+
$subfolder = $filePath->folderPath;
104+
}
105+
106+
// file path
106107
$filePath = $this->getAssetPath($filePath);
107-
108+
108109
if (!empty($filePath)) {
109-
$destVideoPath = $settings['transcoderPaths']['video'] . $subfolder ?? $settings['transcoderPaths']['default'];
110-
$destVideoPath = Craft::getAlias($destVideoPath);
110+
$destVideoPath = $settings['transcoderPaths']['video'].$subfolder ?? $settings['transcoderPaths']['default'];
111+
$destVideoPath = Craft::getAlias($destVideoPath);
111112
$videoOptions = $this->coalesceOptions('defaultVideoOptions', $videoOptions);
112113

113114
// Get the video encoder presets to use
@@ -198,12 +199,11 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
198199

199200
// If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
200201
if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
201-
$url = $settings['transcoderUrls']['video'] . $subfolder ?? $settings['transcoderUrls']['default'];
202+
$url = $settings['transcoderUrls']['video'].$subfolder ?? $settings['transcoderUrls']['default'];
202203
$result = Craft::getAlias($url).$destVideoFile;
203-
204-
// skip encoding
204+
// skip encoding
205205
} elseif (!$generate) {
206-
$result = "";
206+
$result = "";
207207
} else {
208208
// Kick off the transcoding
209209
$pid = $this->executeShellCommand($ffmpegCmd);
@@ -229,20 +229,20 @@ public function getVideoUrl($filePath, $videoOptions, $generate = true): string
229229
* @return string|false|null URL or path of the video thumbnail
230230
*/
231231
public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = true, $asPath = false)
232-
{
232+
{
233233
$result = null;
234234
$settings = Transcoder::$plugin->getSettings();
235-
$subfolder = '';
236-
237-
// sub folder check
238-
if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
239-
$subfolder = $filePath->folderPath;
240-
}
241-
235+
$subfolder = '';
236+
237+
// sub folder check
238+
if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
239+
$subfolder = $filePath->folderPath;
240+
}
241+
242242
$filePath = $this->getAssetPath($filePath);
243243

244244
if (!empty($filePath)) {
245-
$destThumbnailPath = $settings['transcoderPaths']['thumbnail'] . $subfolder ?? $settings['transcoderPaths']['default'];
245+
$destThumbnailPath = $settings['transcoderPaths']['thumbnail'].$subfolder ?? $settings['transcoderPaths']['default'];
246246
$destThumbnailPath = Craft::getAlias($destThumbnailPath);
247247

248248
$thumbnailOptions = $this->coalesceOptions('defaultThumbnailOptions', $thumbnailOptions);
@@ -286,12 +286,11 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
286286
/** @noinspection PhpUnusedLocalVariableInspection */
287287
$shellOutput = $this->executeShellCommand($ffmpegCmd);
288288
Craft::info($ffmpegCmd, __METHOD__);
289-
289+
290290
// if ffmpeg fails which we can't check because the process is ran in the background
291-
// dont return the future path of the image or else we can't check this in the front end
291+
// dont return the future path of the image or else we can't check this in the front end
292292

293-
return false;
294-
293+
return false;
295294
} else {
296295
Craft::info('Thumbnail does not exist, but not asked to generate it: '.$filePath, __METHOD__);
297296

@@ -303,7 +302,7 @@ public function getVideoThumbnailUrl($filePath, $thumbnailOptions, $generate = t
303302
if ($asPath) {
304303
$result = $destThumbnailPath;
305304
} else {
306-
$url = $settings['transcoderUrls']['thumbnail'] . $subfolder ?? $settings['transcoderUrls']['default'];
305+
$url = $settings['transcoderUrls']['thumbnail'].$subfolder ?? $settings['transcoderUrls']['default'];
307306
$result = Craft::getAlias($url).$destThumbnailFile;
308307
}
309308
}
@@ -324,17 +323,17 @@ public function getAudioUrl($filePath, $audioOptions): string
324323
{
325324
$result = '';
326325
$settings = Transcoder::$plugin->getSettings();
327-
$subfolder = '';
328-
329-
// sub folder check
330-
if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
331-
$subfolder = $filePath->folderPath;
332-
}
333-
326+
$subfolder = '';
327+
328+
// sub folder check
329+
if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
330+
$subfolder = $filePath->folderPath;
331+
}
332+
334333
$filePath = $this->getAssetPath($filePath);
335334

336335
if (!empty($filePath)) {
337-
$destAudioPath = $settings['transcoderPaths']['audio'] . $subfolder ?? $settings['transcoderPaths']['default'];
336+
$destAudioPath = $settings['transcoderPaths']['audio'].$subfolder ?? $settings['transcoderPaths']['default'];
338337
$destAudioPath = Craft::getAlias($destAudioPath);
339338

340339
$audioOptions = $this->coalesceOptions('defaultAudioOptions', $audioOptions);
@@ -404,7 +403,7 @@ public function getAudioUrl($filePath, $audioOptions): string
404403

405404
// If the audio file already exists and hasn't been modified, return it. Otherwise, start it transcoding
406405
if (file_exists($destAudioPath) && (@filemtime($destAudioPath) >= @filemtime($filePath))) {
407-
$url = $settings['transcoderUrls']['audio'] . $subfolder ?? $settings['transcoderUrls']['default'];
406+
$url = $settings['transcoderUrls']['audio'].$subfolder ?? $settings['transcoderUrls']['default'];
408407
$result = Craft::getAlias($url).$destAudioFile;
409408
} else {
410409
// Kick off the transcoding
@@ -580,8 +579,8 @@ public function handleGetAssetThumbPath(AssetThumbEvent $event)
580579
/**
581580
* Returns a URL to a encoded GIF file (mp4)
582581
*
583-
* @param string $filePath path to the original video or an Asset
584-
* @param array $gifOptions of options for the GIF file
582+
* @param string $filePath path to the original video or an Asset
583+
* @param array $gifOptions of options for the GIF file
585584
*
586585
* @return string|false|null URL or path of the GIF file
587586
*/
@@ -590,18 +589,18 @@ public function getGifUrl($filePath, $gifOptions): string
590589
{
591590
$result = '';
592591
$settings = Transcoder::$plugin->getSettings();
593-
$subfolder = '';
594-
595-
// sub folder check
596-
if(\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
597-
$subfolder = $filePath->folderPath;
598-
}
599-
592+
$subfolder = '';
593+
594+
// sub folder check
595+
if (\is_object($filePath) && ($filePath instanceof Asset) && $settings['createSubfolders']) {
596+
$subfolder = $filePath->folderPath;
597+
}
598+
600599
$filePath = $this->getAssetPath($filePath);
601600

602601
if (!empty($filePath)) {
603602
// Dest path
604-
$destVideoPath = $settings['transcoderPaths']['gif'] . $subfolder ?? $settings['transcoderPaths']['default'];
603+
$destVideoPath = $settings['transcoderPaths']['gif'].$subfolder ?? $settings['transcoderPaths']['default'];
605604
$destVideoPath = Craft::getAlias($destVideoPath);
606605

607606
// Options
@@ -655,7 +654,7 @@ public function getGifUrl($filePath, $gifOptions): string
655654

656655
// If the video file already exists and hasn't been modified, return it. Otherwise, start it transcoding
657656
if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
658-
$url = $settings['transcoderUrls']['gif'] . $subfolder ?? $settings['transcoderUrls']['default'];
657+
$url = $settings['transcoderUrls']['gif'].$subfolder ?? $settings['transcoderUrls']['default'];
659658
$result = Craft::getAlias($url).$destVideoFile;
660659
} else {
661660
// Kick off the transcoding
@@ -741,14 +740,14 @@ protected function getAssetPath($filePath): string
741740
// If it's local, get a path to the file
742741
if ($assetVolume instanceof Local) {
743742
$sourcePath = rtrim($assetVolume->path, DIRECTORY_SEPARATOR);
744-
$sourcePath .= '' === $sourcePath ? '': DIRECTORY_SEPARATOR;
743+
$sourcePath .= '' === $sourcePath ? '' : DIRECTORY_SEPARATOR;
745744
$folderPath = '';
746745
try {
747746
$folderPath = rtrim($asset->getFolder()->path, DIRECTORY_SEPARATOR);
748747
} catch (InvalidConfigException $e) {
749748
Craft::error($e->getMessage(), __METHOD__);
750749
}
751-
$folderPath .= '' === $folderPath ? '': DIRECTORY_SEPARATOR;
750+
$folderPath .= '' === $folderPath ? '' : DIRECTORY_SEPARATOR;
752751

753752
$filePath = $sourcePath.$folderPath.$asset->filename;
754753
} else {

src/translations/en/transcoder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
return [
1717
'Transcoder caches' => 'Transcoder caches',
1818
'{name} plugin loaded' => '{name} plugin loaded',
19-
'{name} cache directory cleared' => '{name} cache directory cleared'
19+
'{name} cache directory cleared' => '{name} cache directory cleared',
20+
'Manifest file not found at: {manifestPath}' => 'Manifest file not found at: {manifestPath}',
21+
'Module does not exist in the manifest: {moduleName}' => 'Module does not exist in the manifest: {moduleName}'
2022
];

0 commit comments

Comments
 (0)