Jump to content

Intercept video playback


zetatec
 Share

Recommended Posts

zetatec
Hello.
I am a programmer in PHP and JAVA, although I know a little about C, I have no command of the language.
Following the wiki I managed to generate the base of a plugin. When reading about "Automatic Type Discovery", it was not clear if any of the classes met my need.
I don't know if it goes against politics either.
But I need my plugin to be able to be called via url scheme.
 
Something like:
plugin://example.plugin?id =FILEID
 
The idea is that when recording a .strm with this content and reproducing it, the plugin intercepts the reproduction and delivers the video file.
 
PS: I am using Google Drive API.

 

Thanks

Link to comment
Share on other sites

Hi, why do you even need a plugin? You could have the strm point to your own http server and deliver the video content that way.

Link to comment
Share on other sites

zetatec
Hi @@Luke.
Correct observation, in fact in recent years it has worked well.
 
Description of the scenario:
I have a system in php called Link Manager. You can configure multiple api keys.
Google's oAuth is also used to generate STRM from a folder ID.
When you inform a folder to generate STRM, it will scrape the entire folder using oAuth, in the end it will generate a zip file with the entire structure of the folder.
Within the strm {
}
(Before everything was done by API, but the API hid some files, which made me change the scratch to oAuth)
When "s.php?id=" is called, it will do some tests on the file, if everything is ok (whoever requests it is part of the allowed origin, the file can be downloaded, it is not abusive, etc.)
I test if its download is working using foreach on the apis keys registered on the panel, the first one that works it sends to "https://www.googleapis.com/drive/v3/files/$id?alt=media&key=$api",using header("Location:"), http  302.
 
The problem:
started this year to present a bug, he warns that the file reached the download quota, however, it did not.
It can be downloaded from the web, or by oAuth.
I have just finished sending the file and at the same time try to access it and come across the quota reached.
(Me and many other users have already reported to Google)
 
The solution:
Use oAuth to download the file ONLY when the quota error occurs via the api key.
However, the request via oAuth must have the header with authorization bearer. What is not possible by sending a simple url request, you must send this header.
So I can't redirect the s.php request via header("Location:").
The final url is always sent from s.php to the requester, if the server takes the final request he will download the file, then it is not even worth working with strm (direct stream).
My s.php can analyze who requested it, if it was Emby and there is a failure using the api key he could send header("Location: plugin://linkmanager?id=FILEID").
The plugin will intercept, use oAuth previously configured on it, and it will be responsible for the download. I imagine that this way, the request will be made by the client, consuming the client's bandwidth and not the server's.
 
Generic code (not real)

if (apis) {
	$file = searchFile($id);
	if ($file) {
		foreach($apis as $api) {
			if (testDownload($id,$api['value'])) {
				header("Location: https://www.googleapis.com/drive/v3/files/$id?alt=media&key=" . $api['value']);
				die();
			} else if ($requester == "emby"){
				header("Location: plugin://emby.linkmanager?id=$id");
				die();
			} else {
				echo "Lol";
				die();
			}
		}
	} else {echo "Lollolol";die();}
} else {
	echo "Nenhuma api configurada!";
	die();
}

 

Hi, why do you even need a plugin? You could have the strm point to your own http server and deliver the video content that way.

Edited by zetatec
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...