~cadence/tube-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2

[PATCH cloudtube] Properly rewrite URL params for youtu.be links in converters.rewriteVideoDescription()

~lomanic
Details
Message ID
<162483525128.16655.7088647474999417007-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +7 -1
From: Lomanic <lomanic@hotmail.fr>

---
 utils/converters.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/utils/converters.js b/utils/converters.js
index 6e17567..b5e6404 100644
--- a/utils/converters.js
+++ b/utils/converters.js
@@ -66,8 +66,14 @@ function rewriteVideoDescription(descriptionHtml, id) {
	// https://www.youtube.com/watch?v=fhum63fAwrI www.youtube.com/watch?v=<videoid>
	// https://www.youtube.com/watch?v=i-szWOrc3Mo www.youtube.com/<channelname> (unsupported by cloudtube currently)
	// https://www.youtube.com/watch?v=LSG71wbKpbQ www.youtube.com/channel/<id>
	// https://www.youtube.com/watch?v=RiEkOKFOG3s youtu.be/<videoid> with params

	descriptionHtml = descriptionHtml.replace(new RegExp(`<a href="https?://(?:www\\.)?youtu\\.be/(${constants.regex.video_id})([^"]*)">([^<]+)</a>`, "g"), `<a href="/watch?v=$1$2">$3</a>`)
	descriptionHtml = descriptionHtml.replace(new RegExp(`<a href="https?://(?:www\\.)?youtu\\.be/(${constants.regex.video_id})[?]?([^"]*)">([^<]+)</a>`, "g"), (_, id, params, innerText) => {
		if (params != "") {
			return `<a href="/watch?v=${id}&${params}">${innerText}</a>`
		}
		return `<a href="/watch?v=${id}">${innerText}</a>`
	})
	descriptionHtml = descriptionHtml.replace(new RegExp(`<a href="https?://(?:www\\.)?youtu(?:\\.be|be\\.com)/([^"]*)">([^<]+)<\/a>`, "g"), `<a href="/$1">$2</a>`)
	descriptionHtml = descriptionHtml.replace(new RegExp(`(?:([0-9]*):)?([0-5]?[0-9]):([0-5][0-9])`, "g"), (_, hours, minutes, seconds) => {
		let timeURL, timeDisplay, timeSeconds
-- 
2.30.2
Details
Message ID
<cc814f97-a732-4ec6-ba7f-4a88f88fb30c@disroot.org>
In-Reply-To
<162483525128.16655.7088647474999417007-0@git.sr.ht> (view parent)
DKIM signature
pass
Download raw message
Could you give an example of a video fixed by this?
Details
Message ID
<20210702004955.0cf40ec96c8555aabae286ba@disroot.org>
In-Reply-To
<162483525128.16655.7088647474999417007-0@git.sr.ht> (view parent)
DKIM signature
pass
Download raw message
Thanks, patch applied. I like your implementation.
Reply to thread Export thread (mbox)