mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +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) {
|
||||
$trackFile = $this->_file;
|
||||
$source = 'ponify';
|
||||
$source = 'eqbeats';
|
||||
} else {
|
||||
$trackFile = Request::file('track', null);
|
||||
}
|
||||
|
|
|
@ -19,22 +19,23 @@ use Illuminate\Console\Command;
|
|||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class ImportPonify extends Command
|
||||
class ImportEQBeats extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ponify:import
|
||||
{--startAt=1 : Track to start importing from. Useful for resuming an interrupted import.}';
|
||||
protected $signature = 'eqbeats: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.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Imports the Ponify archive';
|
||||
protected $description = 'Imports the EQBeats archive';
|
||||
|
||||
/**
|
||||
* File extensions to ignore when importing the archive.
|
||||
|
@ -84,7 +85,7 @@ class ImportPonify extends Command
|
|||
|
||||
pcntl_signal(SIGINT, [$this, 'handleInterrupt']);
|
||||
|
||||
$ponifyPath = Config::get('ponyfm.ponify_directory');
|
||||
$archivePath = $this->argument('archiveFolder');
|
||||
$tmpPath = Config::get('ponyfm.files_directory').'/tmp';
|
||||
|
||||
if (!File::exists($tmpPath)) {
|
||||
|
@ -99,12 +100,12 @@ class ImportPonify extends Command
|
|||
//==========================================================================================================
|
||||
// Get the list of files and artists
|
||||
//==========================================================================================================
|
||||
$this->comment('Enumerating Ponify files...');
|
||||
$files = File::allFiles($ponifyPath);
|
||||
$this->comment('Enumerating files...');
|
||||
$files = File::allFiles($archivePath);
|
||||
$this->info(sizeof($files) . ' files found!');
|
||||
|
||||
$this->comment('Enumerating artists...');
|
||||
$artists = File::directories($ponifyPath);
|
||||
$artists = File::directories($archivePath);
|
||||
$this->info(sizeof($artists) . ' artists found!');
|
||||
|
||||
$this->comment('Importing tracks...');
|
||||
|
@ -496,7 +497,7 @@ class ImportPonify extends Command
|
|||
$track->save();
|
||||
|
||||
// If we made it to here, the track is intact! Log the import.
|
||||
DB::table('ponify_tracks')
|
||||
DB::table('eqbeats_tracks')
|
||||
->insert([
|
||||
'track_id' => $result->getResponse()['id'],
|
||||
'path' => $file->getRelativePath(),
|
|
@ -352,11 +352,11 @@ class TracksController extends ApiControllerBase
|
|||
}
|
||||
});
|
||||
|
||||
if ($archive == "mlpma") {
|
||||
$query->join('mlpma_tracks', 'tracks.id', '=', 'mlpma_tracks.track_id');
|
||||
} elseif ($archive == "ponify") {
|
||||
$query->join('ponify_tracks', 'tracks.id', '=', 'ponify_tracks.track_id');
|
||||
}
|
||||
$archives = ['mlpma', 'ponify', 'eqbeats'];
|
||||
$akey = array_search($archive, $archives);
|
||||
|
||||
if (!$akey)
|
||||
$query->join($archive . '_tracks', 'tracks.id', '=', $archive . 'tracks.track_id');
|
||||
}
|
||||
|
||||
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