Play-With-MPV icon indicating copy to clipboard operation
Play-With-MPV copied to clipboard

试着解析了两个网站

Open blass0009 opened this issue 9 months ago • 0 comments

因为个人需求,试着解析了iwara和missav的视频地址,因为我并不会写代码,代码基本是AI写的,所以无法提PR。只能说我本地试了是可以用的。贴出来如果有人有同样需求的话可以参考。 iwara方面解析出来的视频地址是当前选择的清晰度,不知道有没有办法解析出多个地址在mpv里切换。 另外默认情况下iwara需要设置代理,但是可以改hosts直连。 missav则是无法从html中找到明文的地址,所以从加载的资源里找到m3u8。

	{
		name: "Iwara.tv",
		home: ["https://www.iwara.tv"],
		regex: /^https:\/\/www\.iwara\.tv\/video\/.*/g,
		handler: class Handler extends BaseHandler {
			async parse() {
				let videoElement = document.querySelector('video.vjs-tech');
				if (videoElement) {
					//let videoUrl = videoElement.src;
					let videoUrl = videoElement.src;
					// 处理协议头
					if (videoUrl.startsWith('//')) {
						videoUrl = 'https:' + videoUrl;
					}
					this.media.setVideoUrl(videoUrl);
					// 设置代理
					this.media.setProxy(currentConfig.proxy);
				}
			}
		},
	},
	{
		name: "Missav.com (Resource Search)",
		home: ["https://missav.com"],
		regex: /^https:\/\/missav\.com\/.*/g,
		handler: class Handler extends BaseHandler {
			async parse() {
				// 从已加载的资源中查找 M3U8 文件
				const resources = performance.getEntriesByType('resource');
				for (const resource of resources) {
					if (resource.name.endsWith('playlist.m3u8')) {
						// 获取 M3U8 地址
						let m3u8Url = resource.name;
						// 设置 referer
						this.media.setReferer(page.url);
						// 设置视频 URL
						this.media.setVideoUrl(m3u8Url);
						break;
					}
				}
			}
		},
	},

blass0009 avatar Apr 30 '24 14:04 blass0009