diff options
| author | RblSb <msrblsb@gmail.com> | 2020-04-01 18:09:10 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-04-01 18:09:10 +0300 |
| commit | fd495d14af55b5196bdb3adc4ef092ab2952d94f (patch) | |
| tree | 6b6d53a50026c7704b481cad8a17c62fdea44ad6 /src | |
| parent | 6fa4100b5237c64ca1e6e4f1c2ed30654f4feb79 (diff) | |
Url masks
foo.com/${2-10}.mp4
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/Main.hx | 19 |
1 files changed, 19 insertions, 0 deletions
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<String>):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 |
