From 9e3cc5e0e2523aea57c771bde7f3e5634f5c7eec Mon Sep 17 00:00:00 2001 From: Hell13Cat <46496367+Hell13Cat@users.noreply.github.com> Date: Thu, 16 Mar 2023 00:06:04 +0300 Subject: [PATCH] build 0003 Video support --- .gitignore | 4 +++- data/vid.png | Bin 0 -> 4210 bytes server.py | 51 +++++++++++++++++++++++++++++++++++++----------- static/js/my.js | 46 ++++++++++++++++++++++++++++++++++++++----- 4 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 data/vid.png diff --git a/.gitignore b/.gitignore index 9942040..a58d60b 100644 --- a/.gitignore +++ b/.gitignore @@ -140,4 +140,6 @@ main (2).py search_data.json 2.json image_gen.py -config.json \ No newline at end of file +config.json +test_frame.py +test.png \ No newline at end of file diff --git a/data/vid.png b/data/vid.png new file mode 100644 index 0000000000000000000000000000000000000000..ce38b3697a1c3f75b4cd0780d1e6b9019c0d5ce7 GIT binary patch literal 4210 zcmcgw`9DfKIp=wv_jT{<`8ux~Yin(Cj!TG(jg9S`nW>>Y z(9ivDXHEgv)`z=|K*t_zZ=%mu*>`mjFi!gDS?RH{5fix&JU9TG^RX#3n2qgx`|rly z8Cc@U#&+SfnW5gDr?6iWe*TV*xt(jDtO~>}P4Zj|^j+?KxE)uWSA~DssU^d?R>{#T z(NDd#-X@R$!Ghd(+IHIh#GnUme+`;du53wyt&kVh*&PL_4dYFIjhGEZvBf$A~90%XP z*v-5@ zq4+N?nFnNQI9Br&f0R;u#xv`=Xv>tnfB!Pzp97Y~p?jb%Y_-LVB?LAOtj1Sds^p%! zi$80`*+Jh1ABzu(R1{>z5%i78MejisY#m1NRTiG-OFvDe=$4rt8@$1toGxZqkGK!W zofat4i0Gj?T? z6D4}2AO8{JmGJqop2k#6q$9c|C0~mD1^O-rG*{=;6t^QLZP9?O*%k#&);amx9OpW@ ziq?=VkNhYUWpe8Z_tUp+C$$Vc{t&?_vGdqrqGF^h|25#dIVHw*Y4rk%^M5~#_q1PZ z_mq~FzF6)=xU8b0a({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7LmSQkbMk lZv=v`c= im.height: + widtha = 250 + percent = widtha / im.width + heighta = round(im.height * percent) + else: + heighta = 250 + percent = heighta / im.height + widtha = round(im.width * percent) + im = im.resize((widtha, heighta)) + return im + @app.route("/") def index(): value = Markup('The HTML String') @@ -74,9 +98,11 @@ def hentai_search(types, tags): if contun == 2: if ".webm" in ii["file"] or ".mp4" in ii["file"] or ".avi" in ii["file"] or ".flv" in ii["file"]: typef = "v" + url_thumb = "/file/thumb/"+ii["file"]+".png" else: typef = "i" - res_post = {"tags":" ".join(ii["tags"]), "id":ii["id"], "type":typef, "rating":ii["rating"], "url_full":"/file/full/"+ii["file"], "url_thumb":"/file/thumb/"+ii["file"]} + url_thumb = "/file/thumb/"+ii["file"] + res_post = {"tags":" ".join(ii["tags"]), "id":ii["id"], "type":typef, "rating":ii["rating"], "url_full":"/file/full/"+ii["file"], "url_thumb":url_thumb} list_res.append(res_post) count += 1 json_resp = {"count":count,"list":list_res} @@ -100,16 +126,19 @@ def hentai_img(filetype, filename): return response if filetype == "thumb": ext = filename.split(".")[-1] - images = Image.open(root_folder+"data_img/"+filename) - if images.width >= images.height: - widtha = 250 - percent = widtha / images.width - heighta = round(images.height * percent) + if ".webm.png" in filename: + images = get_frame(root_folder+"data_img/"+(filename.replace(".webm.png", ".webm"))) else: - heighta = 250 - percent = heighta / images.height - widtha = round(images.width * percent) - images = images.resize((widtha, heighta)) + images = Image.open(root_folder+"data_img/"+filename) + if images.width >= images.height: + widtha = 250 + percent = widtha / images.width + heighta = round(images.height * percent) + else: + heighta = 250 + percent = heighta / images.height + widtha = round(images.width * percent) + images = images.resize((widtha, heighta)) io_data = io.BytesIO() if ext == "jpg": extf = "jpeg" diff --git a/static/js/my.js b/static/js/my.js index c119af1..1c89f65 100644 --- a/static/js/my.js +++ b/static/js/my.js @@ -39,7 +39,11 @@ function search(e){ imgc.innerHTML = ''; resp_res.forEach(function(item, i, resp_res) { var add_elem_a = document.createElement("button"); - add_elem_a.setAttribute("onclick", "see_full('"+item["url_full"]+"', '"+item["id"]+"', '"+item["type"]+"')"); + if (item["type"] == "i") { + add_elem_a.setAttribute("onclick", "see_full_img('"+item["url_full"]+"', '"+item["id"]+"', '"+item["type"]+"')"); + } else { + add_elem_a.setAttribute("onclick", "see_full_vid('"+item["url_full"]+"', '"+item["id"]+"', '"+item["type"]+"')"); + } add_elem_a.setAttribute("id", item["id"]); add_elem_a.setAttribute("class", "buttimg"); var add_elem_img = document.createElement("img"); @@ -52,15 +56,47 @@ function search(e){ }); } } -function see_full(url, id_button, type){ - var fulldata = document.getElementById("fullimg"); + +function see_full_vid(url, id_button, type){ + var fulldata = document.getElementById("fulldata"); if (fulldata != null){ fulldata.remove(); } var add_elem_br = document.createElement("br"); var add_elem_p = document.createElement("p"); add_elem_p.setAttribute("class", "fullimagep"); - add_elem_p.setAttribute("id", "fullimg"); + add_elem_p.setAttribute("id", "fulldata"); + var add_elem_a = document.createElement("a"); + add_elem_a.setAttribute("href", "#"+id_button); + var add_elem_button = document.createElement("button"); + add_elem_button.textContent = 'CLOSE'; + add_elem_button.setAttribute("class", "buttonclose"); + add_elem_button.setAttribute("onclick", "close_full()"); + var add_elem_ai = document.createElement("a"); + add_elem_ai.setAttribute("href", url); + add_elem_ai.setAttribute("target", "_blank"); + var add_elem_img = document.createElement("video"); + add_elem_img.setAttribute("src", url); + add_elem_img.setAttribute("class", "fullimage"); + add_elem_img.controls = true; + add_elem_ai.append(add_elem_img) + add_elem_p.appendChild(add_elem_button); + add_elem_p.appendChild(add_elem_br); + add_elem_p.appendChild(add_elem_ai); + var targetimg = document.getElementById(id_button); + targetimg.after(add_elem_p) + add_elem_a.click(); +} + +function see_full_img(url, id_button, type){ + var fulldata = document.getElementById("fulldata"); + if (fulldata != null){ + fulldata.remove(); + } + var add_elem_br = document.createElement("br"); + var add_elem_p = document.createElement("p"); + add_elem_p.setAttribute("class", "fullimagep"); + add_elem_p.setAttribute("id", "fulldata"); var add_elem_a = document.createElement("a"); add_elem_a.setAttribute("href", "#"+id_button); var add_elem_button = document.createElement("button"); @@ -82,7 +118,7 @@ function see_full(url, id_button, type){ add_elem_a.click(); } function close_full(){ - var fulldata = document.getElementById("fullimg"); + var fulldata = document.getElementById("fulldata"); fulldata.remove(); }