Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30 committed Mar 17, 2023
2 parents 57f5970 + 7b32d47 commit 5ca3088
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
32 changes: 31 additions & 1 deletion src/components/MetaList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<template>
<div class="meta-list__container">
<Animation v-if="getIsLoading" />
<div v-else-if="isFailedLoading">
<div
class="py-2 md:w-2/5 w-11/12 failed--msg--wrapper my-auto flex justify-center items-center w-full mr-auto ml-auto"
>
<div
class="text-center md:text-2xl text-lg font-semibold dark:text-white"
>
{{ getMetaLoadFailedText }}
</div>
</div>
</div>
<div v-else class="meta__results">
<MetaResult v-for="(meta, id) in getMetaResults" :key="id" :meta="meta" />
<div v-if="!getShowAllData" class="show--more--btn my-8">
Expand Down Expand Up @@ -45,7 +56,8 @@ export default {
metaUrl: "https://apis.deepjyoti30.dev/v2/ytmdl/metadata",
fetchedData: null,
isLoading: false,
showAllData: false
showAllData: false,
hasFailed: false
};
},
props: {
Expand Down Expand Up @@ -74,6 +86,14 @@ export default {
}
}
);
// Handle the case if a non 200 OK status is received
if (response.status != 200) {
this.hasFailed = true;
this.isLoading = false;
return;
}
const jsonData = await response.json();
this.fetchedData = jsonData;
Expand All @@ -100,6 +120,12 @@ export default {
},
getManualLink() {
return { name: "Manual", query: { videoId: this.$route.query.videoId } };
},
isFailedLoading() {
return this.hasFailed;
},
getMetaLoadFailedText() {
return "Failed to load metadata for the song. Please enter the song name only without artist name etc";
}
},
watch: {
Expand Down Expand Up @@ -137,4 +163,8 @@ export default {
}
}
}
.failed--msg--wrapper {
height: 60vh;
}
</style>
16 changes: 15 additions & 1 deletion src/views/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export default {
confirmText: "",
titleUrl: `https://apis.deepjyoti30.dev/v2/ytmdl/metadata/title-from-url`,
songNameExtracted: null,
isTitleLoading: false
isTitleLoading: false,
isTitleLoadFailed: false
};
},
methods: {
Expand All @@ -71,7 +72,11 @@ export default {
this.songNameExtracted = await this.extractTitleFromUrl(
searchData.youtubeUrl
);
this.isTitleLoading = false;
// Check if title load failed
if (this.isTitleLoadFailed) return;
}
// Check if we need to show the prompt. If we do, show the prompt,
Expand Down Expand Up @@ -122,6 +127,13 @@ export default {
method: "GET"
}
);
// Handle the case if the response is not 200 OK
if (response.status != 200) {
this.isTitleLoadFailed = true;
return "";
}
const jsonData = await response.json();
// TODO: Do something with the should_verify flag
Expand All @@ -139,6 +151,8 @@ export default {
getNoQueryText() {
return this.isTitleLoading
? "Extracting title from the entered URL..."
: this.isTitleLoadFailed
? "Failed to load details for the entered URL. Please try with a different URL"
: "You need to enter the name of a song";
}
},
Expand Down

0 comments on commit 5ca3088

Please sign in to comment.