[IMP] php: About ready to send download data to python

refactor_total
Brett Spaulding 1 year ago
parent 3148378334
commit 45abbc823f

@ -32,7 +32,9 @@ class ArtistQueue extends Model
$artist_id = Artist::where('id', $this->artist_id)->get()->first();
if ($artist_id->count() > 0) {
try {
WebScraper::scrapeAlbums($driver, $artist_id);
$album_count = WebScraper::scrapeAlbums($driver, $artist_id);
$artist_id->album_count = $album_count;
$artist_id->save();
} catch (Exception $e) {
\Log::warning('Failed to scrape albums: ' . $e->getMessage());
} finally {

@ -110,7 +110,7 @@ class WebScraper
{
$url = 'https://music.youtube.com/' . $artist_id->url_remote;
$driver->get($url);
$response = [];
$response = 0;
$albumBtn = $driver->findElement(WebDriverBy::xpath('//a[text()="Albums"]'));
if ($albumBtn) {
$albumBtn->click();
@ -120,6 +120,7 @@ class WebScraper
$albumContainers = $item->findElements(WebDriverBy::cssSelector('.ytmusic-grid-renderer'));
if ($albumContainers) {
foreach ($albumContainers as $albumContainer) {
$response += 1;
$albumLink = $albumContainer->findElement(WebDriverBy::cssSelector('a'));
$albumHref = $albumLink->getAttribute('href');
$albumTitle = $albumLink->getAttribute('title');

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('artists', function (Blueprint $table) {
$table->integer('album_count')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('artists', function (Blueprint $table) {
//
});
}
};

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('artists', function (Blueprint $table) {
$table->integer('album_done')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('artists', function (Blueprint $table) {
//
});
}
};
Loading…
Cancel
Save