Availability of videoMediaMetadata - google-drive-api

I use google drive api (via python) and I wonder if there is an exact period of time after uploading video on google drive when i can be sure that videoMediaMetadata exists for uploaded files. Are there any ways to adjust that period of time for our corporate google drive?
According to the documentation (https://developers.google.com/drive/api/v3/reference/files) videoMediaMetadata field
This may not be available immediately upon upload
without any additional clarifications.
In my case there are files which were uploaded on the 15 of October and haven't had videoMediaMetadata field yet
Code from comment:
service.files().list(fields="nextPageToken,
files(id, name, videoMediaMetadata(width, height, durationMillis), imageMediaMetadata(width, height))").execute()
but there is no problem with request because for other files i get videoMediaMetadata successfully

Related

requests: Get last modified time of Google Doc or Sheet?

I want to download a Google Sheet (and/or Doc, or Colab Notebook) from an "Anyone can View" sharing URL, if the file is newer than my local copy. To do that, I need to find out when the remote file was last modified. Which I thought shouldn't be hard.
There are threads explaining how to do this for regular files on websites that make use of the HTML Last-Modified property, but Google doesn't provide this field in its headers. It provides a Date: but that's just the download date/time that updates every moment.
I see threads about doing this from within the Doc or Sheet itself. My question is not about that. I'm talking about getting the info remotely by running a python script on my local machine.
I see a thread about using the Google Drive API v3, but....is it really necessary to go through all that (e.g. install oauth, register an API key, etc. effectively create an entire Google app *) just to find out when a publicly-available file was last modified? Is there an easier way?
Thanks!
EDIT: * I started down the road of Google Drive API but I find it confusing and overwhelming. It's like they think I'm trying to create an app for general users for the Android Store, instead of just myself. (??)

Get Google Drive video view count from Apps Script API?

I have a series of videos uploaded to a specific Google Drive folder, and I'd like to get the view count for each video/file. Literally as simple as "file_id" "10 views".
From extensive research, it seems this is quite simply impossible within Google Apps Script today? Per this old answer, both the Drive API and the Drive Activity API only report edit or comment activity, while view activity is ignored. The Reports API does support this, but only for users with Admin access in an Enterprise account (not for us plebes who just want to know view counts on our own files).
And per this Apps Script documentation, it seems that onOpen() triggers don't run for views (which blocks a "view_count + 1 on open of this specific file" sort of analytics).
Before I give up, I figured I'd run it past this brilliant community: am I missing anything? Is there some way to get view count on videos stored and accessed through Google Drive?
Answer:
You are correct in your findings that you can not get video view count information through the Drive API. You must use the Admin SDK to obtain this information.
Feature Request:
You can however let Google know that this is a feature that is important for access to their APIs, and that you would like to request they implement it.
Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services, I'd urge you to make a feature request there. The best component to file this under would be the Google Drive component, with the Feature Request template.

429 Too Many Requests when exporting Google spreadsheets

We use the Google Drive SDK to monitor a folder of spreadsheets for changes. When a change happens, we download the file to our servers and convert it to JSON for further use.
Since a file may contain multiple sheets, we go through this process to extract all sheets:
Download the embedLink from the drive#file resource and parse the HTML to extract the gid of each sheet. (Similar to the approach used here.)
Download each individual sheet as CSV by appending ?gid=... to the text/csv URL from the exportLinks field.
Recently we've been seeing 429 Too Many Requests errors, especially if the file gets big enough. According to the API console we're not close to the quota limit, so presumably export links are not counted as API requests, but is rate limited some other way. Exporting the sheet manually – as a different user from the one used against the Drive API – works fine.
Is there a way to find the gid of each sheet in a file without downloading the full embedHTML? If not, is there some way to avoid hitting the download limit?
EDIT: This incorrectly closed issue seems to deal with the problem of finding the gids of a spreadsheet file.
UPDATE: I've worked around this issue by parsing the XLSX export instead of the CSVs. Haven't seen the problem since.
I am a little late to the party, but this is for future readers.
Refer to this answer to know why the behavior #felix mentioned is happening.
I am quoting #chrish from the comments.
WARNING: Web hosting support in Google Drive is deprecated. "Beginning August 31, 2015, web hosting in Google Drive for users and developers will be deprecated. Google Apps customers can continue to use this feature for a period of one year until August 31, 2016, when serving content via googledrive.com/host/doc id will be discontinued."
Also, to know more details on the subject, you can read the article Deprecating web hosting support in Google Drive by Google.
Hope it helps.

How to get an accurate file list through the google drive api

I'm developing an application using the Google drive api (java version). The application saves files on a Google drive mimicking a file system (i.e. has a folder tree). I started by using the files.list() method to retrieve all the existing files on the Google drive but the response got slower as the number of files increased (after a couple of hundred).
The java Google API hardcodes the response timeout to 20 seconds. I changed the code to load one folder at a time recursively instead (using files.list().setQ("'folderId' in parents) ). This method beats the timeout problem but it consistently misses about 2% of the files in my folders (the same files are missing each time). I can see those files through the Google drive web browser interface and even through the Google drive API if I search the file name directly files.list().setQ("title='filename'").
I'm assuming that the "in parents" search uses some inexact indexing which may only be updated periodically. I need a file listing that's more robust and accurate.
Any ideas?
could you utilize the Page mechanism to do multiple times of queries and each query just asks for a small mount of result ?

Allowing a third party website to save to my drive (and with no sharing permission)

We're working on an app to sell our music and was wondering if Google Drive can be used as an online storage solution.
The user would complete the transaction on our site, and then authorize us to save the file (or multiple files) to their Google Drive.
The appeal to us is to solve downloading problems via the browser. I believe the Google Drive api returns a successful response when the delivery is complete. If incomplete, we would then either resend or update.
One other requirement is whether we can set permissions to not allow sharing after save (and for that setting to be permanent).
You can do everything you want. The last part about not allowing users to reshare, you can do this if you still own the file, but cannot do it if you have made the user own the file. I am not sure you could ever achieve that - a user can always download a file and share it themselves, whether you are using Drive or your own custom system.