0

I'm building a webhook to send Zoom Recordings to Google Drive. The webhook works properly. However, whenever I tried to create the video on Google Drive, it can't play and display the error Couldn't preview file. There was a problem playing this video

Below is my code:

    var response = UrlFetchApp.fetch(download_url + '?access_token=' + download_token);
    var getfile = response.getBlob();
    file = {
      title : name,
      mimeType : file_type.toLowerCase()
    };
    
    var mainFolders = DriveApp.getFoldersByName(SessionFolderName);
    if (!mainFolders.hasNext()) {
      DriveApp.createFolder(SessionFolderName);
      mainFolders = DriveApp.getFoldersByName(SessionFolderName);
    }
    
    mainFolder = mainFolders.next();
    
    var accFolders = mainFolder.getFoldersByName(account);
    if (!accFolders.hasNext()) {
      mainFolder.createFolder(account);
      accFolders = mainFolder.getFoldersByName(account);
    }
    
    accFolder = accFolders.next();
    
    var meetingFolders = accFolder.getFoldersByName(name);
    if (!meetingFolders.hasNext()) {
      accFolder.createFolder(name);
      meetingFolders = accFolder.getFoldersByName(name);
    }
    
    meetingFolder = meetingFolders.next();

    getfile.setName(start + ' - ' + name);
    meetingFolder.createFile(getfile);

I believe there is something to do with mimeType, but I'm not too sure or how to add it while creating a new file. Please give me some advice.

Thank you in advance!

Anh Nguyen
  • 51
  • 6
  • What is the current mimetype? – Cooper May 15 '20 at 17:48
  • hi Cooper, it's mp4 – Anh Nguyen May 15 '20 at 17:52
  • Has the file been created? I mean, can you view the icon in your drive? –  May 15 '20 at 18:16
  • Hi Tyler, yes, I see the file icon, but just unable to play the video. – Anh Nguyen May 15 '20 at 18:40
  • I've uploaded and viewed mp4's and viewed them. How large is it? – Cooper May 15 '20 at 18:43
  • Zoom states the video is 181029791 bytes. On Google Drive, it says 52,427,998 bytes. Sooo, the file is not completed? Also when i tried to download the video from Google Drive, it doesnt have ant ext. – Anh Nguyen May 15 '20 at 18:51
  • it seems like all of my downloaded video on Google Drive is around that size. – Anh Nguyen May 15 '20 at 18:52
  • I don't think that file size is a problem? – Cooper May 15 '20 at 20:53
  • You might want to take a look at this: https://stackoverflow.com/a/61767017/7215091 – Cooper May 15 '20 at 20:58
  • I just noticed something. I cant open and play it on my end. But i can use the shareable link to play in incognito mode. I'm not sure why? – Anh Nguyen May 15 '20 at 22:06
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/213981/discussion-between-anh-nguyen-and-cooper). – Anh Nguyen May 16 '20 at 01:05
  • 1
    UrlFetchApp [is limited to 50 MB per call](https://developers.google.com/apps-script/guides/services/quotas#current_limitations). Because of this, the video file is incomplete, and thus, non-reproducible. Is it mandatory to upload this via Apps Script? – Iamblichus May 18 '20 at 10:33
  • Hi @lambichus, the purpose of the project is to upload Zoom recordings to Google Drive. We have been doing it manually, so I'm trying to find a way that we can save the recordings programmatically whenever the Zoom recording is completed. I think it's not possible to upload it via App Script. The right way is downloading the recordings to the database or local computer, then use App Script to resumable upload it. Or if you have any other way, please give me some advice. Thanks for your response. – Anh Nguyen May 18 '20 at 16:28
  • 1
    Well, if you had a way of retrieving the video data and perform a resumable upload on it without storing it in local, the downloading step would not be needed, but I don't know whether that would be possible. Otherwise, yes, I think that's the way to go. But about using Apps Script, how will you access the local file from there? – Iamblichus May 19 '20 at 11:31
  • Hi @lambichus, I'm still trying to piece everything together. I'm not sure how to do most of them yet. Currently, I just make the webhook request to display on a Google Sheet. If you know any other way, please suggest, I would very appreciate it! – Anh Nguyen May 19 '20 at 15:05
  • 1
    I'd probably use Drive API directly in order to upload the file from local. And I guess you could automate the download process too? For example, if you were using Python, you could make a combination of [this](https://stackoverflow.com/a/16696317/10612011) and [this](https://tanaikech.github.io/2020/03/05/simple-script-of-resumable-upload-with-google-drive-api-for-python/). In any case, I'd need more details on your exact situation (how are you retrieving the video, for example), and what technologies are you willing to use, in order to provide a more specific answer. – Iamblichus May 20 '20 at 10:48
  • Hi @lamblichus, thanks for the recommendation. I can sort of code in Python, not an expert yet. Currently, I built a Webhook in Zoom to send me the notification that includes the Download_URL whenever the Recording is completed. I'm using the Deployed App on App Script as the endpoint. That's how it is set up right now. I'm wondering how to set up the webhook endpoint if I want to retrieve the video and save it in my local pc. – Anh Nguyen May 21 '20 at 05:55

0 Answers0