diff --git a/logic_anilife.py b/logic_anilife.py index 0784343..b92f6c1 100644 --- a/logic_anilife.py +++ b/logic_anilife.py @@ -756,6 +756,8 @@ class LogicAniLife(LogicModuleBase): arg = P.ModelSetting.to_dict() arg["sub"] = self.name if sub in ["setting", "queue", "list", "category", "request"]: + if sub == "request" and req.args.get("content_code") is not None: + arg["anilife_current_code"] = req.args.get("content_code") if sub == "setting": job_id = "%s_%s" % (self.P.package_name, self.name) arg["scheduler"] = str(scheduler.is_include(job_id)) @@ -794,6 +796,37 @@ class LogicAniLife(LogicModuleBase): return jsonify( {"ret": "success", "cate": cate, "page": page, "data": data} ) + elif sub == "complete_list": + data = [] + + cate = request.form["type"] + logger.debug("cate:: %s", cate) + page = request.form["page"] + + data = self.get_anime_info(cate, page) + # self.current_data = data + return jsonify( + {"ret": "success", "cate": cate, "page": page, "data": data} + ) + elif sub == "search": + data = [] + # cate = request.form["type"] + # page = request.form["page"] + cate = request.form["type"] + query = request.form["query"] + page = request.form["page"] + + data = self.get_search_result(query, page, cate) + # self.current_data = data + return jsonify( + { + "ret": "success", + "cate": cate, + "page": page, + "query": query, + "data": data, + } + ) elif sub == "add_queue": logger.debug(f"add_queue routine ===============") ret = {} @@ -832,11 +865,65 @@ class LogicAniLife(LogicModuleBase): return jsonify("") elif sub == "web_list": return jsonify(ModelAniLifeItem.web_list(request)) - + elif sub == "db_remove": + return jsonify(ModelAniLifeItem.delete_by_id(req.form["id"])) except Exception as e: P.logger.error("Exception:%s", e) P.logger.error(traceback.format_exc()) + @staticmethod + def add_whitelist(*args): + ret = {} + + logger.debug(f"args: {args}") + try: + + if len(args) == 0: + code = str(LogicAniLife.current_data["code"]) + else: + code = str(args[0]) + + print(code) + + whitelist_program = P.ModelSetting.get("anilife_auto_code_list") + # whitelist_programs = [ + # str(x.strip().replace(" ", "")) + # for x in whitelist_program.replace("\n", "|").split("|") + # ] + whitelist_programs = [ + str(x.strip()) for x in whitelist_program.replace("\n", "|").split("|") + ] + + if code not in whitelist_programs: + whitelist_programs.append(code) + whitelist_programs = filter( + lambda x: x != "", whitelist_programs + ) # remove blank code + whitelist_program = "|".join(whitelist_programs) + entity = ( + db.session.query(P.ModelSetting) + .filter_by(key="anilife_auto_code_list") + .with_for_update() + .first() + ) + entity.value = whitelist_program + db.session.commit() + ret["ret"] = True + ret["code"] = code + if len(args) == 0: + return LogicAniLife.current_data + else: + return ret + else: + ret["ret"] = False + ret["log"] = "이미 추가되어 있습니다." + except Exception as e: + logger.error("Exception:%s", e) + logger.error(traceback.format_exc()) + ret["ret"] = False + ret["log"] = str(e) + return ret + def setting_save_after(self): if self.queue.get_max_ffmpeg_count() != P.ModelSetting.get_int( "anilife_max_ffmpeg_process_count" @@ -846,7 +933,12 @@ class LogicAniLife(LogicModuleBase): ) def scheduler_function(self): - pass + logger.debug(f"ohli24 scheduler_function::=========================") + + content_code_list = P.ModelSetting.get_list("ohli24_auto_code_list", "|") + url = f'{P.ModelSetting.get("anilife_url")}/dailyani' + if "all" in content_code_list: + ret_data = LogicAniLife.get_auto_anime_info(self, url=url) def plugin_load(self): self.queue = FfmpegQueue( @@ -882,8 +974,7 @@ class LogicAniLife(LogicModuleBase): .text_content() .strip() ) - # print(des_items1) - # print(len(des_items)) + des = {} des_key = [ "_otit", @@ -1315,6 +1406,10 @@ class ModelAniLifeItem(db.Model): ) return ret + def save(self): + db.session.add(self) + db.session.commit() + @classmethod def get_by_id(cls, idx): return db.session.query(cls).filter_by(id=idx).first() @@ -1323,9 +1418,11 @@ class ModelAniLifeItem(db.Model): def get_by_anilife_id(cls, anilife_id): return db.session.query(cls).filter_by(anilife_id=anilife_id).first() - def save(self): - db.session.add(self) + @classmethod + def delete_by_id(cls, idx): + db.session.query(cls).filter_by(id=idx).delete() db.session.commit() + return True @classmethod def web_list(cls, req): @@ -1370,6 +1467,10 @@ class ModelAniLifeItem(db.Model): ) return query + @classmethod + def get_list_uncompleted(cls): + return db.session.query(cls).filter(cls.status != "completed").all() + @classmethod def append(cls, q): item = ModelAniLifeItem() diff --git a/logic_ohli24.py b/logic_ohli24.py index 9e243ad..05f796f 100644 --- a/logic_ohli24.py +++ b/logic_ohli24.py @@ -804,7 +804,7 @@ class Ohli24QueueEntity(FfmpegQueueEntity): ourls = parse.urlparse(url) headers = { - "referer": f"{ourls.scheme}://{ourls.netloc}", + "Referer": f"{ourls.scheme}://{ourls.netloc}", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Whale/3.12.129.46 Safari/537.36", } logger.debug("make_episode_info()::url==> %s", url) diff --git a/templates/anime_downloader_anilife_category.html b/templates/anime_downloader_anilife_category.html index 17335b1..13091c2 100644 --- a/templates/anime_downloader_anilife_category.html +++ b/templates/anime_downloader_anilife_category.html @@ -1,5 +1,25 @@ {% extends "base.html" %} {% block content %} - +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
-
@@ -70,6 +90,13 @@ enableAutoReload: true // it will reload the new image when validating attributes changes }); observer.observe(); + const loader = document.getElementById("preloader"); + + const dismissLoadingScreen = async function () { + console.log("Before the delay") + // await delay(2.5); + loader.style.display = "none"; + }; const get_anime_list = (type, page) => { @@ -128,6 +155,7 @@ div_visible = true console.log(div_visible) } + dismissLoadingScreen() next_page = page + 1 } }) @@ -660,5 +688,126 @@ body { background-image: linear-gradient(90deg, #233f48, #6c6fa2, #768dae); } + + .demo { + width: 100px; + height: 102px; + border-radius: 100%; + position: absolute; + top: 45%; + left: calc(50% - 50px); + } + + .circle { + width: 100%; + height: 100%; + position: absolute; + } + + .circle .inner { + width: 100%; + height: 100%; + border-radius: 100%; + border: 5px solid rgba(0, 255, 170, 0.7); + border-right: none; + border-top: none; + backgroudn-clip: padding; + box-shadow: inset 0px 0px 10px rgba(0, 255, 170, 0.15); + } + + @-webkit-keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } + } + + @keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } + } + + .circle:nth-of-type(0) { + transform: rotate(0deg); + } + + .circle:nth-of-type(0) .inner { + -webkit-animation: spin 2s infinite linear; + animation: spin 2s infinite linear; + } + + .circle:nth-of-type(1) { + transform: rotate(70deg); + } + + .circle:nth-of-type(1) .inner { + -webkit-animation: spin 2s infinite linear; + animation: spin 2s infinite linear; + } + + .circle:nth-of-type(2) { + transform: rotate(140deg); + } + + .circle:nth-of-type(2) .inner { + -webkit-animation: spin 2s infinite linear; + animation: spin 2s infinite linear; + } + + .demo { + -webkit-animation: spin 5s infinite linear; + animation: spin 5s infinite linear; + background: rgba(0, 0, 0, 0.2); + background: radial-gradient(#222, #000); + bottom: 0; + left: 0; + overflow: hidden; + /*position: fixed;*/ + right: 0; + /*top: 0;*/ + z-index: 99999; + opacity: 0.5; + margin: 0 auto; + transform: translate(-50%, -50%); + position: absolute; + top: 50%; + + } + + .loader-inner { + bottom: 0; + height: 60px; + left: 0; + margin: auto; + position: absolute; + right: 0; + top: 0; + width: 100px; + } + + #preloader { + /*background-color: green;*/ + /*color: white;*/ + /*height: 100vh;*/ + /*width: 100%;*/ + /*position: fixed;*/ + /*z-index: 100;*/ + background: rgba(0, 0, 0, 0.2); + background: radial-gradient(#222, #000); + bottom: 0; + left: 0; + overflow: hidden; + position: fixed; + right: 0; + top: 0; + z-index: 99999; + opacity: 0.5; + } {% endblock %} diff --git a/templates/anime_downloader_anilife_request.html b/templates/anime_downloader_anilife_request.html index f0aff4f..db05839 100644 --- a/templates/anime_downloader_anilife_request.html +++ b/templates/anime_downloader_anilife_request.html @@ -2,7 +2,7 @@
-
+
@@ -55,9 +55,48 @@ return result; } + const loader = document.getElementById("preloader"); + + const dismissLoadingScreen = async function () { + console.log("Before the delay") + // await delay(2.5); + loader.style.display = "none"; + }; + + const wait_seconds = function () { + // REFERENCE: https://www.w3schools.com/jsref/met_win_settimeout.asp + let result = setTimeout(dismissLoadingScreen, 2500); + console.log(result) + }; + const init = function () { + + } + + function delay(n) { + return new Promise(function (resolve) { + setTimeout(resolve, n * 1000); + }); + } + + async function myAsyncFunction() { + //Do what you want here + console.log("Before the delay") + + await delay(2.5); + + console.log("After the delay") + //Do what you want here too + + } + + // myAsyncFunction(); + // window.addEventListener("DOMContentLoaded", dismissLoadingScreen); + + // window.addEventListener("DOMContentLoaded", wait_seconds); + function analyze(wr_id, bo_table) { - e.preventDefault(); - e.stopPropagation() + // e.preventDefault(); + // e.stopPropagation() // e.preventDefault(); const code = document.getElementById("code").value console.log(code) @@ -184,6 +223,7 @@ $("#loader").css("display", 'none') // console.log('wr_id::', params.wr_id) + }); $("#analysis_btn").unbind("click").bind('click', function (e) { @@ -203,7 +243,9 @@ if (ret.ret === 'success' && ret.data != null) { // {#console.log(ret.code)#} console.log(ret.data) + make_program(ret.data) + dismissLoadingScreen() } else { $.notify('분석 실패
' + ret.log, {type: 'warning'}); } @@ -393,6 +435,25 @@ margin-top: 10px; } + #preloader { + /*background-color: green;*/ + /*color: white;*/ + /*height: 100vh;*/ + /*width: 100%;*/ + /*position: fixed;*/ + /*z-index: 100;*/ + background: rgba(0, 0, 0, 0.2); + background: radial-gradient(#222, #000); + bottom: 0; + left: 0; + overflow: hidden; + position: fixed; + right: 0; + top: 0; + z-index: 99999; + opacity: 0.5; + } + .loader { background: rgb(0, 0, 0, 0.8); background: radial-gradient(#222, #000); diff --git a/templates/anime_downloader_ohli24_category.html b/templates/anime_downloader_ohli24_category.html index 75b8e82..7c48ac8 100644 --- a/templates/anime_downloader_ohli24_category.html +++ b/templates/anime_downloader_ohli24_category.html @@ -1,4 +1,24 @@ {% extends "base.html" %} {% block content %} + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/anime_downloader_ohli24_request.html b/templates/anime_downloader_ohli24_request.html index 72a4e09..4fc9674 100644 --- a/templates/anime_downloader_ohli24_request.html +++ b/templates/anime_downloader_ohli24_request.html @@ -1,366 +1,547 @@ {% extends "base.html" %} {% block content %} - +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
-
- {{ macros.setting_input_text_and_buttons('code', '작품 Code', - [['analysis_btn', '분석'], ['go_ohli24_btn', 'Go OHLI24']], desc='예) - "https://ohli24.net/c/녹을 먹는 비스코" 이나 "녹을 먹는 비스코"') }} -
-
-
-
+
+ {{ macros.setting_input_text_and_buttons('code', '작품 Code', + [['analysis_btn', '분석'], ['go_ohli24_btn', 'Go OHLI24']], desc='예) + "https://ohli24.net/c/녹을 먹는 비스코" 이나 "녹을 먹는 비스코"') }} +
+
+
+
{% endblock %}