Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avgle new m3u8 URL regex - 新 m3u8 url 格式 #54

Open
av-boss opened this issue Jan 9, 2021 · 9 comments
Open

Avgle new m3u8 URL regex - 新 m3u8 url 格式 #54

av-boss opened this issue Jan 9, 2021 · 9 comments

Comments

@av-boss
Copy link

av-boss commented Jan 9, 2021

Avgle seems to have new unencrypted m3u8 format, in the form of

https://cdn.qooqlevideo.com/key=3hMnsykJZe7E-5rJd4f4eQ,end=1610186386,limit=2/ip=69.166.112.160/referer=force,.avgle.com/data=1610186386/media=hlsA/475928.mp4

avgle 新的一个 m3u8 格式, 可以加到 src\config.js 里去

For now fixed locally by adding to unencrypted regexes at src\config.js

export const M3U8_PATTERN_ARRAY = [
	// 1. Normal m3u8 file
	'*://*/*.m3u8',
	'*://*/*.m3u8?*',
+++'*://*/*.mp4',

export const PROCESSABLE_M3U8_PATTERN = [
	// { pattern: /\.adcdn\.com\// },
	// { pattern: /\.ahcdn\.com\// },
	{ pattern: /\.\w+cdn\.com\// },
+++{ pattern: /cdn\.qooqlevideo\.com\// },
@chenhow83
Copy link

After modified still getting error.

download-FC2-PPV-1648397.sh: line 886: ((: i<=!WU1HRUQLSxgLQgNQBAVTWgVUBRlXAAhIEF5eRg9SRF1VXFwbVF4JGAlXSF9LXwk1USdcU3IxMTERWRxQLX9qTkZeH0YKHQFZBg8AVAMEU1AEWwUCGAgPCwhFDAVMU1NAUAQCAwYAVQRRCwFXHUYWAkMHCG51AgI8TEt6GBFSVFFDXEEIUV4WVAceHwNEUg4GGQFaWhsWAwAVUFYKVgEDBAgPBwEYXAFTC1MMCl5GI0xEEVEDG1VRUU4IHgVQAAsBAQ4GDBlcFANNQVQFHwZbVBoUBBpVVUgSEg== : syntax error: operand expected (error token is "== ")

@ivideom
Copy link

ivideom commented Jan 20, 2021

Seems the dectyptURI function call will check whether its called by functions in "avgle.com/templates/frontend/videojs-contrib-hls.js" (which's used to generate md5 hash for decrypting the video segment uri).
It might cause current script not work any more.

@ivideom
Copy link

ivideom commented Jan 20, 2021

You may try a workaround like this:

--- a/src/inject/main-player-page-hls.js
+++ b/src/inject/main-player-page-hls.js
@@ -33,9 +33,8 @@ function main(utils, parameters = {}) {
                        const arr = [];
                        try {
                                const segments = player.tech_.hls.playlists.media_.segments;
-                               segments.forEach(x => arr.push({ uri: x.resolvedUri }));
-                               arr.forEach(videojs.Hls.xhr.beforeRequest);
-                               arr.forEach(x => typeof x.decryptURI === 'function' && x.decryptURI());
+                               segments.forEach(x => arr.push({ uri: x.resolvedUri, method: "HEAD", timeout: 50 }));
+                               arr.forEach(x => x.uri = videojs.Hls.xhr(x, function(){}).uri);
                        } catch (error) {
                                return logError(error);
                        }

It works, though hundreds of requests will be sent (querying for response headers only, no data)...

@chenhow83
Copy link

tried the workaround but still getting the same error.

function main(utils, parameters = {}) {
// #21
waitForVideoJS(100, () => {
const player = videojs('video-player');
player.on('loadedmetadata', () => {
logInfo(Detected the hls.js loadedmetadata event!);

		const arr = [];
		try {
			const segments = player.tech_.hls.playlists.media_.segments;
			//segments.forEach(x => arr.push({ uri: x.resolvedUri }));
			//arr.forEach(videojs.Hls.xhr.beforeRequest);
			//arr.forEach(x => typeof x.decryptURI === 'function' && x.decryptURI());
			segments.forEach(x => arr.push({ uri: x.resolvedUri, method: "HEAD", timeout: 50 }));
            arr.forEach(x => x.uri = videojs.Hls.xhr(x, function(){}).uri);
			
		} catch (error) {
			return logError(error);
		}

@ivideom
Copy link

ivideom commented Jan 21, 2021

tried the workaround but still getting the same error.

function main(utils, parameters = {}) {
// #21
waitForVideoJS(100, () => {
const player = videojs('video-player');
player.on('loadedmetadata', () => {
logInfo(Detected the hls.js loadedmetadata event!);

		const arr = [];
		try {
			const segments = player.tech_.hls.playlists.media_.segments;
			//segments.forEach(x => arr.push({ uri: x.resolvedUri }));
			//arr.forEach(videojs.Hls.xhr.beforeRequest);
			//arr.forEach(x => typeof x.decryptURI === 'function' && x.decryptURI());
			segments.forEach(x => arr.push({ uri: x.resolvedUri, method: "HEAD", timeout: 50 }));
            arr.forEach(x => x.uri = videojs.Hls.xhr(x, function(){}).uri);
			
		} catch (error) {
			return logError(error);
		}

Note that you will need to rebuild the chrome extension after src code updated.
(And may need to restart chrome to load the updated extension)

# Install Node.js and yarn
# Visit: https://nodejs.org/en/
# And https://yarnpkg.com/getting-started/install

# Install dependencies
yarn install

# Launch builder script
yarn run build

@heroboy
Copy link

heroboy commented Jan 23, 2021

就2点:

  1. 必须在进入创建xhr这个时间点调用。你可以在相应位置设置断点,然后控制台执行代码能解密成功。但是如果过了这个代码段,执行同样的代码,就解密失败了。
  2. beforeRequest和decryptURI必须按顺序调用。
var backupBeforeRequest = videojs.Hls.xhr.beforeRequest;
var done = false;
let v = videojs('video-player');
v.on('loadedmetadata', function () {
	console.log('test:', 'loadedmetadata')
	videojs.Hls.xhr.beforeRequest = function () {
		backupBeforeRequest.apply(videojs.Hls.xhr, arguments);
		if (!done) {
			console.log('start decrypt video uri')
			done = true;
			try {
				v = videojs('video-player');
				arr = v.tech_.hls.playlists.media_.segments.map(x => {
					return {
						uri: x.resolvedUri,
						"timeout": 0,
						"withCredentials": false,
						"responseType": "arraybuffer",
						"headers": {}
					}
				});
				for(let item of arr)
				{
					videojs.Hls.xhr.beforeRequest(item)
					item.decryptURI();
				}
				
				console.log(arr[0]);
			}
			catch (e) {
				console.error('some error', e);
			}

		}
	}
})

@sino1641
Copy link

sino1641 commented Feb 5, 2021

就2点:

  1. 必须在进入创建xhr这个时间点调用。你可以在相应位置设置断点,然后控制台执行代码能解密成功。但是如果过了这个代码段,执行同样的代码,就解密失败了。
  2. beforeRequest和decryptURI必须按顺序调用。
var backupBeforeRequest = videojs.Hls.xhr.beforeRequest;
var done = false;
let v = videojs('video-player');
v.on('loadedmetadata', function () {
	console.log('test:', 'loadedmetadata')
	videojs.Hls.xhr.beforeRequest = function () {
		backupBeforeRequest.apply(videojs.Hls.xhr, arguments);
		if (!done) {
			console.log('start decrypt video uri')
			done = true;
			try {
				v = videojs('video-player');
				arr = v.tech_.hls.playlists.media_.segments.map(x => {
					return {
						uri: x.resolvedUri,
						"timeout": 0,
						"withCredentials": false,
						"responseType": "arraybuffer",
						"headers": {}
					}
				});
				for(let item of arr)
				{
					videojs.Hls.xhr.beforeRequest(item)
					item.decryptURI();
				}
				
				console.log(arr[0]);
			}
			catch (e) {
				console.error('some error', e);
			}

		}
	}
})

so how to use it, thx

@ilovefood2
Copy link

arr.forEach(x => x.uri = videojs.Hls.xhr(x, function(){}).uri);

this actually works, thanks a lot !!!

@jasonlow83
Copy link

jasonlow83 commented Jul 7, 2021

I'm encountering the below warning and causing the script to retry wget again without Referer header, it can be fixed by updating the download.sh and downloader-hls.sh in your extension/dist folder (re-import after updating the sh).

Avgle_wget_warn

Replace
"$WGET_BIN" "$ref1" "$ref2" --header "User-Agent: $CFG_USER_AGENT" "$out1" "$out2" $2;

With
if [[ -n "$3" ]]; then "$WGET_BIN" "$ref1" "$ref2" --header "User-Agent: $CFG_USER_AGENT" "$out1" "$out2" $2; else "$WGET_BIN" "$ref1" "$ref2" --header "User-Agent: $CFG_USER_AGENT" $2; fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants