From fd495d14af55b5196bdb3adc4ef092ab2952d94f Mon Sep 17 00:00:00 2001 From: RblSb Date: Wed, 1 Apr 2020 18:09:10 +0300 Subject: Url masks foo.com/${2-10}.mp4 --- src/client/Main.hx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/client') diff --git a/src/client/Main.hx b/src/client/Main.hx index ea4fc84..664495e 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -164,6 +164,24 @@ class Main { return personal.isAdmin; } + final mask = ~/\${([0-9]+)-([0-9]+)}/g; + + function handleUrlMasks(links:Array):Void { + for (link in links) { + if (!mask.match(link)) continue; + final start = Std.parseInt(mask.matched(1)); + var end = Std.parseInt(mask.matched(2)); + if (Math.abs(start - end) > 100) continue; + final step = end > start ? -1 : 1; + final i = links.indexOf(link); + links.remove(link); + while (end != start + step) { + links.insert(i, mask.replace(link, '$end')); + end += step; + } + } + } + function addVideoUrl(atEnd:Bool):Void { final mediaUrl:InputElement = cast ge("#mediaurl"); final checkbox:InputElement = cast ge("#addfromurl").querySelector(".add-temp"); @@ -173,6 +191,7 @@ class Main { mediaUrl.value = ""; final url = ~/,(https?)/g.replace(url, "|$1"); final links = url.split("|"); + handleUrlMasks(links); // if videos added as next, we need to load them in reverse order if (!atEnd) { // except first item when list empty -- cgit v1.2.3