In the past, with Google Drive API v2, I could easily get thumbnails for pictures or videos with the property thumbnailLink on GTLDriveFile.
But now, with the API v3 which I currently use with Swift, the thumbnailLink of the files I get from Google Drive is nil, so what can I do to get thumbnails of images and videos stored in the user's Google Drive. I need to display theses in my iOS app.
Make sure to specify thumbnailLink in fields, such as
let query = GTLQueryDrive.queryForFilesList()
query.fields = "files(id, name, thumbnailLink)"
then you can access the property thumbnailLink for images and videos
You'd have to use the Drive REST API method Files: get. The result of that method contains thumbnailLink but according to the documentation it is 'a short-lived link to the file's thumbnail. Typically lasts on the order of hours.
Alternatively, you can cache the thumbnail in your application, reducing the count of drive api requests and thus improve your page performance. You need to fetch the information for the uploaded file. The easiest way of caching is to simply download the thumbnail and save it like fileid_thumb somewhere and upon the next request, you check if such a file exists before actually requesting the thumbnail. Check here the detailed explanation.
You can also upload a thumbnail by setting the contentHints.thumbnail property on the File resource during an insert or update call as follows:
Set contentHints.thumbnail.image to the URL-safe Base64-encoded image (see RFC 4648 section 5)
Set contentHints.thumbnail.mimeType to the appropriate type for the image format
You can also check the accepted answer in this SO question.
Hope this helps!
Related
I'm trying to Retrieve images in the cell from a google spreadsheet. I checked this question is already available. and I also referred to this documentation. But, these both are no longer work. Does anyone suggests me API or provides any good documentation link?
Edited:
This is my Google Sheet. I'm trying to retrieve A4 and A5. Which is I uploaded from local machine. I used this API. But It's given me the blank value. Is there any other API available for retrieving this both images?
You will not be able to retrieve images placed using the "Upload" functionality. To retrieve via API, the image should be placed using
=IMAGE("http://your.url").
So upload your image to a content server, get the URL and insert them to the respective cells using =IMAGE formula.
Now if you retrieve the grid data using Spreadsheet.get and locate this specific element in the array, you will get the cell value as =IMAGE("http://your.url"), you can parse this string to retrieve the image URL.
You can get a zip file with the sheet in html format with all the images – using Google API. I belive it will be easy to parse it and to get the image you need.
Get Your API Key, from Google developers Console
Get a File ID of a google spreadsheet with permissions set to "Anyone with the link".
Now you're ready to call the api (with curl or browser window):
https://www.googleapis.com/drive/v3/files/{FILE_ID}/export?mimeType=application%2Fzip&key={YOUR API KEY}
fill in your FILE_ID and API_KEY from google.
works only with "anyone with link" permissions, otherwise you gotta authenticate first. (more here: How to send google-sheet data in an email keeping the formatting( colors) intact from python?)
I have a list of recent and shared DriveItems I need thumbnails for. First, is there a way to pass a list of DriveItem ids to get the thumbnails in a single call?
All of the DriveItems are pretty basic, all Excel or Word, and they have thumbnails in OneDrive but when I ask for the thumbnails, the large majority return without a thumbnailSet. The ones that do are all invalid urls with a height and width of -1. Using the call below:
https://.../v1.0/me/drive/items/{driveItemId}/thumbnails
For making one call and returning multiple thumbnails:
https://.../v1.0/me/drive/items/{item-id}/children?select=id,name&expand=thumbnails(select=large)
Personally, I'm having trouble returning thumbnails of certain document types (e.g. Excel spreadsheets), whereas the document and photo thumbnails return without issue. Thus, I'm not sure about the second part of your question.
OneDrive thumbnail docs
Using CMS account we can download raw data files from youtube(https://cms.youtube.com/cyc_download_reports).
This csv does have information whether a video was Partner-provided or UGC.
The corresponding closest match from Youtube Analytics API I believe is using the uploaderType
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3DXXXXXXXXXXXXXXX&start-date=2013-06-17&end-date=2013-06-21&metrics=views&filters=uploaderType%3D%3Dself&key={YOUR_API_KEY}
But this is at a contentOwner Level rather than at video level.Kindly let me know if I am missing something.
You're not missing anything. You can run a content-owner YouTube Analytics API report and use the uploaderType as a filter, to find stats about all the videos underneath that content owner that have a specific uploader type value. You can't request uploaderType as a dimension in a request with a video== or channel== filter, though.
The matrix of supported parameters is at https://developers.google.com/youtube/analytics/v1/content_owner_reports#Reports
I've explored most of this topic using the previous question How do I get a list of uploaded videos for a certain channel with the new YouTube Data API (V3)?, but I wanted some specifics that build upon the answer given.
Is it possible to use the channel's username without calling a search query to get the channel ID? I have an https request that can get a search list shown below, but I'd rather not waste API quotas when I know the exact channel username.
https://www.googleapis.com/youtube/v3/search?q={channel_username}&key={my_api_key}&part=snippet
My hack for this is just take a videoid from the channel and extract a uploader ID from there, but its not elegant and won't work if the upload is removed.
Also, once I've worked my way down to getting the uploads key, how can I get a json that shows all of the uploads and not just a list of 25? If I do have to recursively call pages of uploads, how can I do that?
Thanks.
I think that to get a channel, using the channel's username, the only option is to use the search, and the best strategy to minimize the use of quota is to use a cache, or save the channel ID.
For a full list of videos uploaded, as JSON, you can use contentDetails.relatedPlaylists.uploads (the ID of the playlist that contains the channel's uploaded videos) and retrieve the PlaylistItems, using pages with 50 items per page, and using the nextPageToken value to retrieve each page in the result set.
I've found the answer. The correct way to go about it is to query the site using the search, but directly state the type of list to respond with, in effect searching only channels. This is done by
https://www.googleapis.com/youtube/v3/search?q={search_term}&key={API_key}&type=channel&part=snippet
As you can see the type is channel. By searching with a search term of the exact channel username, you'll get a return list with the first item object as the channel, and you can store the channel ID and upload ID from there.
To update this answer, you need to recognise the "quota limits".
As such, to use the "search?q=[search]" will incur a 100 quota usage.
Better to use "channels?part=id&forUsername={username]" as is only a quota of 1.
Then you can use "channels?part=id,snippet ....... &id={channel_ID]" to grab all your data
When a video is duplicated (let's say v = GgVH5fXXYSE) , is there a way i can find the videoid of the "good" one (the one that should work) with the duplicated id.
(so with GgVH5fXXYSE i could find eNqZgEgOfsw)
Thanks!
Unfortunately, there's no way to get this information. It's come up as a feature request a number of times in the past, and there are technical reasons why this can't be exposed in the YouTube Data API response.
If you have APP, that solely uploads file to particular (authorized) youtube account(s), then you can get it done using following method. Maintain a hash of all input files and while uploading file, check ,if you have old file having same hash as current file upload, and that old file was uploaded successfully, then don't upload that file and use youtube link = old file's ( having same hash as current file) youtube link.