Problem/Motivation

Vimeo introduced a hash parameter (h) that has to be appended to private video URLs in order to be embedded.
Example:
https://player.vimeo.com/video/607242810?h=47f19305fd&autoplay=0

Without the hash, the Vimeo video will display a message "Sorry This video does not exist message" or "Sorry We’re having a little trouble."

Proposed resolution

Extract the hash parameter from the provided video URL and append it to the player embed as the "h" query string parameter.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

puidu created an issue. See original summary.

puidu’s picture

Title: Vimeo hash parameter » Vimeo hash parameter on private video url
StatusFileSize
new842 bytes
puidu’s picture

markgp’s picture

#3 doesn't work for us. Our users are pasting the share link into the field, which has the hash as the second URL segment rather than a query string.

// this
vimeo.com/{id}/{hash}

// not this
vimeo.com/{id}?h={hash}

Here's a patch that covers both cases.

sokru’s picture

Version: 8.x-2.2 » 8.x-2.x-dev
Status: Active » Needs work

#4 works nicely, but I'm setting "Needs work" since I expect module maintainer would like to have test coverage for this.

nathan tsai’s picture

#4 works on 2.4!

I encountered this issue when trying to embed an unlisted video, with the format:

https://vimeo.com/{id}/{hash}?embedded=true&source=vimeo_logo&owner={owner-id}

I had to remove the query parameter though (e.g. https://vimeo.com/{id}/{hash}) in order for it to work.

Could we update the regex string to support having excess query parameters? Perhaps by removing the $ from the end of the regex?

For example, using ^https?:\/\/(www\.)?vimeo.com\/(channels\/[a-zA-Z0-9]*\/)?(?<id>[0-9]*)(\/(?<hash>[a-zA-Z0-9]+))?(\#t=(\d+)s)? instead.

See https://regex101.com/r/ZQGI9K/1 vs https://regex101.com/r/ZQGI9K/2.

recrit’s picture

The patch attached is an update to the patch #4 that adds the following:
- Support PHP 8: The patch fixes the warning: "Deprecated function: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated".
- Removes the trailing "$" from the regex to allow for other query parameters to be on the input string. This addresses the comment in #6.

recrit’s picture

Re-uploading the patch as it was 0 bytes by mistake.

The patch attached is an update to the patch #4 that adds the following:
- Support PHP 8: The patch fixes the warning: "Deprecated function: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated".
- Removes the trailing "$" from the regex to allow for other query parameters to be on the input string. This addresses the comment in #6.

d70rr3s’s picture

This is great, we stumble on this issue without knowing was about the hash since the error thrown by the request was a little bit cryptic. Any way, RTBC on Drupal 8.9 and module version 2.4. Many thanks, great work!

sagesolutions’s picture

Status: Needs work » Reviewed & tested by the community

Setting to RTBC as per d70rr3s

kunal_sahu made their first commit to this issue’s fork.

kunal_sahu’s picture

Hi @all Thanks you for all your patches. The patch video_embed_field-vimeo_hash_parameters_private_video-3238136-8.patch applied successfully.

PS C:\xampp\htdocs\drupal\web\themes\custom\video_embed_field-2580459> git apply -v .\youtube_autoplay-2580459-25.patch
Checking patch video_embed_field.handlers.inc...

PS C:\xampp\htdocs\drupal\web\themes\custom\video_embed_field-3238136> git apply -v .\video_embed_field-vimeo_hash_parameters_private_video-3238136-8.patch
Checking patch src/Plugin/video_embed_field/Provider/Vimeo.php...
Applied patch src/Plugin/video_embed_field/Provider/Vimeo.php cleanly.

LGTM.

Creating an MR for helping out maintainer. Thanks recrit for the patch . Thanks

cslevy’s picture

The patch doesn't apply anymore.
Created a new patch which applies to the latest dev version

mably’s picture

Version: 8.x-2.x-dev » 3.0.x-dev

Hi @cslevy, could you provide an MR against 3.0.x please?

mably’s picture

Version: 3.0.x-dev » 8.x-2.x-dev
ezeedub’s picture

Version: 8.x-2.x-dev » 3.0.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.27 KB

Here's an updated patch for 3.0.x

mably’s picture

Hi @ezeedub, thanks for your patch. Could you create an MR please?

mably’s picture

bkosborne’s picture

The patch doesn't appear to work for the input example provided in the original report: https://player.vimeo.com/video/607242810?h=47f19305fd&autoplay=0

This is because the main regex that's used for validating if the Vimeo provider can parse the input doesn't allow query string parameters. This was mentioned in #6 and it wasn't completely addressed. The regex in getIdFromInput needs to be updated to remove the $ at the end.
Nevermind, I see that video URL was the embedded version of the URL, not the source URL that someone would paste in.

And yes, the patch should be converted to an MR.

bkosborne’s picture

Title: Vimeo hash parameter on private video url » Unlisted Vimeo videos don't work because they are missing the required hash parameter
Issue summary: View changes
Status: Needs review » Needs work

Closed #3270201: For Vimeo videos in format vimeo.com/ABC/123, the popup should be https://player.vimeo.com/video/ABC?h=123, not https://player.vimeo.com/video/ABC as a duplicate of this.

Maintainer, please update contribution record to add people that contributed in that issue as well.

bkosborne changed the visibility of the branch 3238136-vimeo-hash-parameter to hidden.

bkosborne changed the visibility of the branch 3.x to hidden.

bkosborne changed the visibility of the branch master to hidden.

bkosborne’s picture

Status: Needs work » Needs review

Ported over the MR from the other issue and updated it to fix a few things. Unit tests passed locally. This should be good to go.

znak’s picture

Added patch for version 3.0.0

mably’s picture

Version: 3.0.x-dev » 3.x-dev
Status: Needs review » Needs work

MR needs to be updated: linting errors and failing tests.

ethant made their first commit to this issue’s fork.