Initial Commit
This commit is contained in:
commit
42b5da2e39
|
@ -0,0 +1,4 @@
|
|||
.idea/
|
||||
*.*~
|
||||
vendor/
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is a part of Hathor
|
||||
*
|
||||
* Command line script entry to interact with Hathor
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Sikofitt\Hathor;
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\Config;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Sikofitt\Hathor\Command\ScannerCommand;
|
||||
|
||||
|
||||
$app = new Application('Hathor', 'v0.0.1');
|
||||
$app->add(new ScannerCommand());
|
||||
$app->run();
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"require": {
|
||||
"symfony/finder": "^2.7",
|
||||
"symfony/console": "^2.7",
|
||||
"symfony/process": "^2.7",
|
||||
"symfony/validator": "^2.7",
|
||||
"symfony/event-dispatcher": "^2.7",
|
||||
"symfony/dependency-injection": "^2.7",
|
||||
"symfony/config": "^2.7",
|
||||
"symfony/yaml": "^2.7",
|
||||
"symfony/var-dumper": "^2.7",
|
||||
"psr/log":"~1",
|
||||
"james-heinrich/getid3": "^1.9",
|
||||
"doctrine/common": "^2.5",
|
||||
"doctrine/orm": "^2.5",
|
||||
"doctrine/dbal": "^2.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Sikofitt\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Sikofitt\\Tests\\":"src/Tests/"
|
||||
}
|
||||
},
|
||||
"prefer-stable":true,
|
||||
"license":"MIT",
|
||||
"require-dev": {
|
||||
"phpunit/phpunit":"@stable"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,58 @@
|
|||
<?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();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Sikofitt\Hathor\Common\Music;
|
||||
|
||||
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
|
||||
class ID3 extends \getID3
|
||||
{
|
||||
private $fileData;
|
||||
protected $file;
|
||||
|
||||
const IS_ASF = 0;
|
||||
const IS_ID3V1 = 1;
|
||||
const IS_ID3V2 = 2;
|
||||
const IS_VORBIS = 3;
|
||||
const IS_UNKNOWN = 4;
|
||||
|
||||
public function __construct($file = null) {
|
||||
parent::__construct();
|
||||
|
||||
if(!is_null($file))
|
||||
{
|
||||
$this->file = $file;
|
||||
}
|
||||
}
|
||||
public function setFile($file) {
|
||||
$this->file = $file;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getFile() {
|
||||
return $this->file ?: $this->file;
|
||||
}
|
||||
|
||||
public function getFileData() {
|
||||
|
||||
$this->fileData = $this->analyze($this->getFile());
|
||||
|
||||
if(isset($this->fileData['error']))
|
||||
{
|
||||
throw new \RuntimeException(implode(' ', $this->fileData['error']));
|
||||
} else {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
public function extractV2() {
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
public function extractV1() {
|
||||
|
||||
}
|
||||
public function extractAsf() {
|
||||
|
||||
}
|
||||
public function extractVorbis() {
|
||||
|
||||
}
|
||||
public function extractDefaultData() {
|
||||
switch($this->typeOfTag()) {
|
||||
case $this::IS_ID3V2:
|
||||
break;
|
||||
case $this::IS_ID3V1:
|
||||
break;
|
||||
case $this::IS_VORBIS:
|
||||
break;
|
||||
case $this::IS_ASF:
|
||||
break;
|
||||
case $this::IS_UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function typeOfTag() {
|
||||
|
||||
if($this->hasId3v2()) {
|
||||
return $this::IS_ID3V2;
|
||||
} elseif($this->hasId3v1()) {
|
||||
return $this::IS_ID3V1;
|
||||
} elseif($this->isAsf()) {
|
||||
return $this::IS_ASF;
|
||||
} else {
|
||||
return $this::IS_UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasId3v2() {
|
||||
return isset($this->fileData['id3v2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasId3v1() {
|
||||
return isset($this->fileData['id3v1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAsf() {
|
||||
return isset($this->fileData['asf']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function dumpAll() {
|
||||
if(isset($this->fileData)) {
|
||||
unset($this->fileData['tags']);
|
||||
unset($this->fileData['asf']);
|
||||
VarDumper::dump($this->fileData);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue