mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
EQBeats import script and db migration
This commit is contained in:
parent
df917890e3
commit
c6dc6aae32
4 changed files with 64 additions and 15 deletions
|
@ -101,7 +101,7 @@ class UploadTrackCommand extends CommandBase
|
||||||
|
|
||||||
if ($this->_file !== null) {
|
if ($this->_file !== null) {
|
||||||
$trackFile = $this->_file;
|
$trackFile = $this->_file;
|
||||||
$source = 'ponify';
|
$source = 'eqbeats';
|
||||||
} else {
|
} else {
|
||||||
$trackFile = Request::file('track', null);
|
$trackFile = Request::file('track', null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,22 +19,23 @@ use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
|
|
||||||
class ImportPonify extends Command
|
class ImportEQBeats extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ponify:import
|
protected $signature = 'eqbeats:import
|
||||||
{--startAt=1 : Track to start importing from. Useful for resuming an interrupted import.}';
|
{--startAt=1 : Track to start importing from. Useful for resuming an interrupted import.}
|
||||||
|
{archiveFolder : Absolute location of archive to import}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Imports the Ponify archive';
|
protected $description = 'Imports the EQBeats archive';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File extensions to ignore when importing the archive.
|
* File extensions to ignore when importing the archive.
|
||||||
|
@ -84,7 +85,7 @@ class ImportPonify extends Command
|
||||||
|
|
||||||
pcntl_signal(SIGINT, [$this, 'handleInterrupt']);
|
pcntl_signal(SIGINT, [$this, 'handleInterrupt']);
|
||||||
|
|
||||||
$ponifyPath = Config::get('ponyfm.ponify_directory');
|
$archivePath = $this->argument('archiveFolder');
|
||||||
$tmpPath = Config::get('ponyfm.files_directory').'/tmp';
|
$tmpPath = Config::get('ponyfm.files_directory').'/tmp';
|
||||||
|
|
||||||
if (!File::exists($tmpPath)) {
|
if (!File::exists($tmpPath)) {
|
||||||
|
@ -99,12 +100,12 @@ class ImportPonify extends Command
|
||||||
//==========================================================================================================
|
//==========================================================================================================
|
||||||
// Get the list of files and artists
|
// Get the list of files and artists
|
||||||
//==========================================================================================================
|
//==========================================================================================================
|
||||||
$this->comment('Enumerating Ponify files...');
|
$this->comment('Enumerating files...');
|
||||||
$files = File::allFiles($ponifyPath);
|
$files = File::allFiles($archivePath);
|
||||||
$this->info(sizeof($files) . ' files found!');
|
$this->info(sizeof($files) . ' files found!');
|
||||||
|
|
||||||
$this->comment('Enumerating artists...');
|
$this->comment('Enumerating artists...');
|
||||||
$artists = File::directories($ponifyPath);
|
$artists = File::directories($archivePath);
|
||||||
$this->info(sizeof($artists) . ' artists found!');
|
$this->info(sizeof($artists) . ' artists found!');
|
||||||
|
|
||||||
$this->comment('Importing tracks...');
|
$this->comment('Importing tracks...');
|
||||||
|
@ -496,7 +497,7 @@ class ImportPonify extends Command
|
||||||
$track->save();
|
$track->save();
|
||||||
|
|
||||||
// If we made it to here, the track is intact! Log the import.
|
// If we made it to here, the track is intact! Log the import.
|
||||||
DB::table('ponify_tracks')
|
DB::table('eqbeats_tracks')
|
||||||
->insert([
|
->insert([
|
||||||
'track_id' => $result->getResponse()['id'],
|
'track_id' => $result->getResponse()['id'],
|
||||||
'path' => $file->getRelativePath(),
|
'path' => $file->getRelativePath(),
|
|
@ -352,11 +352,11 @@ class TracksController extends ApiControllerBase
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($archive == "mlpma") {
|
$archives = ['mlpma', 'ponify', 'eqbeats'];
|
||||||
$query->join('mlpma_tracks', 'tracks.id', '=', 'mlpma_tracks.track_id');
|
$akey = array_search($archive, $archives);
|
||||||
} elseif ($archive == "ponify") {
|
|
||||||
$query->join('ponify_tracks', 'tracks.id', '=', 'ponify_tracks.track_id');
|
if (!$akey)
|
||||||
}
|
$query->join($archive . '_tracks', 'tracks.id', '=', $archive . 'tracks.track_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Request::has('songs')) {
|
if (Request::has('songs')) {
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateEQBeatsTracks extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('eqbeats_tracks', function(Blueprint $table)
|
||||||
|
{
|
||||||
|
$table->increments('id');
|
||||||
|
$table->integer('track_id')->unsigned()->index();
|
||||||
|
$table->string('path')->index();
|
||||||
|
$table->string('filename')->index();
|
||||||
|
$table->string('extension')->index();
|
||||||
|
$table->dateTime('imported_at');
|
||||||
|
$table->text('parsed_tags');
|
||||||
|
$table->text('raw_tags');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('eqbeats_tracks', function(Blueprint $table)
|
||||||
|
{
|
||||||
|
$table->foreign('track_id')->references('id')->on('tracks')->onUpdate('RESTRICT')->onDelete('RESTRICT');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('eqbeats_tracks', function(Blueprint $table)
|
||||||
|
{
|
||||||
|
$table->dropForeign('eqbeats_tracks_track_id_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::drop('eqbeats_tracks');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue