2020-12-09 19:03:29 +05:30
|
|
|
<template>
|
|
|
|
<h1 class="uk-text-center">
|
|
|
|
{{ $route.query.search_query }}
|
|
|
|
</h1>
|
|
|
|
|
2021-09-22 03:28:25 +05:30
|
|
|
<label for="ddlSearchFilters"><b>{{ $t("actions.filter") }}: </b></label>
|
2021-06-15 01:15:19 +05:30
|
|
|
<select
|
2021-09-06 03:01:46 +05:30
|
|
|
id="ddlSearchFilters"
|
2021-06-15 01:15:19 +05:30
|
|
|
default="all"
|
|
|
|
class="uk-select uk-width-auto"
|
|
|
|
style="height: 100%"
|
|
|
|
v-model="selectedFilter"
|
|
|
|
@change="updateResults()"
|
|
|
|
>
|
|
|
|
<option v-bind:key="filter" v-for="filter in availableFilters" v-bind:value="filter">
|
|
|
|
{{ filter.replace("_", " ") }}
|
|
|
|
</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
2020-12-09 19:03:29 +05:30
|
|
|
<div v-if="results" class="uk-grid-xl" uk-grid="parallax: 0">
|
|
|
|
<div
|
2021-06-29 01:15:03 +05:30
|
|
|
:style="[{ background: backgroundColor }]"
|
2020-12-09 19:03:29 +05:30
|
|
|
class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl"
|
|
|
|
v-bind:key="result.url"
|
2020-12-14 12:45:09 +05:30
|
|
|
v-for="result in results.items"
|
2020-12-09 19:03:29 +05:30
|
|
|
>
|
2021-09-04 00:57:22 +05:30
|
|
|
<VideoItem v-if="shouldUseVideoItem(result)" :video="result" height="94" width="168" />
|
|
|
|
<div class="uk-text-secondary" v-if="!shouldUseVideoItem(result)">
|
2021-05-29 01:02:10 +05:30
|
|
|
<router-link class="uk-text-emphasis" v-bind:to="result.url">
|
2021-07-21 15:45:07 +05:30
|
|
|
<div class="uk-position-relative">
|
|
|
|
<img style="width: 100%" v-bind:src="result.thumbnail" loading="lazy" />
|
|
|
|
</div>
|
2021-05-29 01:02:10 +05:30
|
|
|
<p>
|
|
|
|
{{ result.name }} <font-awesome-icon
|
|
|
|
v-if="result.verified"
|
|
|
|
icon="check"
|
|
|
|
></font-awesome-icon>
|
|
|
|
</p>
|
2020-12-09 19:03:29 +05:30
|
|
|
</router-link>
|
2021-05-29 01:02:10 +05:30
|
|
|
<p v-if="result.description">{{ result.description }}</p>
|
|
|
|
<router-link class="uk-link-muted" v-if="result.uploaderUrl" v-bind:to="result.uploaderUrl">
|
|
|
|
<p>
|
|
|
|
{{ result.uploader }} <font-awesome-icon
|
|
|
|
v-if="result.uploaderVerified"
|
|
|
|
icon="check"
|
|
|
|
></font-awesome-icon>
|
|
|
|
</p>
|
2020-12-09 19:03:29 +05:30
|
|
|
</router-link>
|
2021-05-06 23:10:32 +05:30
|
|
|
|
2021-05-29 01:02:10 +05:30
|
|
|
<a v-if="result.uploaderName" class="uk-text-muted">{{ result.uploaderName }}</a>
|
2021-09-06 02:23:59 +05:30
|
|
|
<b v-if="result.videos >= 0"
|
|
|
|
><br v-if="result.uploaderName" />{{ result.videos }} {{ $t("video.videos") }}</b
|
|
|
|
>
|
2021-05-29 01:02:10 +05:30
|
|
|
|
2021-05-06 23:10:32 +05:30
|
|
|
<br />
|
2020-12-09 19:03:29 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-09-04 00:57:22 +05:30
|
|
|
import VideoItem from "@/components/VideoItem.vue";
|
|
|
|
|
2020-12-09 19:03:29 +05:30
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 17:15:40 +05:30
|
|
|
results: null,
|
2021-06-15 01:15:19 +05:30
|
|
|
availableFilters: [
|
|
|
|
"all",
|
|
|
|
"videos",
|
|
|
|
"channels",
|
|
|
|
"playlists",
|
|
|
|
"music_songs",
|
|
|
|
"music_videos",
|
|
|
|
"music_albums",
|
|
|
|
"music_playlists",
|
|
|
|
],
|
|
|
|
selectedFilter: "all",
|
2020-12-09 19:03:29 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.updateResults();
|
2021-07-07 19:48:09 +05:30
|
|
|
},
|
|
|
|
activated() {
|
2020-12-14 12:45:09 +05:30
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
2021-07-07 19:48:09 +05:30
|
|
|
deactivated() {
|
2020-12-14 12:45:09 +05:30
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
2020-12-09 19:03:29 +05:30
|
|
|
},
|
2021-09-06 02:23:59 +05:30
|
|
|
unmounted() {
|
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
2020-12-09 19:03:29 +05:30
|
|
|
methods: {
|
|
|
|
async fetchResults() {
|
2021-07-04 23:56:02 +05:30
|
|
|
return await await this.fetchJson(this.apiUrl() + "/search", {
|
2021-06-15 17:07:35 +05:30
|
|
|
q: this.$route.query.search_query,
|
|
|
|
filter: this.selectedFilter,
|
|
|
|
});
|
2020-12-09 19:03:29 +05:30
|
|
|
},
|
|
|
|
async updateResults() {
|
2020-12-14 12:45:09 +05:30
|
|
|
document.title = this.$route.query.search_query + " - Piped";
|
2021-04-07 17:15:40 +05:30
|
|
|
this.results = this.fetchResults().then(json => (this.results = json));
|
2020-12-14 12:45:09 +05:30
|
|
|
},
|
|
|
|
handleScroll() {
|
|
|
|
if (this.loading || !this.results || !this.results.nextpage) return;
|
2021-04-07 17:15:40 +05:30
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
2020-12-14 12:45:09 +05:30
|
|
|
this.loading = true;
|
2021-07-04 23:56:02 +05:30
|
|
|
this.fetchJson(this.apiUrl() + "/nextpage/search", {
|
2021-06-15 17:07:35 +05:30
|
|
|
nextpage: this.results.nextpage,
|
|
|
|
q: this.$route.query.search_query,
|
|
|
|
filter: this.selectedFilter,
|
|
|
|
}).then(json => {
|
2021-02-24 15:05:41 +05:30
|
|
|
this.results.nextpage = json.nextpage;
|
|
|
|
this.results.id = json.id;
|
|
|
|
this.loading = false;
|
|
|
|
json.items.map(stream => this.results.items.push(stream));
|
|
|
|
});
|
2020-12-14 12:45:09 +05:30
|
|
|
}
|
2021-04-07 17:15:40 +05:30
|
|
|
},
|
2021-09-04 00:57:22 +05:30
|
|
|
shouldUseVideoItem(item) {
|
|
|
|
return item.title;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
VideoItem,
|
2021-04-07 17:15:40 +05:30
|
|
|
},
|
2020-12-09 19:03:29 +05:30
|
|
|
};
|
|
|
|
</script>
|