From 8877507abd8271b00b228135d2824326579831e6 Mon Sep 17 00:00:00 2001 From: Ayushya Amitabh Date: Fri, 26 Feb 2021 19:22:22 -0500 Subject: [PATCH] v1.7.10/version change, add google drive support --- admin/package.json | 2 +- app/package.json | 2 +- app/public/background.js | 2 +- app/public/manifest.json | 6 +++-- app/src/Api.js | 3 +++ app/src/App.js | 2 +- app/src/VideoListener.js | 36 +++++++++++++++++++++++++- functions/package.json | 2 +- functions/webhooks/scheduledCleanUp.js | 8 ++++-- package.json | 2 +- 10 files changed, 54 insertions(+), 11 deletions(-) diff --git a/admin/package.json b/admin/package.json index a6b27bb..6c920c2 100644 --- a/admin/package.json +++ b/admin/package.json @@ -1,6 +1,6 @@ { "name": "watch-party-admin", - "version": "1.7.9", + "version": "1.7.10", "private": true, "devDependencies": { "@ant-design/icons": "^4.2.2", diff --git a/app/package.json b/app/package.json index 634fd1b..0deb9ef 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "watch-party-crx", - "version": "1.7.9", + "version": "1.7.10", "private": true, "dependencies": {}, "scripts": { diff --git a/app/public/background.js b/app/public/background.js index 635406c..c03c250 100644 --- a/app/public/background.js +++ b/app/public/background.js @@ -26,7 +26,7 @@ try { console.info("CHROME ENV"); } -const APP_VERSION = "1.7.9"; +const APP_VERSION = "1.7.10"; const APP_VERSION_STRING = APP_VERSION.replace(/\./g, ""); const firebaseConfig = { diff --git a/app/public/manifest.json b/app/public/manifest.json index 3ddd2e2..25f2360 100644 --- a/app/public/manifest.json +++ b/app/public/manifest.json @@ -1,7 +1,7 @@ { "name": "Watch Party", "short_name": "WP", - "version": "1.7.9", + "version": "1.7.10", "description": "Watch streamed content together.", "background": { "page": "background.html" @@ -47,6 +47,7 @@ "https://*.airtelxstream.in/*", "https://*.vimeo.com/*", "https://*.dailymotion.com/*", + "https://drive.google.com/*", "https://api.giphy.com/*", "https://*.voxeet.com/*" ], @@ -89,7 +90,8 @@ "https://*.hotstar.com/*", "https://*.airtelxstream.in/*", "https://*.vimeo.com/*", - "https://*.dailymotion.com/*" + "https://*.dailymotion.com/*", + "https://drive.google.com/*" ], "run_at": "document_idle", "js": ["/static/js/content.js"], diff --git a/app/src/Api.js b/app/src/Api.js index 16b28c9..50a19f5 100644 --- a/app/src/Api.js +++ b/app/src/Api.js @@ -43,6 +43,7 @@ export const PLAYER_SOURCE = { AIRTEL: "airtelxstream.", VIMEO: "vimeo.", DAILYMOTION: "dailymotion.", + GOOGLEDRIVE: "drive.google.", LOCAL: "localhost", }; @@ -71,6 +72,8 @@ export const getPlayerSource = () => { if (HREF.includes(PLAYER_SOURCE.VIMEO)) return PLAYER_SOURCE.VIMEO; if (HREF.includes(PLAYER_SOURCE.DAILYMOTION)) return PLAYER_SOURCE.DAILYMOTION; + if (HREF.includes(PLAYER_SOURCE.GOOGLEDRIVE)) + return PLAYER_SOURCE.GOOGLEDRIVE; if (HREF.includes(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL; }; diff --git a/app/src/App.js b/app/src/App.js index 25276e9..1a975e0 100644 --- a/app/src/App.js +++ b/app/src/App.js @@ -34,7 +34,7 @@ import { } from "./Api"; import Tutorial from "./Tutorial"; -const APP_VERSION = "1.7.9"; +const APP_VERSION = "1.7.10"; const APP_VERSION_STRING = APP_VERSION.replace(/\./g, ""); const darkTheme = createMuiTheme({ diff --git a/app/src/VideoListener.js b/app/src/VideoListener.js index acceb96..67af6b1 100644 --- a/app/src/VideoListener.js +++ b/app/src/VideoListener.js @@ -143,6 +143,7 @@ export default class VideoListener { case PLAYER_SOURCE.CRUNCHYROLL: case PLAYER_SOURCE.FUNIMATION: case PLAYER_SOURCE.ROOSTERTEETH: + case PLAYER_SOURCE.GOOGLEDRIVE: window.postMessage( JSON.stringify({ watchPartyDirection: "TO_SCRIPT", @@ -175,7 +176,8 @@ export default class VideoListener { PLAYER_SOURCE.HULU === this.video.source || PLAYER_SOURCE.NETFLIX === this.video.source || PLAYER_SOURCE.HBOMAX === this.video.source || - PLAYER_SOURCE.HBONOW === this.video.source + PLAYER_SOURCE.HBONOW === this.video.source || + PLAYER_SOURCE.GOOGLEDRIVE === this.video.source ) { if ( serverPlayer.status === PLAYER_STATUS.PAUSED || @@ -500,6 +502,38 @@ export default class VideoListener { ); } break; + case PLAYER_SOURCE.GOOGLEDRIVE: + const googleDriveInject = `var watchPartyInteraction=function(e){const data=JSON.parse(e.data);const player=document.querySelector("${vS}").contentWindow.document.querySelector('video');if(player){if(data.watchPartyDirection==='TO_SCRIPT'){if(data.type==='WATCH_PARTY_SEEK'){player.currentTime(data.time)}else if(data.type==='WATCH_PARTY_STATUS'){if(data.status==='PAUSED')player.pause();if(data.status==='PLAYING')player.play()}}}};window.addEventListener("message",watchPartyInteraction);`; + const googleDriveInjectScript = document.createElement("script"); + googleDriveInjectScript.text = googleDriveInject; + document.head.appendChild(googleDriveInjectScript); + const googleDrivePlayerIframe = document.querySelector(vS); + if (googleDrivePlayerIframe) { + const googleDrivePlayer = googleDrivePlayerIframe.contentWindow.document.querySelector( + "video" + ); + if (googleDrivePlayer) { + this.firstTimeSync(googleDrivePlayerIframe); + } + } else { + setInterval( + this.video.element + ? null + : () => { + const gdif = document.querySelector(vS); + if (gdif) { + const gdp = gdif.contentWindow.document.querySelector( + "video" + ); + if (gdp) { + this.firstTimeSync(gdif); + } + } + }, + 1000 + ); + } + break; case PLAYER_SOURCE.CRUNCHYROLL: const crunchyRollInject = `var sendToWatchPartyApp = function(pS, pT) { var customWatchPartyEvent = new CustomEvent('watchParty', { detail: { watchPartyDirection: 'TO_APP', type: 'WATCH_PARTY_PLAYER_UPDATE', status: pS, time: pT } }); window.dispatchEvent(customWatchPartyEvent); }, watchPartyGetTimeAndSend = function(pS) { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.getCurrentTime(function(pT) { sendToWatchPartyApp(pS, pT); }); } }, watchPartySendPlaying = function() { watchPartyGetTimeAndSend('PLAYING'); }, watchPartySendPaused = function() { watchPartyGetTimeAndSend('PAUSED'); }, watchPartyInteraction = function(e) { if (e.source === window) { const data = JSON.parse(e.data); if (data.watchPartyDirection === 'TO_SCRIPT') { if (data.type === 'WATCH_PARTY_ADD_LISTENERS') { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.on('play', watchPartySendPlaying, 'player.js'); window.VILOS_PLAYERJS.on('pause', watchPartySendPaused, 'player.js'); } } else if (data.type === 'WATCH_PARTY_SEEK') { if (window.VILOS_PLAYERJS) { window.VILOS_PLAYERJS.setCurrentTime(data.time); } } else if (data.type === 'WATCH_PARTY_STATUS') { if (window.VILOS_PLAYERJS) { if (data.status === 'PAUSED') window.VILOS_PLAYERJS.pause(); if (data.status === 'PLAYING') window.VILOS_PLAYERJS.play(); } } } } }; window.addEventListener("message", watchPartyInteraction);`; const crunchyRollInjectScript = document.createElement("script"); diff --git a/functions/package.json b/functions/package.json index fa4f9dd..dffa228 100644 --- a/functions/package.json +++ b/functions/package.json @@ -1,6 +1,6 @@ { "name": "watch-party-api", - "version": "1.7.9", + "version": "1.7.10", "description": "Cloud Functions for Watch Party", "scripts": { "lint": "eslint .", diff --git a/functions/webhooks/scheduledCleanUp.js b/functions/webhooks/scheduledCleanUp.js index d564d88..ba9a536 100644 --- a/functions/webhooks/scheduledCleanUp.js +++ b/functions/webhooks/scheduledCleanUp.js @@ -72,8 +72,12 @@ module.exports = async (req, res) => { ); }); - var ids = await roomIdList(roomList); - batchDeleteRooms(ids, ids.length); + if (roomList.length > 0) { + var ids = await roomIdList(roomList); + if (ids.length > 0) { + batchDeleteRooms(ids, ids.length); + } + } return; }; diff --git a/package.json b/package.json index 6040d76..d1e6dae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "watch-party", - "version": "1.7.9", + "version": "1.7.10", "description": "Watch Party", "scripts": { "start": "firebase emulators:start",