From a49d65d86a35cde96302c0a40b44431bdaa70b9c Mon Sep 17 00:00:00 2001
From: RikaCelery <94585272+RikaCelery@users.noreply.github.com>
Date: Mon, 24 Jul 2023 16:11:45 +0800
Subject: [PATCH] add <header,key>

---
 generator.html | 127 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 95 insertions(+), 32 deletions(-)

diff --git a/generator.html b/generator.html
index a0ba0f8..cac6edb 100644
--- a/generator.html
+++ b/generator.html
@@ -4,7 +4,8 @@
 <head>
     <meta charset="UTF-8">
     <title>Command Generator</title>
-    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,700;1,400&amp;display=swap.css">
+    <link rel="stylesheet"
+        href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,700;1,400&amp;display=swap.css">
     <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 </head>
@@ -48,126 +49,147 @@
                     <input id="input" type="text" placeholder="链接或文件" required>
                 </div>
                 <div class="input-box">
-                    <label for="">save-name</label>
+                    <label>save-name</label>
                     <input id="save-name" type="text" placeholder="设置保存文件名">
                 </div>
                 <div class="input-box">
-                    <label for="">base-url</label>
+                    <label>base-url</label>
                     <input id="base-url" type="text" placeholder="设置BaseURL">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">save-dir</label>
+                    <label>save-dir</label>
                     <input id="save-dir" type="text" placeholder="设置输出目录">
                 </div>
                 <div class="input-box">
-                    <label for="">tmp-dir</label>
+                    <label>tmp-dir</label>
                     <input id="tmp-dir" type="text" placeholder="设置临时文件存储目录">
                 </div>
                 <div class="input-box">
-                    <label for="">mux-import</label>
+                    <label>mux-import</label>
                     <input id="mux-import" type="text" placeholder="混流时引入外部媒体文件">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">thread-count</label>
+                    <label>thread-count</label>
                     <input id="thread-count" type="text" placeholder="设置下载线程数 [default: 8]" defalut="8">
                 </div>
                 <div class="input-box">
-                    <label for="">download-retry-count</label>
+                    <label>download-retry-count</label>
                     <input id="download-retry-count" type="text" placeholder="每个分片下载异常时的重试次数 [default: 3]" defalut="3">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">ffmpeg-binary-path</label>
+                    <label>ffmpeg-binary-path</label>
                     <input id="ffmpeg-binary-path" type="text" placeholder="ffmpeg可执行程序全路径, 例如 C:\Tools\ffmpeg.exe">
                 </div>
                 <div class="input-box">
-                    <label for="">urlprocessor-args</label>
+                    <label>urlprocessor-args</label>
                     <input id="urlprocessor-args" type="text" placeholder="此字符串将直接传递给URL Processor">
                 </div>
             </div>
             <div class="input-box">
-                <label for="">key-text-file</label>
+                <label>key-text-file</label>
                 <input id="key-text-file" type="text" placeholder="设置密钥文件,程序将从文件中按KID搜寻KEY以解密.(不建议使用特大文件)">
             </div>
             <div class="input-box">
-                <label for="">decryption-binary-path</label>
+                <label>decryption-binary-path</label>
                 <input id="decryption-binary-path" type="text" placeholder=" MP4解密所用工具的全路径, 例如 C:\Tools\mp4decrypt.exe">
             </div>
 
             <div class="column">
                 <div class="input-box">
-                    <label for="">mux-after-done</label>
+                    <label>mux-after-done</label>
                     <input id="mux-after-done" type="text" placeholder="所有工作完成时尝试混流分离的音视频">
                 </div>
                 <div class="input-box">
-                    <label for="">custom-hls-key</label>
+                    <label>custom-hls-key</label>
                     <input id="custom-hls-key" type="text" placeholder="指定HLS解密KEY. 可以是文件, HEX或Base64">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">custom-hls-iv</label>
+                    <label>custom-hls-iv</label>
                     <input id="custom-hls-iv" type="text" placeholder="指定HLS解密IV. 可以是文件, HEX或Base64">
                 </div>
                 <div class="input-box">
-                    <label for="">custom-proxy</label>
+                    <label>custom-proxy</label>
                     <input id="custom-proxy" type="text" placeholder="设置请求代理, 如 http://127.0.0.1:8888">
                 </div>
             </div>
             <div class="column">
 
                 <div class="input-box">
-                    <label for="">custom-range</label>
+                    <label>custom-range</label>
                     <input id="custom-range" type="text" placeholder="仅下载部分分片">
                 </div>
                 <div class="input-box">
-                    <label for="">task-start-at</label>
+                    <label>task-start-at</label>
                     <input id="task-start-at" type="text" placeholder="格式:<yyyyMMddHHmmss>在此时间之前不会开始执行任务">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">live-record-limit</label>
+                    <label>live-record-limit</label>
                     <input id="live-record-limit" type="text" placeholder="录制直播时的录制时长限制,格式: HH:mm:ss">
                 </div>
                 <div class="input-box">
-                    <label for="">live-wait-time</label>
+                    <label>live-wait-time</label>
                     <input id="live-wait-time" type="text" placeholder="手动设置直播列表刷新间隔, 单位为秒">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">select-video</label>
+                    <label>select-video</label>
                     <input id="select-video" type="text" placeholder="通过正则表达式选择符合要求的视频流">
                 </div>
                 <div class="input-box">
-                    <label for="">select-audio</label>
+                    <label>select-audio</label>
                     <input id="select-audio" type="text" placeholder="通过正则表达式选择符合要求的音频流">
                 </div>
                 <div class="input-box">
