<?php
/*
 *
 */

namespace Sikofitt\Hathor\Command;

use Symfony\Component\Finder\Finder;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Command\Command as BaseCommand;
use Sikofitt\Hathor\Common\Music\ID3;

class ScannerCommand extends BaseCommand
{

    protected function configure()
    {
        $this
            ->setName('scan')
            ->setDescription('Scans Music')
            ->addArgument('file', InputArgument::OPTIONAL, 'the file to work on');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln("Please wait ...");
        $finder = new Finder();
        $finder
            ->files()
            ->in("/home/eric/Music")
            ->ignoreDotFiles(true)
            ->ignoreUnreadableDirs(true)
            ->ignoreVCS(true)
            ->sortByType()
            ->name("*.mp3")
            ->name("*.mp4")
            ->name("*.ogg")
            ->name("*.wma")
            ->name("*.mp2");
        $progress = new ProgressBar($output, $finder->count());
        $progress->setFormat("debug");
        $progress->start();
        foreach ($finder as $file) {
            $progress->setOverwrite(true);
            $progress->setMessage($file->getFilename());
            $progress->advance();
        }
        $progress->finish();
        $getID3 = new ID3;
        //$getID3->setFile($input->getArgument('file'))->getFileData()->dumpAll();

    }
}
