Optimize search for videos and change location for video thumbnails
This commit is contained in:
parent
0b4457ccb4
commit
532db59b6e
|
@ -25,12 +25,7 @@ const ViewsFormat = ViewsConversion.format(Views)
|
|||
|
||||
<a href={'/watch?v=' + ID} class="video-item" data-astro-reload>
|
||||
<div class="video-item-thumbnail">
|
||||
<img onload=`
|
||||
if (this.naturalWidth == '120') {
|
||||
src='https://md.sudovanilla.org/images/pt-th-fl.png'
|
||||
}
|
||||
`
|
||||
src={'https://i.ytimg.com/vi/' + ID + '/maxresdefault.jpg'}/>
|
||||
<img src={'https://yt.sudovanilla.org/vi/' + ID + '/hqdefault.jpg'}/>
|
||||
</div>
|
||||
<div class="video-item-details">
|
||||
<p id="vi-title">{Title}</p>
|
||||
|
@ -39,10 +34,6 @@ const ViewsFormat = ViewsConversion.format(Views)
|
|||
</div>
|
||||
</a>
|
||||
|
||||
<script is:inline>
|
||||
document.querySelectorAll("img[src='https://i.ytimg.com/vi/undefined/maxresdefault.jpg']").forEach(img => {img.src='https://md.sudovanilla.org/images/pt-th-fl.png'})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.video-item {
|
||||
display: flex;
|
||||
|
@ -56,6 +47,7 @@ document.querySelectorAll("img[src='https://i.ytimg.com/vi/undefined/maxresdefau
|
|||
aspect-ratio: 16/9;
|
||||
object-fit: contain;
|
||||
background: #cfcfcf;
|
||||
object-fit: cover;
|
||||
}
|
||||
p#vi-length {
|
||||
margin: -41px 8px 0px 0px;
|
||||
|
|
|
@ -13,7 +13,7 @@ const DEFAULT_SAFETWITCH_BACKEND = import.meta.env.DEFAULT_SAFETWITCH_BACKEND
|
|||
|
||||
// Fetch
|
||||
const Query = Astro.url.href.split("search?q=").pop()
|
||||
const InvidiousResponse = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/search?q=" + Query)
|
||||
const InvidiousVideosResponse = await fetch('https://' + DEFAULT_INVIDIOUS_INSTANCE + "/api/v1/search?q=" + Query + '&type=video')
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
|
@ -27,7 +27,7 @@ const TwitchResponse = await fetch('https://' + DEFAULT_SAFETWITCH_BACKEND + "/a
|
|||
console.log(error)
|
||||
})
|
||||
|
||||
const InvidiousData = await InvidiousResponse.json()
|
||||
const InvidiousVideosData = await InvidiousVideosResponse.json()
|
||||
const InvidiousChannelsData = await InvidiousChannelsResponse.json()
|
||||
const TwitchData = await TwitchResponse.json()
|
||||
---
|
||||
|
@ -77,7 +77,7 @@ const TwitchData = await TwitchResponse.json()
|
|||
</div>
|
||||
<p>YouTube Videos</p>
|
||||
<div class="video-grid">
|
||||
{InvidiousData.map((data) =>
|
||||
{InvidiousVideosData.map((data) =>
|
||||
<Video
|
||||
ID={data.videoId}
|
||||
Title={data.title}
|
||||
|
|
Reference in a new issue