Browse Source

feat(EditSong): Fill artists with youtube author button

Owen Diffey 2 years ago
parent
commit
ff7135a2a2
1 changed files with 25 additions and 1 deletions
  1. 25 1
      frontend/src/components/modals/EditSong/index.vue

+ 25 - 1
frontend/src/components/modals/EditSong/index.vue

@@ -418,6 +418,16 @@
 											getAlbumData('artists')
 										"
 									/>
+									<button
+										class="button youtube-get-button"
+										@click="getYouTubeData('author')"
+									>
+										<div
+											class="youtube-icon"
+											v-tippy
+											content="Fill from YouTube"
+										></div>
+									</button>
 									<button
 										class="button album-get-button"
 										@click="getAlbumData('artists')"
@@ -1645,7 +1655,7 @@ export default {
 						});
 					else throw new Error("No title found");
 				} catch (e) {
-					new Toast("Unable to fetch YouTube title");
+					new Toast("Unable to fetch YouTube video title");
 				}
 			}
 			if (type === "thumbnail")
@@ -1653,6 +1663,20 @@ export default {
 					field: "thumbnail",
 					value: `https://img.youtube.com/vi/${this.song.youtubeId}/mqdefault.jpg`
 				});
+			if (type === "author") {
+				try {
+					const { author } = this.video.player.getVideoData();
+
+					if (author)
+						this.updateSongField({
+							field: "artists",
+							value: [author]
+						});
+					else throw new Error("No video author found");
+				} catch (e) {
+					new Toast("Unable to fetch YouTube video author");
+				}
+			}
 		},
 		fillDuration() {
 			this.song.duration =