Skip to content

Instantly share code, notes, and snippets.

@yagihash
Created June 5, 2018 23:53
Show Gist options
  • Save yagihash/691ba83b020378830c3d28cb7a6587fb to your computer and use it in GitHub Desktop.
Save yagihash/691ba83b020378830c3d28cb7a6587fb to your computer and use it in GitHub Desktop.
雑にm3uのプレイリスト作るやつ。
<?php
$files = glob('*.m4a');
foreach($files as $file) {
$duration = `exiftool -Duration '{$file}' | cut -d ':' -f 3,4`;
$duration = explode(':', $duration);
$extinf = (int)$duration[0]*60 + (int)$duration[1];
$title = substr($file, 3, -4);
$album = basename(getcwd());
$artist = basename(dirname(getcwd(), 1));
printf('#EXTINF:%d,%s' . PHP_EOL, $extinf, $title);
printf('%s\%s\%s' . PHP_EOL, $artist, $album, $file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment