-2

I have found an interesting google script file, but would like to change it a bit to run it locally on my system. Locally I use Python. How can this be easily converted or to which language is it comparable?

The script is generating a new presentation with a specific slide template (shape). This part raises the most questions, of how to do it locally. Probably something with OpenCv / mathplotlib to generate a template.

Rubén
  • 34,714
  • 9
  • 70
  • 166
i vk
  • 29
  • 5
  • According to Wikipedia it's based on javascript https://en.wikipedia.org/wiki/Google_Apps_Script – jprebys Nov 10 '22 at 21:29
  • Aside from translating the codes from GAS to python manually or connect/recreate your work to google slides API. [Python command-line application that makes requests to the Google Slides API](https://developers.google.com/slides/api/quickstart/python). You may also use 3rd party service like GAE, etc. Have you seen these SO cases: https://stackoverflow.com/questions/41048109/launching-python-script-from-google-apps-script or this one: https://stackoverflow.com/questions/9205590/can-you-use-google-apps-script-with-python – Twilight Nov 11 '22 at 04:47

1 Answers1

1

If you are looking "easy" options, keep using Google Apps Script.


Google Apps Script uses JavaScript as programming language and has several services that make it convenient to automate Google apps like Google Slides.

In order to minimize the convertion work, you might create a web app using Google Apps Script to respond to HTTP GET or POST requests that you might do from Python.

If you still insist is using a Python only code, you should "translate" JavaScript code into Python code and replace the calls to services like Slides (SlidesApp) into calls to Google Slides API. This implies that you will have to use Google OAuth 2.

Another option is that you enable the Google Apps Script API (this also requires Google OAuth 2) and call the Google Apps Script functions from Python.

Also you have the option to change your approach, i.e., instead of using Python run Google Apps Script functions using CLASP, but still can't be qualified as easy.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    I'm worried that using Google Apps Script API might be a bit complicated from my experience. So, as the additional simple method, how about proposing to use Web Apps? In this case, the existing Google Apps Script can be used with the simple setting and the simple script of a python script like `requests.get(url)`. – Tanaike Nov 11 '22 at 02:15
  • 1
    Of course, I think that in order to directly achieve OP's goal using the current Google resources, Google Slides API is required to be used with python script. But, in this case, the authorization process and the script for using Slides API are required to be created. If OP wants the simple way, I thought that Web Apps might be one of several ways. – Tanaike Nov 11 '22 at 02:19
  • 1
    @Tanaike Thank you very much for your comments. I have slighthy edited my answer. I can't offer to the OP a more specific help at this time like providing a sample Python script. If you think that tha is something that will help the OP and others please feel free to post an answer. – Rubén Nov 11 '22 at 03:18
  • Thank you for your response. About the sample script of python for requesting Web Apps, in this case, when the setting of Web Apps is `Execute as: Me` and `Who has access to the app: Anyone`, the Web Apps can be accessed by a simple script of `requests.get(url)`. More detailed sample script can be seen at https://gist.github.com/tanaikech/a72aab0242012362c46ec69031c720d5#python . In this case, when the sample API key is prepared, the security can be also high a little. – Tanaike Nov 11 '22 at 04:53