From 5358b597735186a14d2350f8b510417e360aa913 Mon Sep 17 00:00:00 2001 From: projectdx Date: Tue, 30 Dec 2025 20:34:02 +0900 Subject: [PATCH] feat: Implement early download slot release for special CDNs, add mobile UI fixes, and introduce new plugin structure. --- lib/cdndania_downloader.py | 37 +- lib/ffmpeg_queue_v1.py | 29 +- mod_ohli24.py | 279 +++++---- plugin.py | 2 + templates/anime_downloader_anilife_list.html | 26 + templates/anime_downloader_anilife_queue.html | 26 + .../anime_downloader_anilife_request.html | 26 + .../anime_downloader_anilife_search.html | 26 + templates/anime_downloader_linkkf_list.html | 26 + templates/anime_downloader_linkkf_queue.html | 26 + .../anime_downloader_linkkf_request.html | 26 + templates/anime_downloader_linkkf_search.html | 26 + templates/anime_downloader_ohli24_list.html | 542 ++++++++++++++++-- templates/anime_downloader_ohli24_queue.html | 26 + .../anime_downloader_ohli24_request.html | 1 + templates/anime_downloader_ohli24_search.html | 26 + .../anime_downloader_ohli24_setting.html | 1 + 17 files changed, 966 insertions(+), 185 deletions(-) create mode 100644 plugin.py diff --git a/lib/cdndania_downloader.py b/lib/cdndania_downloader.py index dca1e5b..0f8e9e0 100644 --- a/lib/cdndania_downloader.py +++ b/lib/cdndania_downloader.py @@ -20,14 +20,16 @@ logger = logging.getLogger(__name__) class CdndaniaDownloader: """cdndania.com 전용 다운로더 (세션 기반 보안 우회)""" - def __init__(self, iframe_src, output_path, referer_url=None, callback=None, proxy=None, threads=16): + def __init__(self, iframe_src, output_path, referer_url=None, callback=None, proxy=None, threads=16, on_download_finished=None): self.iframe_src = iframe_src # cdndania.com 플레이어 iframe URL self.output_path = output_path self.referer_url = referer_url or "https://ani.ohli24.com/" self.callback = callback self.proxy = proxy self.threads = threads + self.on_download_finished = on_download_finished self.cancelled = False + self.released = False # 조기 반환 여부 # 진행 상황 추적 self.start_time = None @@ -92,6 +94,13 @@ class CdndaniaDownloader: content = f.read().strip() if content: progress = json.loads(content) + # 조기 반환 체크 (merging 상태이면 네트워크 완료로 간주) + status = progress.get('status', 'downloading') + if status == 'merging' and not self.released: + if self.on_download_finished: + self.on_download_finished() + self.released = True + if self.callback and progress.get('percent', 0) > 0: self.callback( percent=progress.get('percent', 0), @@ -164,17 +173,21 @@ def _download_worker(iframe_src, output_path, referer_url, proxy, progress_path, ) log = logging.getLogger(__name__) - def update_progress(percent, current, total, speed, elapsed): + def update_progress(percent, current, total, speed, elapsed, status=None): """진행 상황을 파일에 저장""" try: + data = { + 'percent': percent, + 'current': current, + 'total': total, + 'speed': speed, + 'elapsed': elapsed + } + if status: + data['status'] = status + with open(progress_path, 'w') as f: - json.dump({ - 'percent': percent, - 'current': current, - 'total': total, - 'speed': speed, - 'elapsed': elapsed - }, f) + json.dump(data, f) except: pass @@ -350,7 +363,8 @@ def _download_worker(iframe_src, output_path, referer_url, proxy, progress_path, total_segments = len(segments) log.info(f"Temp directory: {temp_dir}") - log.info(f"Starting parallel download with {threads} threads for {total_segments} segments...") + # 다운로드 worker + log.info(f"Starting optimized download: Binary Merge Mode (Threads: {threads})") # 세그먼트 다운로드 함수 def download_segment(index, url): @@ -422,6 +436,9 @@ def _download_worker(iframe_src, output_path, referer_url, proxy, progress_path, log.info("All segments downloaded successfully.") + # 조기 반환 신호 (merging 상태 기록) + update_progress(100, total_segments, total_segments, "", "", status="merging") + # 7. ffmpeg로 합치기 log.info("Concatenating segments with ffmpeg...") concat_file = os.path.join(temp_dir, "concat.txt") diff --git a/lib/ffmpeg_queue_v1.py b/lib/ffmpeg_queue_v1.py index 165a0ed..28e83d3 100644 --- a/lib/ffmpeg_queue_v1.py +++ b/lib/ffmpeg_queue_v1.py @@ -265,8 +265,8 @@ class FfmpegQueue(object): # [주의] cdndania는 yt-dlp로 받으면 14B 가짜 파일(보안 차단)이 받아지므로 # aria2c 선택 여부와 무관하게 전용 다운로더(CdndaniaDownloader)를 써야 함. # 대신 CdndaniaDownloader 내부에 멀티스레드(16)를 구현하여 속도를 해결함. - if 'cdndania.com' in video_url: - logger.info(f"Detected cdndania.com URL - using Optimized CdndaniaDownloader (curl_cffi + {download_threads} threads)") + if getattr(entity, 'need_special_downloader', False) or 'cdndania.com' in video_url or 'michealcdn.com' in video_url: + logger.info(f"Detected special CDN requirement (flag={getattr(entity, 'need_special_downloader', False)}) - using Optimized CdndaniaDownloader") download_method = "cdndania" logger.info(f"Download method: {download_method}") @@ -298,6 +298,14 @@ class FfmpegQueue(object): if not _iframe_src: # 폴백: headers의 Referer에서 가져오기 _iframe_src = getattr(entity_ref, 'headers', {}).get('Referer', video_url) + # 슬롯 조기 반환을 위한 콜백 + slot_released = [False] + def release_slot(): + if not slot_released[0]: + downloader_self.current_ffmpeg_count -= 1 + slot_released[0] = True + logger.info(f"Download slot released early (Network finished), current_ffmpeg_count: {downloader_self.current_ffmpeg_count}/{downloader_self.max_ffmpeg_count}") + logger.info(f"CdndaniaDownloader iframe_src: {_iframe_src}") downloader = CdndaniaDownloader( iframe_src=_iframe_src, @@ -305,10 +313,13 @@ class FfmpegQueue(object): referer_url="https://ani.ohli24.com/", callback=progress_callback, proxy=_proxy, - threads=download_threads + threads=download_threads, + on_download_finished=release_slot # 조기 반환 콜백 전달 ) elif method == "ytdlp" or method == "aria2c": # yt-dlp 사용 (aria2c 옵션 포함) + # yt-dlp는 내부적으로 병합 과정을 포함하므로 조기 반환이 어려울 수 있음 (추후 지원 고려) + slot_released = [False] from .ytdlp_downloader import YtdlpDownloader logger.info(f"Using yt-dlp downloader (method={method})...") # 엔티티에서 쿠키 파일 가져오기 (있는 경우) @@ -323,8 +334,8 @@ class FfmpegQueue(object): use_aria2c=(method == "aria2c"), threads=download_threads ) - else: + slot_released = [False] # 기본: HLS 다운로더 사용 from .hls_downloader import HlsDownloader logger.info("Using custom HLS downloader for m3u8 URL...") @@ -344,14 +355,16 @@ class FfmpegQueue(object): downloader.cancel() entity_ref.ffmpeg_status_kor = "취소됨" entity_ref.refresh_status() - downloader_self.current_ffmpeg_count -= 1 + if not slot_released[0]: + downloader_self.current_ffmpeg_count -= 1 return success, message = downloader.download() - # 다운로드 완료 후 카운트 감소 - downloader_self.current_ffmpeg_count -= 1 - logger.info(f"Download finished, current_ffmpeg_count: {downloader_self.current_ffmpeg_count}/{downloader_self.max_ffmpeg_count}") + # 다운로드 완료 후 카운트 감소 (이미 반환되었으면 스킵) + if not slot_released[0]: + downloader_self.current_ffmpeg_count -= 1 + logger.info(f"Download finished (Slot released normally), current_ffmpeg_count: {downloader_self.current_ffmpeg_count}/{downloader_self.max_ffmpeg_count}") if success: entity_ref.ffmpeg_status = 7 # COMPLETED diff --git a/mod_ohli24.py b/mod_ohli24.py index e9f16de..635806e 100644 --- a/mod_ohli24.py +++ b/mod_ohli24.py @@ -66,11 +66,23 @@ class LogicOhli24(PluginModuleBase): origin_url = None episode_url = None cookies = None - proxy = "http://192.168.0.2:3138" - proxies = { - "http": proxy, - "https": proxy, - } + + # proxy = "http://192.168.0.2:3138" + # proxies = { + # "http": proxy, + # "https": proxy, + # } + + @classmethod + def get_proxy(cls): + return P.ModelSetting.get("ohli24_proxy_url") + + @classmethod + def get_proxies(cls): + proxy = cls.get_proxy() + if proxy: + return {"http": proxy, "https": proxy} + return None session = requests.Session() @@ -98,6 +110,7 @@ class LogicOhli24(PluginModuleBase): self.db_default = { "ohli24_db_version": "1", + "ohli24_proxy_url": "", "ohli24_url": "https://ani.ohli24.com", "ohli24_download_path": os.path.join(path_data, P.package_name, "ohli24"), "ohli24_auto_make_folder": "True", @@ -252,8 +265,7 @@ class LogicOhli24(PluginModuleBase): P.logger.debug("web_list3") ret = ModelOhli24Item.web_list(req) print(ret) - # return jsonify("test") - # return jsonify(ModelOhli24Item.web_list(req)) + return jsonify(ret) elif sub == "web_list2": @@ -845,7 +857,7 @@ class LogicOhli24(PluginModuleBase): @staticmethod def get_html(url, headers=None, referer=None, stream=False, timeout=60, stealth=False, data=None, method='GET'): - """별도 스레드에서 cloudscraper 실행하여 gevent SSL 충돌 및 Cloudflare 우회""" + """별도 스레드에서 curl_cffi 실행하여 gevent SSL 충돌 및 Cloudflare 우회""" from concurrent.futures import ThreadPoolExecutor, TimeoutError as FuturesTimeoutError import time from urllib import parse @@ -861,32 +873,34 @@ class LogicOhli24(PluginModuleBase): except: pass - def fetch_url_with_cloudscraper(url, headers, timeout, data, method): - """별도 스레드에서 cloudscraper로 실행""" - import cloudscraper - scraper = cloudscraper.create_scraper( - browser={'browser': 'chrome', 'platform': 'darwin', 'mobile': False}, - delay=10 - ) - # 프록시 설정 (필요시 사용) - proxies = LogicOhli24.proxies - if method.upper() == 'POST': - response = scraper.post(url, headers=headers, data=data, timeout=timeout, proxies=proxies) - else: - response = scraper.get(url, headers=headers, timeout=timeout, proxies=proxies) - return response.text + def fetch_url_with_cffi(url, headers, timeout, data, method): + """별도 스레드에서 curl_cffi로 실행""" + from curl_cffi import requests + + # 프록시 설정 + proxies = LogicOhli24.get_proxies() + + with requests.Session(impersonate="chrome120") as session: + # 헤더 설정 + if headers: + session.headers.update(headers) + + if method.upper() == 'POST': + response = session.post(url, data=data, timeout=timeout, proxies=proxies) + else: + response = session.get(url, timeout=timeout, proxies=proxies) + return response.text response_data = "" if headers is None: headers = { - "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", - "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "accept-language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", + "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7", } if referer: - # Referer 인코딩 if '://' in referer: try: scheme, netloc, path, params, query, fragment = parse.urlparse(referer) @@ -895,18 +909,18 @@ class LogicOhli24(PluginModuleBase): referer = parse.urlunparse((scheme, netloc, path, params, query, fragment)) except: pass - headers["referer"] = referer - elif "referer" not in headers: - headers["referer"] = "https://ani.ohli24.com" + headers["Referer"] = referer + elif "Referer" not in headers and "referer" not in headers: + headers["Referer"] = "https://ani.ohli24.com" max_retries = 3 for attempt in range(max_retries): try: - logger.debug(f"get_html (cloudscraper in thread) {method} attempt {attempt + 1}: {url}") + logger.debug(f"get_html (curl_cffi in thread) {method} attempt {attempt + 1}: {url}") - # ThreadPoolExecutor로 별도 스레드에서 cloudscraper 실행 + # ThreadPoolExecutor로 별도 스레드에서 실행 with ThreadPoolExecutor(max_workers=1) as executor: - future = executor.submit(fetch_url_with_cloudscraper, url, headers, timeout, data, method) + future = executor.submit(fetch_url_with_cffi, url, headers, timeout, data, method) response_data = future.result(timeout=timeout + 10) if response_data and (len(response_data) > 10 or method.upper() == 'POST'): @@ -983,8 +997,10 @@ class LogicOhli24(PluginModuleBase): return False def callback_function(self, **args): - logger.debug("callback_function============") - logger.debug(args) + logger.debug(f"callback_function invoked with args: {args}") + if 'status' in args: + logger.debug(f"Status: {args['status']}") + refresh_type = None if args["type"] == "status_change": if args["status"] == SupportFfmpeg.Status.DOWNLOADING: @@ -1003,11 +1019,15 @@ class LogicOhli24(PluginModuleBase): # socketio.emit("notify", data, namespace='/framework', broadcast=True) refresh_type = "add" elif args["type"] == "last": + entity = self.queue.get_entity_by_entity_id(args['data']['callback_id']) + if args["status"] == SupportFfmpeg.Status.WRONG_URL: + if entity: entity.download_failed("WRONG_URL") data = {"type": "warning", "msg": "잘못된 URL입니다"} socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "add" elif args["status"] == SupportFfmpeg.Status.WRONG_DIRECTORY: + if entity: entity.download_failed("WRONG_DIRECTORY") data = { "type": "warning", "msg": "잘못된 디렉토리입니다.
" + args["data"]["save_fullpath"], @@ -1015,6 +1035,7 @@ class LogicOhli24(PluginModuleBase): socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "add" elif args["status"] == SupportFfmpeg.Status.ERROR or args["status"] == SupportFfmpeg.Status.EXCEPTION: + if entity: entity.download_failed("ERROR/EXCEPTION") data = { "type": "warning", "msg": "다운로드 시작 실패.
" + args["data"]["save_fullpath"], @@ -1022,6 +1043,7 @@ class LogicOhli24(PluginModuleBase): socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "add" elif args["status"] == SupportFfmpeg.Status.USER_STOP: + if entity: entity.download_failed("USER_STOP") data = { "type": "warning", "msg": "다운로드가 중지 되었습니다.
" + args["data"]["save_fullpath"], @@ -1041,6 +1063,7 @@ class LogicOhli24(PluginModuleBase): refresh_type = "last" elif args["status"] == SupportFfmpeg.Status.TIME_OVER: + if entity: entity.download_failed("TIME_OVER") data = { "type": "warning", "msg": "시간초과로 중단 되었습니다.
" + args["data"]["save_fullpath"], @@ -1049,6 +1072,7 @@ class LogicOhli24(PluginModuleBase): socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "last" elif args["status"] == SupportFfmpeg.Status.PF_STOP: + if entity: entity.download_failed("PF_STOP") data = { "type": "warning", "msg": "PF초과로 중단 되었습니다.
" + args["data"]["save_fullpath"], @@ -1057,6 +1081,7 @@ class LogicOhli24(PluginModuleBase): socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "last" elif args["status"] == SupportFfmpeg.Status.FORCE_STOP: + if entity: entity.download_failed("FORCE_STOP") data = { "type": "warning", "msg": "강제 중단 되었습니다.
" + args["data"]["save_fullpath"], @@ -1065,6 +1090,7 @@ class LogicOhli24(PluginModuleBase): socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "last" elif args["status"] == SupportFfmpeg.Status.HTTP_FORBIDDEN: + if entity: entity.download_failed("HTTP_FORBIDDEN") data = { "type": "warning", "msg": "403에러로 중단 되었습니다.
" + args["data"]["save_fullpath"], @@ -1073,6 +1099,8 @@ class LogicOhli24(PluginModuleBase): socketio.emit("notify", data, namespace="/framework", broadcast=True) refresh_type = "last" elif args["status"] == SupportFfmpeg.Status.ALREADY_DOWNLOADING: + # Already downloading usually means logic error or race condition, maybe not fail DB? + # Keeping as is for now unless requested. data = { "type": "warning", "msg": "임시파일폴더에 파일이 있습니다.
" + args["data"]["temp_fullpath"], @@ -1103,11 +1131,17 @@ class Ohli24QueueEntity(FfmpegQueueEntity): self.srt_url = None self.headers = None self.cookies_file = None # yt-dlp용 CDN 세션 쿠키 파일 경로 + self.need_special_downloader = False # CDN 보안 우회 다운로더 필요 여부 # Todo::: 임시 주석 처리 self.make_episode_info() def refresh_status(self): + # ffmpeg_queue_v1.py에서 실패 처리(-1)된 경우 DB 업데이트 트리거 + if getattr(self, 'ffmpeg_status', 0) == -1: + reason = getattr(self, 'ffmpeg_status_kor', 'Unknown Error') + self.download_failed(reason) + self.module_logic.socketio_callback("status", self.as_dict()) # 추가: /queue 네임스페이스로도 명시적으로 전송 try: @@ -1133,7 +1167,14 @@ class Ohli24QueueEntity(FfmpegQueueEntity): db_entity = ModelOhli24Item.get_by_ohli24_id(self.info["_id"]) if db_entity is not None: db_entity.status = "completed" - db_entity.complated_time = datetime.now() + db_entity.completed_time = datetime.now() + db_entity.save() + + def download_failed(self, reason): + logger.debug(f"download failed.......!! reason: {reason}") + db_entity = ModelOhli24Item.get_by_ohli24_id(self.info["_id"]) + if db_entity is not None: + db_entity.status = "failed" db_entity.save() # Get episode info from OHLI24 site @@ -1154,74 +1195,10 @@ class Ohli24QueueEntity(FfmpegQueueEntity): } logger.debug(f"make_episode_info()::url==> {url}") logger.info(f"self.info:::> {self.info}") - - # Step 1: 에피소드 페이지에서 cdndania.com iframe 찾기 - text = LogicOhli24.get_html(url, headers=headers, referer=f"{ourls.scheme}://{ourls.netloc}") - - # 디버깅: HTML에 cdndania 있는지 확인 - if "cdndania" in text: - logger.info("cdndania found in HTML") - else: - logger.warning("cdndania NOT found in HTML - page may be dynamically loaded") - logger.debug(f"HTML snippet: {text[:1000]}") - - soup = BeautifulSoup(text, "lxml") - - # mcpalyer 클래스 내의 iframe 찾기 - player_div = soup.find("div", class_="mcpalyer") - logger.debug(f"player_div (mcpalyer): {player_div is not None}") - - if not player_div: - player_div = soup.find("div", class_="embed-responsive") - logger.debug(f"player_div (embed-responsive): {player_div is not None}") - - iframe = None - if player_div: - iframe = player_div.find("iframe") - logger.debug(f"iframe in player_div: {iframe is not None}") - if not iframe: - iframe = soup.find("iframe", src=re.compile(r"cdndania\.com")) - logger.debug(f"iframe with cdndania src: {iframe is not None}") - if not iframe: - # 모든 iframe 찾기 - all_iframes = soup.find_all("iframe") - logger.debug(f"Total iframes found: {len(all_iframes)}") - for i, f in enumerate(all_iframes): - logger.debug(f"iframe {i}: src={f.get('src', 'no src')}") - if all_iframes: - iframe = all_iframes[0] - - if not iframe or not iframe.get("src"): - logger.error("No iframe found on episode page") - return - - iframe_src = iframe.get("src") - logger.info(f"Found cdndania iframe: {iframe_src}") - - # Step 2: cdndania.com 페이지에서 m3u8 URL 추출 - video_url, vtt_url, cookies_file = self.extract_video_from_cdndania(iframe_src, url) - - if not video_url: - logger.error("Failed to extract video URL from cdndania") - return - - self.url = video_url - self.srt_url = vtt_url - self.cookies_file = cookies_file # yt-dlp용 세션 쿠키 파일 - self.iframe_src = iframe_src # CdndaniaDownloader용 원본 iframe URL - logger.info(f"Video URL: {self.url}") - if self.srt_url: - logger.info(f"Subtitle URL: {self.srt_url}") - if self.cookies_file: - logger.info(f"Cookies file: {self.cookies_file}") - - # 헤더 설정 - self.headers = { - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", - "Referer": iframe_src, - } - + # ------------------------------------------------------------------ + # [METADATA PARSING] - Extract title, season, epi info first! + # ------------------------------------------------------------------ # 파일명 생성 match = re.compile(r"(?P.*?)\s*((?P<season>\d+)%s)?\s*((?P<epi_no>\d+)%s)" % ("기", "화")).search( self.info["title"] @@ -1250,8 +1227,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity): self.epi_queue = epi_no self.filename = Util.change_text_for_use_filename(ret) logger.info(f"self.filename::> {self.filename}") + + # Savepath 생성 self.savepath = P.ModelSetting.get("ohli24_download_path") - logger.info(f"self.savepath::> {self.savepath}") if P.ModelSetting.get_bool("ohli24_auto_make_folder"): if self.info["day"].find("완결") != -1: @@ -1268,8 +1246,82 @@ class Ohli24QueueEntity(FfmpegQueueEntity): self.filepath = os.path.join(self.savepath, self.filename) if not os.path.exists(self.savepath): os.makedirs(self.savepath) + logger.info(f"self.savepath::> {self.savepath}") + + + # ------------------------------------------------------------------ + # [VIDEO EXTRACTION] + # ------------------------------------------------------------------ + # Step 1: 에피소드 페이지에서 cdndania.com iframe 찾기 + text = LogicOhli24.get_html(url, headers=headers, referer=f"{ourls.scheme}://{ourls.netloc}") - # 자막 다운로드 + # 디버깅: HTML에 cdndania 있는지 확인 + if "cdndania" in text: + logger.info("cdndania found in HTML") + else: + logger.warning("cdndania NOT found in HTML - page may be dynamically loaded") + # logger.debug(f"HTML snippet: {text[:1000]}") + + soup = BeautifulSoup(text, "lxml") + + # mcpalyer 클래스 내의 iframe 찾기 + player_div = soup.find("div", class_="mcpalyer") + # logger.debug(f"player_div (mcpalyer): {player_div is not None}") + + if not player_div: + player_div = soup.find("div", class_="embed-responsive") + # logger.debug(f"player_div (embed-responsive): {player_div is not None}") + + iframe = None + if player_div: + iframe = player_div.find("iframe") + # logger.debug(f"iframe in player_div: {iframe is not None}") + if not iframe: + iframe = soup.find("iframe", src=re.compile(r"cdndania\.com")) + # logger.debug(f"iframe with cdndania src: {iframe is not None}") + if not iframe: + # 모든 iframe 찾기 + all_iframes = soup.find_all("iframe") + # logger.debug(f"Total iframes found: {len(all_iframes)}") + if all_iframes: + iframe = all_iframes[0] + + if not iframe or not iframe.get("src"): + logger.error("No iframe found on episode page") + return + + iframe_src = iframe.get("src") + logger.info(f"Found cdndania iframe: {iframe_src}") + self.iframe_src = iframe_src + # CDN 보안 우회 다운로더 사용 플래그 설정 (도메인 무관하게 모듈 강제 선택) + self.need_special_downloader = True + + # Step 2: cdndania.com 페이지에서 m3u8 URL 추출 + video_url, vtt_url, cookies_file = self.extract_video_from_cdndania(iframe_src, url) + + if not video_url: + logger.error("Failed to extract video URL from cdndania") + return + + self.url = video_url + self.srt_url = vtt_url + self.cookies_file = cookies_file # yt-dlp용 세션 쿠키 파일 + self.iframe_src = iframe_src # CdndaniaDownloader용 원본 iframe URL + logger.info(f"Video URL: {self.url}") + if self.srt_url: + logger.info(f"Subtitle URL: {self.srt_url}") + if self.cookies_file: + logger.info(f"Cookies file: {self.cookies_file}") + + # 헤더 설정 (Video Download용) + self.headers = { + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", + "Referer": iframe_src, + } + + # ------------------------------------------------------------------ + # [SUBTITLE DOWNLOAD] + # ------------------------------------------------------------------ if self.srt_url and "thumbnails.vtt" not in self.srt_url: try: srt_filepath = os.path.join(self.savepath, self.filename.replace(".mp4", ".ko.srt")) @@ -1318,16 +1370,20 @@ class Ohli24QueueEntity(FfmpegQueueEntity): browser={'browser': 'chrome', 'platform': 'darwin', 'mobile': False}, delay=10 ) - proxies = LogicOhli24.proxies + proxies = LogicOhli24.get_proxies() # getVideo API 호출 - api_url = f"https://cdndania.com/player/index.php?data={video_id}&do=getVideo" + # iframe 도메인 자동 감지 (cdndania.com -> michealcdn.com 등) + parsed_iframe = parse.urlparse(iframe_src) + iframe_domain = f"{parsed_iframe.scheme}://{parsed_iframe.netloc}" + + api_url = f"{iframe_domain}/player/index.php?data={video_id}&do=getVideo" headers = { "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "x-requested-with": "XMLHttpRequest", "content-type": "application/x-www-form-urlencoded; charset=UTF-8", "referer": iframe_src, - "origin": "https://cdndania.com" + "origin": iframe_domain } post_data = { "hash": video_id, @@ -1375,11 +1431,14 @@ class Ohli24QueueEntity(FfmpegQueueEntity): except Exception as json_err: logger.warning(f"Failed to parse API JSON: {json_err}") + logger.debug(f"API Response Text (First 1000 chars): {json_text[:1000] if json_text else 'Empty'}") # API 실패 시 기존 방식(정규식)으로 폴백 if not video_url: logger.info("API extraction failed, falling back to regex") - html_response = scraper.get(iframe_src, headers={"referer": referer_url}, timeout=30, proxies=proxies) + # Ensure referer is percent-encoded for headers (avoids UnicodeEncodeError) + encoded_referer = parse.quote(referer_url, safe=":/?#[]@!$&'()*+,;=%") + html_response = scraper.get(iframe_src, headers={"referer": encoded_referer}, timeout=30, proxies=proxies) html_content = html_response.text if html_content: # m3u8 URL 패턴 찾기 @@ -1399,6 +1458,10 @@ class Ohli24QueueEntity(FfmpegQueueEntity): logger.info(f"Found video URL via regex: {video_url}") break + if not video_url: + logger.warning("Regex extraction failed. Dumping HTML content.") + logger.debug(f"HTML Content (First 2000 chars): {html_content[:2000]}") + if not vtt_url: vtt_match = re.search(r"['\"]([^'\"]*\.vtt[^'\"]*)['\"]", html_content) if vtt_match: diff --git a/plugin.py b/plugin.py new file mode 100644 index 0000000..4065168 --- /dev/null +++ b/plugin.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from flaskfarm.lib.plugin import * diff --git a/templates/anime_downloader_anilife_list.html b/templates/anime_downloader_anilife_list.html index 9ca25b1..3845fd0 100644 --- a/templates/anime_downloader_anilife_list.html +++ b/templates/anime_downloader_anilife_list.html @@ -276,4 +276,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} \ No newline at end of file diff --git a/templates/anime_downloader_anilife_queue.html b/templates/anime_downloader_anilife_queue.html index 0e10b55..865ee20 100644 --- a/templates/anime_downloader_anilife_queue.html +++ b/templates/anime_downloader_anilife_queue.html @@ -422,4 +422,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_anilife_request.html b/templates/anime_downloader_anilife_request.html index e133d0f..bde18df 100644 --- a/templates/anime_downloader_anilife_request.html +++ b/templates/anime_downloader_anilife_request.html @@ -1097,4 +1097,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_anilife_search.html b/templates/anime_downloader_anilife_search.html index ae8debd..e810020 100644 --- a/templates/anime_downloader_anilife_search.html +++ b/templates/anime_downloader_anilife_search.html @@ -1052,4 +1052,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_linkkf_list.html b/templates/anime_downloader_linkkf_list.html index beb4b3b..1d3ec23 100644 --- a/templates/anime_downloader_linkkf_list.html +++ b/templates/anime_downloader_linkkf_list.html @@ -250,4 +250,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} \ No newline at end of file diff --git a/templates/anime_downloader_linkkf_queue.html b/templates/anime_downloader_linkkf_queue.html index 67646ef..946eddf 100644 --- a/templates/anime_downloader_linkkf_queue.html +++ b/templates/anime_downloader_linkkf_queue.html @@ -474,4 +474,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_linkkf_request.html b/templates/anime_downloader_linkkf_request.html index f4b3181..d975b90 100644 --- a/templates/anime_downloader_linkkf_request.html +++ b/templates/anime_downloader_linkkf_request.html @@ -1128,4 +1128,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_linkkf_search.html b/templates/anime_downloader_linkkf_search.html index daefeef..06a12a8 100644 --- a/templates/anime_downloader_linkkf_search.html +++ b/templates/anime_downloader_linkkf_search.html @@ -1187,4 +1187,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_ohli24_list.html b/templates/anime_downloader_ohli24_list.html index 6826588..b401629 100644 --- a/templates/anime_downloader_ohli24_list.html +++ b/templates/anime_downloader_ohli24_list.html @@ -2,58 +2,52 @@ {% block content %} <div class="content-cloak"> - <form id="form_search" class="form-inline" style="text-align:left"> - <div class="container-fluid"> - <div class="row show-grid"> - <span class="col-md-4"> - <select id="order" name="order" class="form-control form-control-sm"> - <option value="desc">최근순</option> - <option value="asc">오래된 순</option> - </select> - <select id="option" name="option" class="form-control form-control-sm"> - <option value="all">전체</option> - <option value="completed">완료</option> - </select> - </span> - <span class="col-md-8"> - <input id="search_word" name="search_word" class="form-control form-control-sm w-75" type="text" - placeholder="" aria-label="Search"> - <button id="search" class="btn btn-sm btn-outline-success">검색</button> - <button id="reset_btn" class="btn btn-sm btn-outline-success">리셋</button> - </span> + <form id="form_search" class="form-inline" style="text-align:left; width:100%;"> + <div class="search-container"> + <div class="search-group-left"> + <select id="order" name="order" class="form-control custom-select"> + <option value="desc">최근순</option> + <option value="asc">오래된 순</option> + </select> + <select id="option" name="option" class="form-control custom-select"> + <option value="all">전체</option> + <option value="completed">완료</option> + </select> + </div> + <div class="search-group-right"> + <input id="search_word" name="search_word" class="form-control custom-input" type="text" placeholder="검색어를 입력하세요..." aria-label="Search"> + <button id="search" class="btn custom-btn btn-search"><i class="fa fa-search"></i></button> + <button id="reset_btn" class="btn custom-btn btn-reset"><i class="fa fa-refresh"></i></button> </div> </div> </form> <div id='page1'></div> - {{ macros.m_hr_head_top() }} - {{ macros.m_row_start('0') }} - {{ macros.m_col(2, macros.m_strong('Poster')) }} - {{ macros.m_col(10, macros.m_strong('Info')) }} - {{ macros.m_row_end() }} - {{ macros.m_hr_head_bottom() }} + {# {{ macros.m_hr_head_top() }} #} + {# {{ macros.m_row_start('0') }} #} + {# {{ macros.m_col(2, macros.m_strong('Poster')) }} #} + {# {{ macros.m_col(10, macros.m_strong('Info')) }} #} + {# {{ macros.m_row_end() }} #} + {# {{ macros.m_hr_head_bottom() }} #} <div id="list_div"></div> <div id='page2'></div> </div> - {# <script src="{{ url_for('.static', filename='js/sjva_global1.js') }}"></script>#} - {# <script src="{{ url_for('.static', filename='js/sjva_ui14.js') }}"></script>#} + <script src="{{ url_for('.static', filename='js/sjva_global1.js') }}"></script> + <script src="{{ url_for('.static', filename='js/sjva_ui14.js') }}"></script> <script type="text/javascript"> var package_name = "{{arg['package_name']}}"; var sub = "{{arg['sub']}}"; var current_data = null; $(document).ready(function () { - {#global_sub_request_search('1');#} - console.log('ready') - globalRequestSearchTest('1'); + global_sub_request_search('1'); }); - function globalRequestSearchTest(page, move_top = true) { + function global_sub_request_search(page, move_top = true) { console.log('........................') var formData = getFormdata('#form_search') formData += '&page=' + page; $.ajax({ - {#url: '/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/web_list2',#} url: '/' + package_name + '/ajax/' + sub + '/web_list3', type: "POST", cache: false, @@ -62,10 +56,11 @@ success: function (data) { console.log(data) current_data = data; - {#if (move_top)#} - {# window.scrollTo(0,0);#} - {#make_list(data.list)#} - {#make_page_html(data.paging)#} + if (move_top) { + window.scrollTo(0,0); + } + make_list(data.list); + make_page_html(data.paging); } }); } @@ -107,7 +102,7 @@ global_sub_request_search('1') }); - $("body").on('click', '#remove_btn', function (e) { + $("body").on('click', '.btn-remove', function (e) { e.preventDefault(); id = $(this).data('id'); $.ajax({ @@ -131,35 +126,104 @@ }); }); - $("body").on('click', '#request_btn', function (e) { + $("body").on('click', '.btn-request', function (e) { e.preventDefault(); var content_code = $(this).data('content_code'); $(location).attr('href', '/' + package_name + '/' + sub + '/request?content_code=' + content_code) }); + $("body").on('click', '.btn-json', function (e) { + e.preventDefault(); + var id = $(this).data('id'); + for (i in current_data.list) { + if (current_data.list[i].id == id) { + m_modal(current_data.list[i]) + } + } + }); + + $("body").on('click', '.btn-self-search', function (e) { + e.preventDefault(); + var search_word = $(this).data('title'); + document.getElementById("search_word").value = search_word; + global_sub_request_search('1') + }); + function make_list(data) { - //console.log(data) - str = ''; - for (i in data) { - //console.log(data[i]) - str += m_row_start(); - str += m_col(1, data[i].id); - tmp = (data[i].status == 'completed') ? '완료' : '미완료'; - str += m_col(1, tmp); - tmp = data[i].created_time + '(추가)'; - if (data[i].completed_time != null) - tmp += data[i].completed_time + '(완료)'; - str += m_col(3, tmp) - tmp = data[i].savepath + '<br>' + data[i].filename + '<br><br>'; - tmp2 = m_button('json_btn', 'JSON', [{'key': 'id', 'value': data[i].id}]); - tmp2 += m_button('request_btn', '작품 검색', [{'key': 'content_code', 'value': data[i].content_code}]); - tmp2 += m_button('self_search_btn', '목록 검색', [{'key': 'title', 'value': data[i].title}]); - tmp2 += m_button('remove_btn', '삭제', [{'key': 'id', 'value': data[i].id}]); - tmp += m_button_group(tmp2) - str += m_col(7, tmp) - str += m_row_end(); - if (i != data.length - 1) str += m_hr(); + let str = ''; + for (let i in data) { + const item = data[i]; + const statusClass = (item.status == 'completed') ? 'status-completed' : + (item.status == 'downloading') ? 'status-downloading' : + (item.status == 'failed') ? 'status-failed' : 'status-wait'; + const statusText = (item.status == 'completed') ? 'COMPLETED' : + (item.status == 'downloading') ? 'DOWNLOADING' : + (item.status == 'failed') ? 'FAIL' : 'WAITING'; + + // Thumbnail + let imgHtml = ''; + if (item.thumbnail) { + imgHtml = `<img src="${item.thumbnail}" onerror="this.src='https://via.placeholder.com/60x80?text=No+Img'">`; + } else { + imgHtml = `<img src="https://via.placeholder.com/60x80?text=No+Img">`; + } + + // Date + let createdDate = item.created_time ? item.created_time.split(' ')[0] : ''; + let completedDate = item.completed_time ? item.completed_time.split(' ')[0] : ''; + let dateHtml = `<span class="meta-tag" title="요청일: ${item.created_time}"><i class="fa fa-clock-o"></i> ${createdDate}</span>`; + if (completedDate) { + dateHtml += `<span class="meta-tag" title="완료일: ${item.completed_time}"><i class="fa fa-check-circle"></i> ${completedDate}</span>`; + } + + // Subtitle Line + let subtitleHtml = ''; + if (item.episode_title) { + subtitleHtml = `<div class="episode-subtitle text-muted">${item.episode_title}</div>`; + } + + str += ` + <div class="episode-card"> + <div class="episode-card-body"> + <!-- Left: Thumb --> + <div class="episode-thumb">${imgHtml}</div> + + <!-- Center: Main Info --> + <div class="episode-main-info"> + <div class="episode-title" title="${item.title}">${item.title}</div> + ${subtitleHtml} + <div class="episode-meta"> + <span class="status-badge ${statusClass}">${statusText}</span> + <span class="meta-tag">S${item.season}</span> + <span class="meta-tag">E${item.episode_no}</span> + </div> + <div class="file-path" title="${item.savepath}/${item.filename}"> + <i class="fa fa-folder-open-o"></i> ${item.filename} + </div> + </div> + + <!-- Right: Date & Actions --> + <div class="episode-right-col"> + <div class="date-info">${dateHtml}</div> + <div class="episode-actions"> + <button data-content_code="${item.content_code}" class="btn btn-outline-info btn-request"> + <i class="fa fa-search"></i> 작품보기 + </button> + <button data-title="${item.title}" class="btn btn-outline-secondary btn-self-search"> + <i class="fa fa-list"></i> 목록검색 + </button> + <button data-id="${item.id}" class="btn btn-outline-dark btn-json"> + <i class="fa fa-code"></i> JSON + </button> + <button data-id="${item.id}" class="btn btn-outline-danger btn-remove"> + <i class="fa fa-trash"></i> 삭제 + </button> + </div> + </div> + </div> + </div> + `; } document.getElementById("list_div").innerHTML = str; } @@ -265,6 +329,311 @@ color: #fff !important; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); } + + /* General Layout Tweaks */ + .container-fluid { + padding-left: 10px !important; + padding-right: 10px !important; + max-width: 1600px; + margin: 0 auto; + } + + .content-cloak { + padding-top: 10px; + } + + /* Search Bar Design */ + .search-container { + background: rgba(30, 41, 59, 0.7); + backdrop-filter: blur(10px); + border: 1px solid rgba(255, 255, 255, 0.08); + border-radius: 12px; + padding: 10px; + margin-bottom: 20px; + display: flex; + flex-wrap: wrap; + gap: 10px; + align-items: center; + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); + } + + .search-group-left { + display: flex; + gap: 8px; + flex: 0 0 auto; + } + + .search-group-right { + display: flex; + gap: 8px; + flex: 1; + } + + /* Custom Form Controls */ + .custom-select, .custom-input { + background-color: rgba(15, 23, 42, 0.6) !important; + border: 1px solid rgba(148, 163, 184, 0.2) !important; + color: #e2e8f0 !important; + border-radius: 8px !important; + padding: 6px 12px !important; + height: 38px !important; + font-size: 13px !important; + transition: all 0.2s; + } + + .custom-select:focus, .custom-input:focus { + border-color: #3b82f6 !important; + box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important; + outline: none; + } + + .custom-btn { + border-radius: 8px !important; + padding: 0 16px !important; + height: 38px !important; + font-weight: 600 !important; + display: flex; + align-items: center; + gap: 6px; + transition: all 0.2s; + border: none !important; + } + + .btn-search { + background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); + color: white !important; + } + .btn-search:hover { box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); transform: translateY(-1px); } + + .btn-reset { + background: rgba(148, 163, 184, 0.1); + color: #94a3b8 !important; + } + .btn-reset:hover { background: rgba(148, 163, 184, 0.2); color: white !important; } + + /* List Container - List View */ + #list_div { + display: flex; + flex-direction: column; + gap: 8px; + padding: 0 5px; + width: 100%; + } + + /* Episode Card Style */ + .episode-card { + display: flex; + flex-direction: column; + background: linear-gradient(135deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.85) 100%); + border-radius: 12px; + border: 1px solid rgba(148, 163, 184, 0.12); + overflow: hidden; + transition: all 0.2s ease; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); + position: relative; + } + + .episode-card:hover { + transform: translateY(-2px); + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); + border-color: rgba(96, 165, 250, 0.4); + background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%); + z-index: 10; + } + + .episode-card-body { + padding: 10px; + display: flex; + flex-direction: row; /* Mobile Default: Row for proper structure */ + flex-wrap: wrap; /* Allow wrapping on small mobile */ + width: 100%; + } + + /* Inner Components */ + .episode-thumb { + width: 60px; + height: 80px; + flex-shrink: 0; + margin-right: 12px; + border-radius: 8px; + overflow: hidden; + background-color: #1e293b; + } + + .episode-thumb img { + width: 100%; + height: 100%; + object-fit: cover; + } + + .episode-main-info { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + justify-content: center; + } + + .episode-title { + color: #f1f5f9; + font-weight: 600; + font-size: 14px; + line-height: 1.4; + margin-bottom: 2px; + word-break: break-all; + } + + .episode-subtitle { + font-size: 12px; + color: #94a3b8; + margin-bottom: 4px; + line-height: 1.3; + display: block; + } + + .episode-meta { + font-size: 11px; + color: #94a3b8; + display: flex; + flex-wrap: wrap; + gap: 6px; + align-items: center; + margin-bottom: 4px; + } + + .meta-tag { + background: rgba(148, 163, 184, 0.1); + padding: 1px 5px; + border-radius: 4px; + color: #cbd5e1; + } + + .status-badge { + font-size: 10px; + font-weight: 700; + padding: 2px 5px; + border-radius: 4px; + text-transform: uppercase; + min-width: 60px; + text-align: center; + } + .status-completed { background: rgba(16, 185, 129, 0.2); color: #34d399; } + .status-wait { background: rgba(245, 158, 11, 0.2); color: #fbbf24; } + .status-downloading { background: rgba(59, 130, 246, 0.2); color: #60a5fa; } + .status-failed { background: rgba(239, 68, 68, 0.2); color: #f87171; } + + .file-path { + font-size: 11px; + color: #64748b; + word-break: break-all; + margin-top: 2px; + display: block; + } + + /* Right Column (Mobile) */ + .episode-right-col { + width: 100%; + margin-top: 10px; + padding-top: 10px; + border-top: 1px solid rgba(255, 255, 255, 0.05); + display: flex; + flex-direction: column; + gap: 8px; + } + + .date-info { + font-size: 11px; + color: #94a3b8; + display: flex; + gap: 10px; + } + + .episode-actions { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 5px; + } + + .episode-actions .btn { + font-size: 11px !important; + padding: 4px 8px !important; + white-space: nowrap; + width: 100%; + } + + /* Desktop List View Transformation */ + @media (min-width: 768px) { + .episode-card { + flex-direction: row; + align-items: center; + padding: 10px; + min-height: 80px; + } + + .episode-card-body { + flex-wrap: nowrap; + align-items: stretch; + padding: 0; + width: 100%; + } + + .episode-thumb { + margin-right: 15px; + margin-bottom: 0; + } + + .episode-main-info { + margin-bottom: 0; + justify-content: center; + } + + .episode-title { + font-size: 15px; + word-break: keep-all; + } + + .episode-right-col { + width: auto; + margin-top: 0; + padding-top: 0; + border-top: none; + margin-left: auto; /* Push to right */ + align-items: flex-end; + justify-content: center; + min-width: 220px; + } + + .date-info { + justify-content: flex-end; + margin-bottom: 5px; + order: -1; + } + + .episode-actions { + display: flex; + flex-direction: row; + gap: 5px; + } + + .episode-actions .btn { + width: auto; + } + + .episode-thumb img { + width: 100%; + height: 100%; + object-fit: cover; + } + } + + /* Hide Original Headers */ + .show-grid { margin-bottom: 20px; } + .container-fluid > div:nth-child(3), /* Head Top HR */ + .container-fluid > div:nth-child(4), /* Headers Row */ + .container-fluid > div:nth-child(5) /* Head Bottom HR */ + { + display: none !important; + } </style> <script type="text/javascript"> @@ -275,4 +644,59 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} + /* Pagination Styling */ + .btn-toolbar { + justify-content: center; + margin: 20px 0; + } + + #page1 .btn-group .btn, #page2 .btn-group .btn { + background: rgba(30, 41, 59, 0.6); + border: 1px solid rgba(255, 255, 255, 0.1); + color: #94a3b8; + padding: 6px 14px; + margin: 0 2px; + border-radius: 6px; + transition: all 0.2s; + } + + #page1 .btn-group .btn:hover, #page2 .btn-group .btn:hover { + background: rgba(255, 255, 255, 0.1); + color: white; + transform: translateY(-1px); + } + + #page1 .btn-group .btn[disabled], #page2 .btn-group .btn[disabled] { + background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); + color: white; + border-color: transparent; + opacity: 1; + box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); + } +</style> {% endblock %} \ No newline at end of file diff --git a/templates/anime_downloader_ohli24_queue.html b/templates/anime_downloader_ohli24_queue.html index 50df3ae..5d863b2 100644 --- a/templates/anime_downloader_ohli24_queue.html +++ b/templates/anime_downloader_ohli24_queue.html @@ -700,4 +700,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} \ No newline at end of file diff --git a/templates/anime_downloader_ohli24_request.html b/templates/anime_downloader_ohli24_request.html index 4172f48..d3acc03 100644 --- a/templates/anime_downloader_ohli24_request.html +++ b/templates/anime_downloader_ohli24_request.html @@ -44,6 +44,7 @@ </form> </div> <!--전체--> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css"> <script src="{{ url_for('.static', filename='js/sjva_ui14.js') }}"></script> <script type="text/javascript"> diff --git a/templates/anime_downloader_ohli24_search.html b/templates/anime_downloader_ohli24_search.html index e31a899..24388b2 100644 --- a/templates/anime_downloader_ohli24_search.html +++ b/templates/anime_downloader_ohli24_search.html @@ -791,4 +791,30 @@ $(document).ready(function(){ }, 100); }); </script> +<style> +/* Mobile Margin Fix */ +@media (max-width: 768px) { + body { overflow-x: hidden !important; padding: 0 !important; margin: 0 !important; } + .container, .container-fluid, .row, form, #program_list, #program_auto_form, #episode_list, .queue-container, #yommi_wrapper, #main_container { + width: 100% !important; max-width: 100% !important; + padding-left: 4px !important; padding-right: 4px !important; + margin-left: 0 !important; margin-right: 0 !important; + box-sizing: border-box !important; + } + .form-group, .form-inline, [class*="col-"] { + flex: 0 0 100% !important; max-width: 100% !important; width: 100% !important; + padding-left: 0 !important; padding-right: 0 !important; + } + .row { margin-left: 0 !important; margin-right: 0 !important; } + .card, .card.p-4, .card.p-lg-5, .card.border-light { + width: calc(100% - 8px) !important; max-width: 100% !important; + padding: 8px !important; margin: 4px !important; + border-radius: 12px !important; box-sizing: border-box !important; + } + .badge { + white-space: normal !important; text-align: left !important; + line-height: 1.4 !important; height: auto !important; display: inline-block !important; + } +} +</style> {% endblock %} diff --git a/templates/anime_downloader_ohli24_setting.html b/templates/anime_downloader_ohli24_setting.html index b1f8375..5d35a97 100644 --- a/templates/anime_downloader_ohli24_setting.html +++ b/templates/anime_downloader_ohli24_setting.html @@ -25,6 +25,7 @@ {{ macros.setting_input_text_and_buttons('ohli24_url', 'ohli24 URL', [['go_btn', 'GO']], value=arg['ohli24_url']) }} {{ macros.setting_input_text('ohli24_download_path', '저장 폴더', value=arg['ohli24_download_path'], desc='정상적으로 다운 완료 된 파일이 이동할 폴더 입니다. ') }} {{ macros.setting_input_int('ohli24_max_ffmpeg_process_count', '동시 다운로드 수', value=arg['ohli24_max_ffmpeg_process_count'], desc='동시에 다운로드 할 에피소드 갯수입니다.') }} + {{ macros.setting_input_text('ohli24_proxy_url', 'Proxy URL', value=arg.get('ohli24_proxy_url', ''), desc=['프록시 서버 URL (예: http://192.168.0.2:3138)', '비어있으면 사용 안 함']) }} {{ macros.setting_select('ohli24_download_method', '다운로드 방법', [['ffmpeg', 'ffmpeg (기본)'], ['ytdlp', 'yt-dlp'], ['aria2c', 'aria2c (yt-dlp)']], value=arg.get('ohli24_download_method', 'ffmpeg'), desc='m3u8 다운로드에 사용할 도구를 선택합니다.') }} <div id="ohli24_download_threads_div">