[FIX] php: YT CDN to local files

Very shotty chance at getting the images from the cdn for some reason.
main
Brett Spaulding 1 year ago
parent 5de3803c55
commit 3c11270d4e

@ -141,8 +141,8 @@ services:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=1
- SE_NODE_MAX_SESSION=1
- SE_NODE_MAX_SESSIONS=2
- SE_NODE_MAX_SESSION=2
# edge:
# image: selenium/node-edge:nightly

@ -24,7 +24,7 @@ class ApiController extends Controller
'name' => $artist->name,
'url_remote' => $artist->url_remote,
'state' => $artist->state,
'thumbnail' => $artist->thumbnail,
'thumbnail' => str_replace('/var/www/html/public', '', $artist->image),
];
}
$response = json_encode(array('data' => $data));
@ -43,8 +43,8 @@ class ApiController extends Controller
'name' => $album->name,
'artist_id' => $artist->toArray(),
'url_remote' => $album->url_remote,
'thumbnail' => $album->thumbnail,
'image' => $album->image,
'thumbnail' => str_replace('/var/www/html/public', '', $album->image),
'image' => str_replace('/var/www/html/public', '', $album->image),
'state' => $queue->state,
];
}

@ -21,6 +21,11 @@ class Album extends Model
$this->save();
}
public function getAlbumImageLocation()
{
return str_replace('/var/www/html', '', $this->image);
}
public static function findByArtistTitle(Artist $artist, string $name)
{
return self::where('name', '=', $name)->where('artist_id', '=', $artist->id)->first();

@ -30,6 +30,11 @@ class Artist extends Model
return self::where('id', '=', $id)->get();
}
public function getArtistImageLocation()
{
return str_replace('/var/www/html', '', $this->image);
}
public static function addArtist(string $name, string $thumbnail, string $url_remote, string $image)
{
$artist = new Artist();

@ -117,7 +117,7 @@ class WebScraper
'name' => $albumTitle,
'artist_id' => $artist->id,
'thumbnail' => $albumThumbnail,
'url_remote' => $albumHref,
'url_remote' => $albumHref, // TODO: Check here if the image is a 'gif' and not a URL
'image' => $imageFileUrl,
];
$album_id = Album::findOrCreateByName($artist, $albumTitle, $data);
@ -167,8 +167,6 @@ class WebScraper
for ($i = 0; $i <= 3; $i++) {
if ($caroselNextButton[0]->isEnabled()) {
$action = $driver->action();
$script = "arguments[0].scrollIntoView();";
$driver->executeScript($script, $caroselNextButton);
$action->moveToElement($caroselNextButton[0])->click()->perform();
sleep(5);
}

@ -13,12 +13,14 @@ function requestQueue() {
}
function template_artist_result(element) {
let image_src = element.image.replace('/var/www/html/public', '');
console.log(image_src);
return `
<div class="card w-100 p-2 mb-2">
<div class="container-fluid">
<div class="row">
<div class="col-3">
<img src="${element.thumbnail}" width="72px" height="72px" style="border-radius: 12px;"/>
<img src="${image_src}" width="72px" height="72px" style="border-radius: 12px;"/>
</div>
<div class="col-9 m-auto">
<h4>${element.name}</h4>
@ -88,39 +90,32 @@ function bind_action_buttons() {
});
$('#download_btn').on('click', () => {
loader.fadeIn(300);
let artist = $('#search_bar').val();
// Send request to server
setTimeout(() => {
if (artist) {
console.log('Sending search request...');
if (artist == '') {
return proc_notification('error', 'Whoopsie!', 'You need to add an artist, c\'mon man!');;
}
loader.fadeIn(300);
$.ajax({
url: `/artist/${artist}`,
success: (response) => {
console.log('Receiving response...');
console.log(response);
console.log('===========');
icon = 'success';
let html = construct_artist_result_html(response);
proc_notification(icon, 'Shazam!', html);
proc_notification('success', 'Shazam!', html);
ArtistTable.ajax.reload();
$('#search_bar').val('');
loader.fadeOut(700);
},
error: (response) => {
console.log('Receiving response...');
console.log(response);
console.log('===========');
proc_notification(icon, 'What the flip?!', response.statusText);
proc_notification('error', 'What the flip?!', response.statusText);
loader.fadeOut(700);
}
});
} else {
proc_notification(icon, 'Whoopsie!', 'You need to add an artist, c\'mon man!');
loader.fadeOut(700);
}
}, 10);
});

@ -17,7 +17,7 @@
</div>
</template>
<!-- Album Art -->
<img :src="album.thumbnail" class="img-fluid rounded-start"
<img :src="album.image" class="img-fluid rounded-start"
:alt="album.name" style="width: 100%; height: 100%; min-height: 180px;">
</div>

Loading…
Cancel
Save