Google Drive API -- get direct video download for different formats - javascript

It's known that by simply retrieving a Google API key that one can download any file (of any size) directly (and even embed a video to a website etc...), the problem is: when using the standard Google API URL in the form:
https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ### inserting the file ID and API key in place.
This works if I want to embed, lets say, a video already in .mp4 format, but lets say if I want to embed a .mpg video to an HTMLwebsite: by default, the .mpg format is not embeddable, but its known that Google Drive automatically converts all of its video files into various formats that cna be played in the browser, so:
How can I access the different video formats of a video in Google Drive? Preferably, I'm looking for a programmatic way to get it (like Node.js or PHP).

You need to integrate your Google Drive with Cloud Convert (this is a manual job)
https://zapier.com/apps/cloudconvert/integrations/google-drive
OR
You can make use of Integromat to do it for you (it comes with various automation scripts)
https://www.integromat.com/en/integrations/cloudconvert/google-drive
Once done - you can consume Cloud Convert's APIs using nodejs, php, python, angular etc.
https://cloudconvert.com/api/v1/
(The free plan supports max 1GB file conversion per session)
Most Important - The API has Google Cloud Integration
https://cloudconvert.com/api/v1/googlecloud
Converters:
Cloud Convert for php
https://github.com/cloudconvert/cloudconvert-php
Cloud Convert for nodejs
https://github.com/cloudconvert/cloudconvert-node
Hope that's a good starting point for you..

I think this is a classic x\y problem. https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem You want access to auto converted, embeddable videos AND you want it using a specific tool -- but the tool isn't the right tool because it doesn't do that.
So, forget about the tool, and focus on the problem: there are two other Google services that auto convert video and allow embedding: YouTube, and Google photos.
Photos is interesting because if you can choose "high quality" or original storage, where high quality converts almost anything to an embeddable, web friendly format. YouTube, of course, also makes it easy to convert and embed.
On the photos side, downloading is natively available, and on the YouTube side, there are numerous sites that will provide a download link to your video in a variety of formats.
So, if you really don't want to use ffmpeg* or other standard conversion tools, I'd look into the APIs of the other two mentioned services.
*Unless you are doing a large volume of conversions, you could do this via a free tier node\firebase project.

Related

Google Drive file simultaneous modification

I am trying to make a simple "sync" functionality. Let me describe my problem with a simple example:
Let's say there is a file named lorem.txt on Google Drive (appFolder). What happens if at the same time, two different devices (belonging to the same user with the same Google account) access the file and try to read or change the contents or name of the file? Lets say device A is suppose to make a change in the contents while device B is also trying to do the same at the same time. The file is accessed through it's unique ID.
How to go around this problem? Is there a build in functionality or measures in place to avoid simultaneous write access to a file (like some sort of file lock)?
I am specifically looking for a solution using Google JS SDK or using plain JS (with Authentication tokens ofc). Does the Drive server returns some sort of error status code (like 404) when such a scenario happens?
UPDATE:
Based on these previously asked questions (asked in 2017 and 2012 respectively):
Android Drive Api Lock File while in use
and
Can I set a lock on files with google api?
, I think it is fair to assume that there is no such functionality built-in into Google Drive.
I will leave this question as a reference for others.

Possible download / upload manager embedded on html page with access to local filesystem

As the title indicates i want to have a certain application get access to the local file system. To describe why i will illustrate my situation:
I am a running a IIS WebApplication with the C# MVC 4 Framework as backend module. The site solely consists of HTML, CSS markup and some JS. The page will be loaded in IE11+ (Edge) only. For the standard procedure of displaying and accessing data from as well as sending data to the server this works quite fine.
On a certain page I want the user to be able to upload a file using a simple file dialog, like the one you can initiate with a simple <input type="file"> tag. I also want to offer the posibility to download files from the server but need to know where files has been saved / will be saved to.
As described on a lot of different websites, just like this one here, the HTML5 File API does a great job but will not be able to return the full qualified filename including the local path directions, same for JS accessing the file object.
As my research confirmed HTML5, JS and also SWF (Flash) will not report detailed information because they are all sandboxed applications or restricted by RFCs. I already unterstood and appreciate the effort to secure my trips to internet.
But in this case do need the paths where a file was upload from and the file has been downloaded to.
So my question is, what is the best way to expose the full path directions for a up- as well as downloaded file to report them back to the server?
Is it possible to embed a SWF object inside HTML which will run inside an Adobe AIR sandbox or is a signed JAVA Applet still the one and only solution to accomblish this security breaking task?
A solution i would also apreciate would be the possiblity to ask the user to get access the file system, like you grant access to the web push service to receive notifications.
Also if there is a possible solution which may suite my circumstances please let me know by adding some simeple examples / revealing some factful links, thanks in advance.

