[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_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442 - SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443 - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=1 - SE_NODE_MAX_SESSIONS=2
- SE_NODE_MAX_SESSION=1 - SE_NODE_MAX_SESSION=2
# edge: # edge:
# image: selenium/node-edge:nightly # image: selenium/node-edge:nightly

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

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

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

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

@ -17,7 +17,7 @@
</div> </div>
</template> </template>
<!-- Album Art --> <!-- 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;"> :alt="album.name" style="width: 100%; height: 100%; min-height: 180px;">
</div> </div>

Loading…
Cancel
Save