mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 08:05:56 -05:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
import{_ as P,a3 as A,e as f,r as p,o as a,c as m,a as s,h as O,j as S,Z as T,d,w as l,F as B,f as D,g as c,k as u,t as n}from"./index.js";import{C as E,T as M}from"./TabsSearch.js";import{C as N}from"./ContentWithHeading.js";import{G as h}from"./GroupByList.js";import{L as V}from"./ListAlbums.js";import{L as W}from"./ListArtists.js";import{L as F}from"./ListComposers.js";import{L as G}from"./ListPlaylists.js";import{L as H}from"./ListTracks.js";import"./CoverArtwork.js";import"./ModalDialogAlbum.js";import"./ModalDialogArtist.js";import"./ModalDialogComposer.js";import"./ModalDialogPlaylist.js";import"./spotify-web-api.js";const R={name:"PageSearchLibrary",components:{ContentText:E,ContentWithHeading:N,ListAlbums:V,ListArtists:W,ListComposers:F,ListPlaylists:G,ListTracks:H,TabsSearch:M},data(){return{albums:new h,artists:new h,audiobooks:new h,composers:new h,playlists:new h,podcasts:new h,search_query:"",tracks:new h}},computed:{recent_searches(){return this.$store.state.recent_searches},show_albums(){return this.$route.query.type&&this.$route.query.type.includes("album")},show_all_albums_button(){return this.albums.total>this.albums.items.length},show_all_artists_button(){return this.artists.total>this.artists.items.length},show_all_audiobooks_button(){return this.audiobooks.total>this.audiobooks.items.length},show_all_composers_button(){return this.composers.total>this.composers.items.length},show_all_playlists_button(){return this.playlists.total>this.playlists.items.length},show_all_podcasts_button(){return this.podcasts.total>this.podcasts.items.length},show_all_tracks_button(){return this.tracks.total>this.tracks.items.length},show_artists(){return this.$route.query.type&&this.$route.query.type.includes("artist")},show_audiobooks(){return this.$route.query.type&&this.$route.query.type.includes("audiobook")},show_composers(){return this.$route.query.type&&this.$route.query.type.includes("composer")},show_playlists(){return this.$route.query.type&&this.$route.query.type.includes("playlist")},show_podcasts(){return this.$route.query.type&&this.$route.query.type.includes("podcast")},show_tracks(){return this.$route.query.type&&this.$route.query.type.includes("track")}},watch:{$route(t,r){this.search(t)}},mounted(){this.search(this.$route)},methods:{search(t){if(!t.query.query||t.query.query===""){this.search_query="",this.$refs.search_field.focus();return}this.search_query=t.query.query,this.searchMusic(t.query),this.searchAudiobooks(t.query),this.searchPodcasts(t.query),this.$store.commit(A,t.query.query)},searchMusic(t){if(t.type.indexOf("track")<0&&t.type.indexOf("artist")<0&&t.type.indexOf("album")<0&&t.type.indexOf("playlist")<0)return;const r={type:t.type,media_kind:"music"};t.query.startsWith("query:")?r.expression=t.query.replace(/^query:/u,"").trim():r.query=t.query,t.limit&&(r.limit=t.limit,r.offset=t.offset),f.search(r).then(({data:_})=>{this.tracks=new h(_.tracks),this.artists=new h(_.artists),this.albums=new h(_.albums),this.composers=new h(_.composers),this.playlists=new h(_.playlists)})},searchAudiobooks(t){if(t.type.indexOf("audiobook")<0)return;const r={type:"album",media_kind:"audiobook"};t.query.startsWith("query:")?r.expression=t.query.replace(/^query:/u,"").trim():r.expression=`((album includes "${t.query}" or artist includes "${t.query}") and media_kind is audiobook)`,t.limit&&(r.limit=t.limit,r.offset=t.offset),f.search(r).then(({data:_})=>{this.audiobooks=new h(_.albums)})},searchPodcasts(t){if(t.type.indexOf("podcast")<0)return;const r={type:"album",media_kind:"podcast"};t.query.startsWith("query:")?r.expression=t.query.replace(/^query:/u,"").trim():r.expression=`((album includes "${t.query}" or artist includes "${t.query}") and media_kind is podcast)`,t.limit&&(r.limit=t.limit,r.offset=t.offset),f.search(r).then(({data:_})=>{this.podcasts=new h(_.albums)})},new_search(){this.search_query&&(this.$router.push({name:"search-library",query:{limit:3,offset:0,query:this.search_query,type:"track,artist,album,playlist,audiobook,podcast,composer"}}),this.$refs.search_field.blur())},open_search_track
|