Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for videos streamed from google drive #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const TYPE_NOTES = 'notes';
export const TYPE_VIDEO_NOTE = 'video';

export const PROVIDER_YOUTUBE = 'youtube';
export const PROVIDER_GOOGLEDRIVE = 'googledrive';

export const NODE_ENV_PLAYGROUND = 'playground';

Expand Down
3 changes: 2 additions & 1 deletion packages/common/utils/buildAutoSeekUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ export default (url, timestamp) => {
if (timestamp < 0) {
timestamp = 0;
}

const { provider } = videoUrlParser.parse(url) || {};
const parsedUrl = new URL(url);
const params = new URLSearchParams(parsedUrl.search);
params.delete('t');
params.delete(QUERY_AUTO_JUMP);
if (provider === 'youtube') {
params.set('t', timestamp);
} else if (provider === 'googledrive') {
params.set('t', timestamp);
} else {
params.set(QUERY_AUTO_JUMP, timestamp);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/common/utils/generatePageId.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fromString } from 'uuidv4';
import compose from 'compose-function';
import videoUrlParser from 'js-video-url-parser';
import { PROVIDER_YOUTUBE } from '../constants';
import { PROVIDER_GOOGLEDRIVE, PROVIDER_YOUTUBE } from '../constants';

const getUrlWithoutHash = url => {
const parsedUrl = new URL(url);
Expand All @@ -21,6 +21,8 @@ export default url => {
)(url);
if (provider === PROVIDER_YOUTUBE) {
return fromString(`${provider}-${id}`);
} else if (provider === PROVIDER_GOOGLEDRIVE) {
return fromString(`${provider}-${id}`);
}

return fromString(urlWithoutHash);
Expand Down