feat: implemented link analyzer

This commit is contained in:
Roberto Tonino
2021-06-02 15:32:45 +02:00
parent f13f643baa
commit 72b78e35e9
5 changed files with 2145 additions and 2207 deletions

View File

@@ -102,6 +102,8 @@ import { defineComponent, ref } from '@vue/composition-api'
import { isValidURL } from '@/utils/utils'
import { sendAddToQueue } from '@/utils/downloads'
import { socket } from '@/utils/socket'
import { fetchData } from '@/utils/api'
import EventBus from '@/utils/EventBus'
export default defineComponent({
setup() {
@@ -156,8 +158,27 @@ export default defineComponent({
}
if (isShowingAnalyzer) {
socket.emit('analyzeLink', term)
return
try {
const analyzedData = await fetchData('analyzeLink', { term })
const isError = !!analyzedData.errorCode
if (isError) {
throw new Error(analyzedData.errorMessage)
}
if (analyzedData.type === 'track') {
EventBus.$emit('analyze_track', analyzedData)
}
if (analyzedData.type === 'album') {
EventBus.$emit('analyze_album', analyzedData)
}
// socket.emit('analyzeLink', term)
return
} catch (error) {
console.error(error)
return
}
}
// ? Open downloads tab maybe?

View File

@@ -134,10 +134,12 @@
</template>
<script>
/* eslint-disable camelcase */
import { socket } from '@/utils/socket'
import { convertDuration } from '@/utils/utils'
import { COUNTRIES } from '@/utils/countries'
import { sendAddToQueue } from '@/utils/downloads'
import EventBus from '@/utils/EventBus'
export default {
data() {
@@ -153,8 +155,8 @@ export default {
}
},
mounted() {
socket.on('analyze_track', this.showTrack)
socket.on('analyze_album', this.showAlbum)
EventBus.$on('analyze_track', this.showTrack)
EventBus.$on('analyze_album', this.showAlbum)
socket.on('analyze_notSupported', this.notSupported)
},
methods: {