mirror of
https://github.com/jgonyea/grav-plugin-podcast.git
synced 2025-12-05 16:00:02 +01:00
v1.0.0 Audio duration now calculated via getid3
This commit is contained in:
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,5 +1,19 @@
|
||||
# v1.0.0
|
||||
## 07/12/2017
|
||||
|
||||
1. [](#new)
|
||||
* Audio duration now calculated via get-id3 Grav plugin
|
||||
* Dependencies added to blueprints.yaml
|
||||
|
||||
2. [](#improved)
|
||||
* Unessential GUID PHP functions removed
|
||||
|
||||
3. [](#bugfix)
|
||||
* Spacing for duration meta data insertion fixed
|
||||
|
||||
# v0.9.2
|
||||
## 07/11/2017
|
||||
|
||||
1. [](#new)
|
||||
|
||||
2. [](#improved)
|
||||
|
||||
@@ -78,7 +78,5 @@ These should be created as child pages of a podcast channel. Note: Episodes won
|
||||
|
||||
## To Do
|
||||
|
||||
- [ID3 integration](http://getid3.sourceforge.net/)
|
||||
- Better media player integration (playlist?)
|
||||
- Fix incorrect <itunes:duration> and partials length calculation
|
||||
- Set podcast meta field validations as required
|
||||
@@ -11,6 +11,10 @@ bugs: https://github.com/jgonyea/grav-plugin-podcast/issues
|
||||
docs: https://github.com/jgonyea/grav-plugin-podcast/blob/develop/README.md
|
||||
license: MIT
|
||||
|
||||
dependencies:
|
||||
- github: https://github.com/jgonyea/grav-plugin-get-id3
|
||||
- feed
|
||||
|
||||
form:
|
||||
validation: strict
|
||||
fields:
|
||||
|
||||
@@ -41,6 +41,3 @@ form:
|
||||
accept:
|
||||
- .mp3
|
||||
help: Upload the MP3 audio file here
|
||||
header.podcast.guid:
|
||||
type: hidden
|
||||
data-default@: '\Grav\Plugin\PodcastPlugin::generateGuid'
|
||||
|
||||
24
podcast.php
24
podcast.php
@@ -6,6 +6,7 @@ use Grav\Common\Plugin;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
use RocketTheme\Toolbox\File\File;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Grav\Plugin\GetID3Plugin;
|
||||
|
||||
/**
|
||||
* Class PodcastPlugin
|
||||
@@ -77,7 +78,7 @@ class PodcastPlugin extends Plugin
|
||||
$page = $this->grav['page'];
|
||||
$header = $page->header();
|
||||
// Only process podcast pages with audio attached.
|
||||
if (isset($header->podcast['audio']) && $page->name() == 'podcast-episode.md') {
|
||||
if (!empty($header->podcast['audio']) && $page->name() == 'podcast-episode.md') {
|
||||
// Find array key for podcast audio.
|
||||
$key = array_keys($header->podcast['audio']);
|
||||
|
||||
@@ -90,7 +91,7 @@ class PodcastPlugin extends Plugin
|
||||
$duration = $this->retreiveAudioDuration($key[0]);
|
||||
$raw = $file->raw();
|
||||
$orig = "type: audio/mpeg\n";
|
||||
$replace = $orig . " duration: $duration\n";
|
||||
$replace = $orig . " duration: $duration\n";
|
||||
$raw = str_replace($orig, $replace, $raw);
|
||||
|
||||
$file->save($raw);
|
||||
@@ -109,21 +110,8 @@ class PodcastPlugin extends Plugin
|
||||
*/
|
||||
public static function retreiveAudioDuration($file)
|
||||
{
|
||||
//todo: change fixed value to calcuated one.
|
||||
return "2:30";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate GUID for podcast entry.
|
||||
*/
|
||||
public static function generateGuid($length = 20, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
||||
{
|
||||
$str = '';
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$str .= $keyspace[random_int(0, $max)];
|
||||
}
|
||||
return $str;
|
||||
$id3 = GetID3Plugin::analyzeFile($file);
|
||||
return ($id3['playtime_string']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +157,7 @@ class PodcastPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user