From 1fb85313dd975f7dd76b5865e52eacd778741610 Mon Sep 17 00:00:00 2001
From: bytedream <bytedream@protonmail.com>
Date: Sat, 11 Nov 2023 21:31:23 +0100
Subject: [PATCH] Use more reliable streamtape match function

---
 src/lib/match.ts | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/lib/match.ts b/src/lib/match.ts
index 0e99f9d..e8a6a8b 100644
--- a/src/lib/match.ts
+++ b/src/lib/match.ts
@@ -156,11 +156,19 @@ export const Newgrounds: Match = {
 export const Streamtape: Match = {
 	name: 'Streamtape',
 	id: 'streamtape',
-	reliability: Reliability.NORMAL,
+	reliability: Reliability.HIGH,
 	domains: ['streamtape.com', 'streamtape.net', 'shavetape.cash'],
 	regex: /id=.*(?=')/gm,
 
 	match: async (match: RegExpMatchArray) => {
+		let i = 0;
+		while (i < match.length) {
+			if (match[++i - 1] == match[i]) {
+				return `https://streamtape.com/get_video?${match[i]}`;
+			}
+		}
+
+		// use the old method as fallback
 		return `https://streamtape.com/get_video?${match.reverse()[0]}`;
 	}
 };