From 3ddf9cafaa1327d54b28ec15519f9584f9dee488 Mon Sep 17 00:00:00 2001 From: levywang Date: Thu, 13 Mar 2025 11:37:25 +0800 Subject: [PATCH 1/2] change readme --- README.md | 14 +++++++++++++- README_CN.md | 11 +++++++++++ main.py | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e83da1..dbc9acc 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,18 @@ git clone https://github.com/levywang/avhub.git cd avhub docker run -d -p :80 -v $PWD:/app --name avhub levywang/avhub:latest ``` +--- + + +### **Configuration Instructions** + +If you deploy the project on a server within China, the source site `missav` is blocked, so you need to configure a proxy server in `config.yaml`. Edit the `/data/config.yaml` file and modify it as follows: +```yaml +av_spider: + source_url: "https://missav.ai/cn/search/" + proxy_url: "http://192.168.50.3:7890" # HTTP or SOCKS5 proxy + use_proxy: true +``` --- @@ -82,7 +94,7 @@ docker run -d -p :80 -v $PWD:/app --name avhub levywang/avhub: ### **Data Sources** - **Magnet Links and Cover Images**: Sourced from **missav**. -- **Hentai Resources**: Sourced from **hacg liuli**. +- **Hacg Resources**: Sourced from **hacg liuli**. - **Random Video Recommendations**: Sourced from crawled data stored in the local file `/data/video_urls.txt`. The above data sources are configured in `/data/config.yaml`. If the data sources change or become inaccessible, modifications and maintenance are required. diff --git a/README_CN.md b/README_CN.md index eb270eb..7fcb3e8 100644 --- a/README_CN.md +++ b/README_CN.md @@ -68,6 +68,17 @@ git clone https://github.com/levywang/avhub.git cd avhub docker run -d -p :80 -v $PWD:/app --name avhub levywang/avhub:latest ``` +--- + +### 配置说明 + +如果您将项目部署在中国境内的服务器上,由于源站 `missav` 被屏蔽,需要在 `config.yaml` 中配置代理服务器。请编辑 `/data/config.yaml` 文件,修改示例如下: +```yaml +av_spider: + source_url: "https://missav.ai/cn/search/" + proxy_url: "http://192.168.50.3:7890" # HTTP 或 SOCKS5 代理 + use_proxy: true +``` --- diff --git a/main.py b/main.py index b1b0446..6d11537 100644 --- a/main.py +++ b/main.py @@ -120,7 +120,7 @@ def main(cfg: DictConfig): logger.info("Random video URL and image URL fetched successfully") return { "url": video_url, - "img_url": img_url or "" # 如果没有找到图片,使用默认图片 + "img_url": img_url or "" } except Exception as e: logger.error(f"Failed to fetch random video URL: {str(e)}") From c6380651fd66d7e55702e94363e29d03ebce8420 Mon Sep 17 00:00:00 2001 From: levywang Date: Thu, 13 Mar 2025 13:16:14 +0800 Subject: [PATCH 2/2] fix(script.js): resolve clipboard copy compatibility issue in js --- web/script.js | 71 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/web/script.js b/web/script.js index 0a4e754..34cfffe 100644 --- a/web/script.js +++ b/web/script.js @@ -1329,37 +1329,76 @@ async function loadCollections() { function copyToClipboard(text) { const notification = document.getElementById('notification'); - navigator.clipboard.writeText(text).then(() => { - // 成功复制通知 - notification.innerHTML = ` + // 显示通知的辅助函数 + const showNotification = (success) => { + notification.innerHTML = success ? ` ${translations[currentLang].copySuccess} - `; - notification.style.setProperty('background', '#1bb76e'); - notification.classList.add('show'); - - setTimeout(() => { - notification.classList.remove('show'); - notification.style.background = ''; // 重置背景色为默认值 - }, 3000); - }).catch(err => { - // 复制失败通知 - notification.innerHTML = ` + ` : ` ${translations[currentLang].copyError} `; - notification.style.background = '#dc2626'; + + notification.style.background = success ? '#1bb76e' : '#dc2626'; notification.classList.add('show'); setTimeout(() => { notification.classList.remove('show'); notification.style.background = ''; }, 3000); - }); + }; + + // 尝试使用 Clipboard API + if (navigator.clipboard && window.isSecureContext) { + navigator.clipboard.writeText(text) + .then(() => showNotification(true)) + .catch(() => { + // 如果 Clipboard API 失败,回退到 execCommand 方法 + fallbackCopyToClipboard(text); + }); + } else { + // 在非安全上下文中直接使用 execCommand 方法 + fallbackCopyToClipboard(text); + } + + // execCommand 复制方法 + function fallbackCopyToClipboard(text) { + try { + // 创建临时文本区域 + const textArea = document.createElement('textarea'); + textArea.value = text; + + // 设置样式使其不可见 + textArea.style.position = 'fixed'; + textArea.style.top = '0'; + textArea.style.left = '0'; + textArea.style.width = '2em'; + textArea.style.height = '2em'; + textArea.style.padding = '0'; + textArea.style.border = 'none'; + textArea.style.outline = 'none'; + textArea.style.boxShadow = 'none'; + textArea.style.background = 'transparent'; + textArea.style.opacity = '0'; + + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + // 尝试执行复制命令 + const successful = document.execCommand('copy'); + document.body.removeChild(textArea); + + showNotification(successful); + } catch (err) { + console.error('复制失败:', err); + showNotification(false); + } + } } // 修改排序下拉菜单