mirror of
https://github.com/fish2018/pansou.git
synced 2025-11-25 03:14:59 +08:00
更换muou域名 添加封面获取
This commit is contained in:
@@ -135,7 +135,7 @@ func (p *MuouAsyncPlugin) searchImpl(client *http.Client, keyword string, ext ma
|
||||
}
|
||||
|
||||
// 1. 构建搜索URL
|
||||
searchURL := fmt.Sprintf("http://123.666291.xyz/index.php/vod/search/wd/%s.html", url.QueryEscape(keyword))
|
||||
searchURL := fmt.Sprintf("https://666.666291.xyz/index.php/vod/search/wd/%s.html", url.QueryEscape(keyword))
|
||||
|
||||
// 2. 创建带超时的上下文
|
||||
ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
|
||||
@@ -154,7 +154,7 @@ func (p *MuouAsyncPlugin) searchImpl(client *http.Client, keyword string, ext ma
|
||||
req.Header.Set("Connection", "keep-alive")
|
||||
req.Header.Set("Upgrade-Insecure-Requests", "1")
|
||||
req.Header.Set("Cache-Control", "max-age=0")
|
||||
req.Header.Set("Referer", "http://123.666291.xyz/")
|
||||
req.Header.Set("Referer", "https://666.666291.xyz/")
|
||||
|
||||
// 5. 发送请求(带重试机制)
|
||||
resp, err := p.doRequestWithRetry(req, client)
|
||||
@@ -256,7 +256,14 @@ func (p *MuouAsyncPlugin) parseSearchItem(s *goquery.Selection, keyword string)
|
||||
return strings.Contains(title, "剧情")
|
||||
})
|
||||
plot := strings.TrimSpace(plotElement.Find(".video-info-item").Text())
|
||||
|
||||
|
||||
// 提取封面图片 (参考 Pan_mogg.js 的选择器)
|
||||
var images []string
|
||||
if picURL, exists := s.Find(".module-item-pic > img").Attr("data-src"); exists && picURL != "" {
|
||||
images = append(images, picURL)
|
||||
}
|
||||
result.Images = images
|
||||
|
||||
// 构建内容描述
|
||||
var contentParts []string
|
||||
if quality != "" {
|
||||
@@ -275,11 +282,11 @@ func (p *MuouAsyncPlugin) parseSearchItem(s *goquery.Selection, keyword string)
|
||||
if plot != "" {
|
||||
contentParts = append(contentParts, plot)
|
||||
}
|
||||
|
||||
|
||||
result.Content = strings.Join(contentParts, "\n")
|
||||
result.Channel = "" // 插件搜索结果不设置频道名,只有Telegram频道结果才设置
|
||||
result.Datetime = time.Time{} // 使用零值而不是nil,参考jikepan插件标准
|
||||
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -311,7 +318,7 @@ func (p *MuouAsyncPlugin) enhanceWithDetails(client *http.Client, results []mode
|
||||
}
|
||||
|
||||
itemID := parts[1]
|
||||
|
||||
|
||||
// 检查缓存
|
||||
if cached, ok := detailCache.Load(itemID); ok {
|
||||
if cachedResult, ok := cached.(model.SearchResult); ok {
|
||||
@@ -323,14 +330,19 @@ func (p *MuouAsyncPlugin) enhanceWithDetails(client *http.Client, results []mode
|
||||
}
|
||||
}
|
||||
atomic.AddInt64(&cacheMisses, 1)
|
||||
|
||||
// 获取详情页链接
|
||||
detailLinks := p.fetchDetailLinks(client, itemID)
|
||||
|
||||
// 获取详情页链接和图片
|
||||
detailLinks, detailImages := p.fetchDetailLinksAndImages(client, itemID)
|
||||
r.Links = detailLinks
|
||||
|
||||
|
||||
// 合并图片:优先使用详情页的海报,如果没有则使用搜索结果的图片
|
||||
if len(detailImages) > 0 {
|
||||
r.Images = detailImages
|
||||
}
|
||||
|
||||
// 缓存结果
|
||||
detailCache.Store(itemID, r)
|
||||
|
||||
|
||||
mu.Lock()
|
||||
enhancedResults = append(enhancedResults, r)
|
||||
mu.Unlock()
|
||||
@@ -370,8 +382,8 @@ func (p *MuouAsyncPlugin) doRequestWithRetry(req *http.Request, client *http.Cli
|
||||
return nil, fmt.Errorf("重试 %d 次后仍然失败: %w", maxRetries, lastErr)
|
||||
}
|
||||
|
||||
// fetchDetailLinks 获取详情页的下载链接
|
||||
func (p *MuouAsyncPlugin) fetchDetailLinks(client *http.Client, itemID string) []model.Link {
|
||||
// fetchDetailLinksAndImages 获取详情页的下载链接和图片
|
||||
func (p *MuouAsyncPlugin) fetchDetailLinksAndImages(client *http.Client, itemID string) ([]model.Link, []string) {
|
||||
// 性能统计
|
||||
start := time.Now()
|
||||
atomic.AddInt64(&detailPageRequests, 1)
|
||||
@@ -380,43 +392,49 @@ func (p *MuouAsyncPlugin) fetchDetailLinks(client *http.Client, itemID string) [
|
||||
atomic.AddInt64(&totalDetailTime, duration)
|
||||
}()
|
||||
|
||||
detailURL := fmt.Sprintf("http://123.666291.xyz/index.php/vod/detail/id/%s.html", itemID)
|
||||
|
||||
detailURL := fmt.Sprintf("https://666.666291.xyz/index.php/vod/detail/id/%s.html", itemID)
|
||||
|
||||
// 创建带超时的上下文
|
||||
ctx, cancel := context.WithTimeout(context.Background(), DetailTimeout)
|
||||
defer cancel()
|
||||
|
||||
|
||||
// 创建请求
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", detailURL, nil)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
// 设置请求头
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
|
||||
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
|
||||
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
|
||||
req.Header.Set("Connection", "keep-alive")
|
||||
req.Header.Set("Referer", "http://123.666291.xyz/")
|
||||
|
||||
req.Header.Set("Referer", "https://666.666291.xyz/")
|
||||
|
||||
// 发送请求(带重试)
|
||||
resp, err := p.doRequestWithRetry(req, client)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
doc, err := goquery.NewDocumentFromReader(resp.Body)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
var links []model.Link
|
||||
|
||||
var images []string
|
||||
|
||||
// 提取详情页的海报图片 (参考 Pan_mogg.js 的选择器)
|
||||
if posterURL, exists := doc.Find(".mobile-play .lazyload").Attr("data-src"); exists && posterURL != "" {
|
||||
images = append(images, posterURL)
|
||||
}
|
||||
|
||||
// 查找下载链接区域
|
||||
doc.Find("#download-list .module-row-one").Each(func(i int, s *goquery.Selection) {
|
||||
// 从data-clipboard-text属性提取链接
|
||||
@@ -433,7 +451,7 @@ func (p *MuouAsyncPlugin) fetchDetailLinks(client *http.Client, itemID string) [
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 也检查直接的href属性
|
||||
s.Find("a[href]").Each(func(j int, a *goquery.Selection) {
|
||||
if linkURL, exists := a.Attr("href"); exists {
|
||||
@@ -448,7 +466,7 @@ func (p *MuouAsyncPlugin) fetchDetailLinks(client *http.Client, itemID string) [
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if !isDuplicate {
|
||||
link := model.Link{
|
||||
Type: linkType,
|
||||
@@ -462,7 +480,13 @@ func (p *MuouAsyncPlugin) fetchDetailLinks(client *http.Client, itemID string) [
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
return links, images
|
||||
}
|
||||
|
||||
// fetchDetailLinks 获取详情页的下载链接(兼容性方法,仅返回链接)
|
||||
func (p *MuouAsyncPlugin) fetchDetailLinks(client *http.Client, itemID string) []model.Link {
|
||||
links, _ := p.fetchDetailLinksAndImages(client, itemID)
|
||||
return links
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user