-                    <label for="">select-subtitle</label>
+                    <label>select-subtitle</label>
                     <input id="select-subtitle" type="text" placeholder="通过正则表达式选择符合要求的字幕流">
                 </div>
             </div>
             <div class="column">
                 <div class="input-box">
-                    <label for="">drop-video</label>
+                    <label>drop-video</label>
                     <input id="drop-video" type="text" placeholder="通过正则表达式去除符合要求的视频流">
                 </div>
                 <div class="input-box">
-                    <label for="">drop-audio</label>
+                    <label>drop-audio</label>
                     <input id="drop-audio" type="text" placeholder="通过正则表达式去除符合要求的音频流">
                 </div>
                 <div class="input-box">
-                    <label for="">drop-subtitle</label>
+                    <label>drop-subtitle</label>
                     <input id="drop-subtitle" type="text" placeholder="通过正则表达式去除符合要求的字幕流">
                 </div>
             </div>
+            <div class="column">
+                <div id="header" class="input-box ">
+                    <div class="row">
+                        <label>header</label>
+                        <label class="button" onclick="insert('#header','header','为HTTP请求设置特定的请求头, 例如: -H &#x0022;Cookie: mycookie&#x0022; -H &#x0022;User-Agent: iOS&#x0022;')">+</label>
+                        <label class="button" onclick="removeLast('#header')">-</label>
+                        <input type="text" id="header" placeholder="为HTTP请求设置特定的请求头, 例如: -H &#x0022;Cookie: mycookie&#x0022; -H &#x0022;User-Agent: iOS&#x0022;">
+                    </div>
+                </div>
+            </div>
+            <div class="column">
+                <div id="key" class="input-box ">
+                    <div class="row">
+                        <label>key</label>
+                        <label class="button"
+                            onclick="insert('#key','key','设置解密密钥, 程序调用mp4decrpyt/shaka-packager进行解密. 格式: --key KID1:KEY1 --key KID2:KEY2')">+</label>
+                        <label class="button" onclick="removeLast('#key')">-</label>
+                        <input type="text" id="key" placeholder="设置解密密钥, 程序调用mp4decrpyt/shaka-packager进行解密. 格式: --key KID1:KEY1 --key KID2:KEY2">
+                    </div>
+                </div>
+            </div>
             <div class="column">
                 <div class="input-box">
                     <label for="log-level">log-level</label>
@@ -350,13 +372,13 @@
         .to(".text p", 0.1, { color: "#FFF" }, 0.1);
 
     animate
-    .set(".circle", { backgroundColor: "rgba(0,0,0,0)" },0.2)
+        .set(".circle", { backgroundColor: "rgba(0,0,0,0)" }, 0.2)
         .to(".toggle-button", 0.1, { scale: 0.7 }, 0)
         .set(".toggle", { backgroundColor: "#FFF" })
         .to(".moon-mask", 0.2, { translateY: 20, translateX: -10 }, 0.3)
         .to(".toggle-button", 0.1, { translateY: 49 }, 0.1)
         .to(".toggle-button", 0.1, { scale: 0.9 })
-        
+
     document.getElementsByClassName("switch")[0].addEventListener("click", () => {
         if (toggle) {
             animate.restart();
@@ -368,6 +390,22 @@
         toggle = !toggle;
         changeColor()
     });
+
+    function insert(pos, id, placeholder) {
+        let input = document.createElement('input')
+        input.type = 'text'
+        input.id = id
+        input.placeholder = placeholder
+        input.oninput = () => { generate('generator_body') }
+        document.querySelector(pos).appendChild(input)
+    }
+    function removeLast(pos) {
+        console.log(document.querySelector(pos).lastChild.tagName);
+        if (document.querySelector(pos).lastChild.tagName != 'INPUT') {
+            return
+        }
+        document.querySelector(pos).removeChild(document.querySelector(pos).lastChild)
+    }
     function generate(params) {
         let form = document.getElementById(params)
         // console.log(form)
@@ -383,7 +421,6 @@
 
                         } else {
                             finalArgs.push('"' + element.value + '"')
-
                         }
                     }
                     break;
@@ -542,6 +579,7 @@
 
     .form label {
         color: var(--main-text-color);
+        user-select: none;
         font-size: 1.2rem;
         font-weight: 500;
     }
@@ -601,6 +639,7 @@
     .select-box select {
         width: 100%;
         height: 100%;
+        padding: 0px 0px;
         outline: none;
         border: none;
         color: var(--main-text-color);
@@ -666,10 +705,34 @@
         }
     }
 
-    ::-webkit-scrollbar{
+    ::-webkit-scrollbar {
         display: none;
     }
 
+    label.button {
+        z-index: 0;
+        padding: 0 8px;
+        width: 20px;
+        height: 20px;
+        background-color: var(--accent-color);
+        border-radius: 40px;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     /* ***** Colors - Start ***** */
     /* ***** Colors - End ***** */
     /* ***** Global Styles - Start ***** */
@@ -689,7 +752,7 @@
 
     /* ***** Global Styles - End ***** */
     /* ***** Specific Styles - Start ***** */
-    
+
 
     .switch {
         width: 60px;
@@ -797,6 +860,6 @@
         flex-grow: 0;
         top: -30px;
         left: 10px;
-        transform:scale(0.7) rotateZ(-90deg);
+        transform: scale(0.7) rotateZ(-90deg);
     }
 </style>
\ No newline at end of file