Delete one slide from a Google Presentation using API - ruby

How is it possible to delete a slide from a Google Presentation using Google API?
In https://developers.google.com/slides/samples/slides it is said: The Slides API allows you to create, move, and delete slides. However, I'm unable to find how to do it.

You can use DeleteObjectRequest for tihs https://developers.google.com/slides/reference/rest/v1/presentations/request#DeleteObjectRequest
Pass your slide id to objectId.

In google app script you can do:
var presentation = SlidesApp.openById("23423423lksdjfsdlkfj");
var slides = presentation.getSlides();
slides[0].remove(); // Remove the first slide
You have to put the proper file id from the long part of the URL of the slide document.

Related

Google Sheet & App Script : how to get image from a link preview?

I am trying to reproduce a RSS reader like Feedly with Google Sheet and displaying with Glide as an app on my mobile phone.
Everything's fine with IMPORTFEED() function with titles, description, URL.
But it seems this function doesn't allow pictures to be displayed even if they are in the feed (which is not all the time).
So I am looking for a way to extract the main image from a blog post... the one displayed when you hover on a link in a Google Sheet cell.
I would like to get the link of that image displayed in the link preview and put that link in another cell.
Here is an example:
I tried IMAGE()
and also IMPORTXML when there is an image in the RSS feeds (but not all of them do... so I stopped)
Is it possible in Google Sheet to get the main image from the one displayed in the link preview ?
For instance, one of the blog I want to extract the main picture of a blog article would be Creajv (URL : https://creajv.com/ ; Feed : https://creajv.com/feed/)
So the IMPORTFEED() function I did in Google Sheets was :
=IMPORTFEED("https://creajv.com/feed/";"items";FALSE;3)
Which stands for :
=IMPORFEED(...) the function to import feeds from an URL
"items" the way to pull every data there is in the feed (you can use other parameters and can see all the possibilities on the GoogleFormulas documentation)
FALSE because I don't want the headers to be included
and the number 3 because I want only the last 3 results displayed.
And it displays perfectly : author, description, URL, date
But I did a little digging in Google and found that basically IMPORTFEED() cannot get images from feeds, even if it is added by the author of the blog (he has to add a feature to do it).
So I am now trying to see if there is another way which is not IMPORTFEED() to get every time the main image of a blog post.
And I saw Google Sheet is able to pull instantly it when I copy paste the URL of a blog article within a cell for instance for Creajv :
Print screen of the image I get when I click in the cell which contains the post URL
So my thoughts would be that I can pull the author, date, description etc. with IMPORTFEED (which works perfectly every time) and use a formula on the cell with the URL to get in another cell the URL of the picture pulled from the one in the link preview.
Two other possibilities might also be with Google App Script :
creating with the App Script a custom function
or creating a script pulling the image in a cell every time a new row is added via the IMPORTFEED() function.
Functions only, as Apps Script doesn't run on mobile Apps
How about this solution? I checked the website and inspected the image from the thumbnail.
Luckily, the structure is simple:
<div class="article-image">
<img src="https://creajv.com/wp-content/uploads/2020/11/HighresScreenshot00000.png" alt="Concours de Level Design avec Unreal Engine, du 11/11 au 05/12/2020">
</div>
You can get the url with IMPORTXML, and apply IMAGE to it:
=IMAGE(ImportXml("https://creajv.com/2020/11/08/concours-de-level-design-avec-unreal-engine/", "//div[#class='article-image']//img/#src"))
Since you are already retrieving the post url with your previous formula, change the source url by the correspondent cell:
=IMAGE(ImportXml(C1, "//div[#class='article-image']//img/#src"))
For example:

How do I insert images into a Google Sheet in Python using gspread (or any other package)?

I need a way to insert an image into a specific cell in a specific Google Sheet. If there is any python package and/or slice of code that can accomplish this, please let me know. As far as I am aware Gspread does not have anything helpful.
You can simply insert an image from an URL with a formula like this:
'=image("https://drive.google.com/uc?export=view&id={}")'.format(file_id)
When you insert/upload the data be sure to choose USER_ENTERED for value input option. https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
With gspred:
sheet_instance.insert_rows(rows, value_input_option='USER_ENTERED')
Overall to add image into Google Sheets can be accomplished with Python by first inserting the image file in Google Drive using the Google Drive API:
Here is how to insert it to google drive. - https://developers.google.com/drive/v2/reference/files/insert#examples,
and secondly linking to the image in Google Sheets with the Google Sheets API, Here is Google sheets API - https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#CellData
Note: Look under CellData

Want to show marker on google map using place id

Is it possible to show marker on google map using place link.
For example, I have a link for place BAR PSY place link is https://goo.gl/maps/JXKa2pe93Tn.
Is there any way to show marker on this place in google map.

Loading the first 5 images from google with specific keyword

I'm trying to load the first 5 image that comes up on google when I type a given keyword in my app. So let's say if the keyword was "Butter" I want to load the first 5 images that com up on google if you type butter.
I've been looking at the Github project SDWebImages (https://github.com/rs/SDWebImage), but it looks like you can only load the images if you have the url of the image.
Anybody know how I can do what I described, or anybody that can point me in the right direction as to what I should look at to do it.
Google has deprecated their image search API and you are now supposed to use custom search which supports images. You will need to sign up for an API key. When you make your search request you need to set your searchType parameter to image.

Embed Google Photo image in spreadsheet

Is it possible to embed in Spreadsheets an image from a Google Photo (Google+ in GDrive) folder?
I have images in Google+ albums and with new functionality show them in Google Drive in location: My Drive/Google Photo .... I tried to show these images in Spreadsheets with:
=image("https://googledrive.com/host/FOLDERID/NAMEPHOTO.jpg")
but see nothing, no image, no errors just a blank cell.
What should I do?
In the major I want to organize (moving, upload etc.) and edit (rename) images in album on Google+ with function and google scripts for spreadsheet. So I try use new functionality - Google Photo Albums see in GDrive - to do this. And finally i need to show the images from albums Google+ (folder Google Photo in GDrive) in Spreadsheet Cells.
Google Drive hosting (googledrive.com/host/FOLDERID/...) is being deprecated. To properly embed an image on Google Drive, you need to follow the following steps:
In Google Drive, right click on an image and select either "Share..." or "Get Link"
You will get a link that looks either like:
drive.google.com/file/d/RaD0mNum3er/view?usp=sharing , or
drive.google.com/open?id=RaD0mNum3er
You need to convert the link to something like:
drive.google.com/uc?export=download&id=RaD0mNum3er
In your cell, enter =image("drive.google.com/uc?export=download&id=RaD0mNum3er")
To quicken the process, I'd create 3 new columns (let's say C, D, E).
C2 = drive.google.com/open?id=RaD0mNum3er
D2 = =REGEXEXTRACT(C2,"(?:(?:file/d/)|(?:open\?id=))(\w+)")
E2 = ="https://drive.google.com/uc?export=download&id="&E2
where
C is the link you got from Google Drive
D is the extracted file ID, and
E is the converted the permalink

Resources