diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index 557acad7..5ba041d2 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -127,8 +127,8 @@ export default { handleRedirect() { const query = this.$route.query.search_query; const url = - /(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9?=&]*)/gm.exec(query)?.[1] ?? - /(?:http(?:s)?:\/\/)?(?:www\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9?=&]*)/gm + /(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9_?=&]*)/gm.exec(query)?.[1] ?? + /(?:http(?:s)?:\/\/)?(?:www\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9_?=&]*)/gm .exec(query)?.[1] .replace(/^/, "/watch?v="); if (url) { diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index 78e5da1b..37d569d7 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -183,8 +183,9 @@ export default { videoEl.setAttribute("poster", this.video.thumbnailUrl); - if (this.$route.query.t) { - const time = this.$route.query.t; + const time = this.$route.query.t ?? this.$route.query.start; + + if (time) { let start = 0; if (/^[\d]*$/g.test(time)) { start = time; diff --git a/src/components/WatchVideo.vue b/src/components/WatchVideo.vue index 91d546bd..0e670cb1 100644 --- a/src/components/WatchVideo.vue +++ b/src/components/WatchVideo.vue @@ -286,9 +286,9 @@ export default { xmlDoc.querySelectorAll("a").forEach(elem => (elem.outerHTML = elem.getAttribute("href"))); xmlDoc.querySelectorAll("br").forEach(elem => (elem.outerHTML = "\n")); this.video.description = this.urlify(xmlDoc.querySelector("body").innerHTML) - .replaceAll(/(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9?=&]*)/gm, "$1") + .replaceAll(/(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9_?=&]*)/gm, "$1") .replaceAll( - /(?:http(?:s)?:\/\/)?(?:www\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9?=&]*)/gm, + /(?:http(?:s)?:\/\/)?(?:www\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9_?=&]*)/gm, "/watch?v=$1", ) .replaceAll("\n", "
");