From 94fd6a5c0dc3d955b08d2dc1b5e66840031912f1 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Wed, 25 Dec 2019 17:25:13 -0500 Subject: [PATCH] [+] Encapsulate function to get vid from youtube url --- src/App.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/App.ts b/src/App.ts index d12987b..6729673 100644 --- a/src/App.ts +++ b/src/App.ts @@ -172,3 +172,19 @@ export default class App extends Vue this.$refs.ps.show(this.swipeItems(), {index: index}); } } + +/** + * Get VID from youtube url + * + * @param url + */ +function getYoutubeVID(url: string) +{ + let video_id = url.split('v=')[1]; + let ampersandPosition = video_id.indexOf('&'); + if(ampersandPosition != -1) + { + video_id = video_id.substring(0, ampersandPosition); + } + return video_id; +}