Universal document viewer in browser - without server side conversion

I want to embed a document viewer in my webpage, which should support all microsoft office formats, pdf, images, etc.
I don't want file conversion to happen on server side and then send it back to html viewer.
Is there a way to instantly view the file with original format directly in browser? Or is there a way to convert files to browser supported formats on fly in frontend (using Javascript) and show it instantly? Is there any product that does it now?
A quick google search shows there are a few javascript libraries out there that can deal with MS Office docs, e.g. DOCX.js, although they may not cover all your use cases.

How to disable video/audio downloading in web pages?

I have a website that I put my videos/audios on it.
I use HTML5 and tag to show videos.
But videos/audios can be downloaded if client opens view source page and then copy the file address.
How can I disable downloading these files, I just want client to see videos/hear audios in the web page.
Many online video/audio services like Youtube disabled downloading videos by this way. How they did that? What is a working way to disable, or at least make this progress much harder?
Youtube encodes their video into the MPEG-DASH format, which plays back through byte streams via the browser's implementation of the Media Source Extensions API. See See more on Wikipedia.
You can do the same by encoding your video into MPEG-DASH files, then playing it back in your code through a library like dash.js. Watch how the dash.js player works live by checking out the DASH Reference Client.
I've encoded MPEG-DASH video using Sorenson Squeeze, but there are other encoders you could use.
And just to clarify... this will make downloading more difficult... but will NOT provide a real DRM solution. For that you need to check out EME.
MPEG-DASH seems like a nice solution but is definitely not perfect. There are many ways to bypass this and still being able to download the video. On the other hand putting a lot of effort in protection might not be worth it since people can always make screen recordings etc.
But if you still want to go for a more secure option you can try using
Encrypted Media Extensions i.e. with Amazon s3 cloud.

Amazon CloudFront - Restrict MP3 to play on specific website

I've been trying figure out how to get mp3 files in an Amazon S3 bucket paired with Cloudfront to allow me to stream the files directly on my site but not allow anyone to take the source URL of the mp3s by viewing the source code of the page and then sharing or leeching the link.
Right now, I am using an html5 mp3 playlist from mediaelements.js and the mp3 file is always in the source code. That's fine, but I want to only allow the mp3 to play on my specific website and if the link gets copied from the source and accessed in a different browser it should show an access restricted error.
I tired to update the cloudfront policy to expire within 30 seconds of the page load, but that will ultimately prevent the files from playing once the 30 seconds is over and if the user didn't play one of the tracks prior to that expiration.
Is there another way to do this without putting a time expiration on the cloudfront links?
I think this is what you are looking for: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls-overview.html
Basically you can vend URLs dynamically from your service, and CloudFront will validate signature. You can also set pretty short expiration time to avoid wide distribution of your URL, and restrict IP addresses that might access URL (see Custom Policies section in the referenced document).
It's possible with just few line wizard coding on back-end (private method) ,i prefer to using free tier EC2 instance and configure environment for handle streamable contents for deliver everything clear this way provide a restrict page to someone going to leech or using IDM for donwload your mp3 files.
Example : Grooveshark.com
However still there is some another methods like Owain answer .
Unfortunately, you can't. MediaElements.js may be hosted on your site, but it's being run on the user's computer. So although it looks like they are playing an MP3 via your site, they are actually just downloading a URL from your site and playing it using code running on their computer.
You could write server-side code that went off to S3 and retrieved the MP3 before returning it as if it were a file hosted on your server, but that still wouldn't limit people from copying that link, unless some sort of session were used before returning the file to ensure they're logged in via your site.
But that would mean you can't make use of CloudFront. That's the compromise. Distribute your MP3 via a CDN and improve download performance by hosting the file in an edge location closer to your users, or take advantage of server-side security to ensure your IP isn't hosted by unscrupulous third parties.

Categories