@@ -3,6 +3,7 @@ import hashjs from 'hash.js'
33import { HTTPException } from 'hono/http-exception'
44import config from '../config.js'
55import { format as lyricFormat } from '../utils/lyric.js'
6+ import { readCookieFile , isAllowedHost } from '../utils/cookie.js'
67import { LRUCache } from 'lru-cache'
78
89const cache = new LRUCache ( {
@@ -50,6 +51,16 @@ export default async (c) => {
5051 c . header ( 'x-cache' , 'miss' )
5152 const meting = new Meting ( server )
5253 meting . format ( true )
54+
55+ // 检查 referrer 并配置 cookie
56+ const referrer = c . req . header ( 'referer' )
57+ if ( isAllowedHost ( referrer ) ) {
58+ const cookie = await readCookieFile ( server )
59+ if ( cookie ) {
60+ meting . cookie ( cookie )
61+ }
62+ }
63+
5364 const method = METING_METHODS [ type ]
5465 let response
5566 try {
@@ -80,6 +91,11 @@ export default async (c) => {
8091 . replace ( '://m7c.' , '://m7.' )
8192 . replace ( '://m8c.' , '://m8.' )
8293 . replace ( 'http://' , 'https://' )
94+ if ( url . includes ( 'vuutv=' ) ) {
95+ const tempUrl = new URL ( url )
96+ tempUrl . search = ''
97+ url = tempUrl . toString ( )
98+ }
8399 }
84100 if ( server === 'tencent' ) {
85101 url = url
0 commit comments