Alert: If You Embed "Private" Vimeo Videos...

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Curlyshell
Propeller Head
Posts: 65
Joined: Fri Mar 01, 2019 9:14 am

Alert: If You Embed "Private" Vimeo Videos...

Post by Curlyshell »

I just had an issue with a private Vimeo file embedded in a Flare topic. Though the old videos are still playing, a video I just uploaded wouldn't display or play.

Vimeo Support explained that they've stepped up their security (which I'll explain below), and new videos are required to comply. But soon all the other videos will be in the same boat—so none of my embedded videos will play unless I fix them. Here's what I know, and what you can do about it for now.

There's a "security hash" included in each private Vimeo video. Here's what it looks like, with the hash in bold:

ORIGINAL LINK:
https:/ /vimeo.com/1a2b3c4d5e/6f7g8h9i0j (dummy code & spaces added to remove auto link).

EMBED CODE ACQUIRED FROM VIMEO: (Note that the /xxx is replaced with ?h=xxx)
<iframe src="https:/ /player.vimeo.com/video/1a2b3c4d5e?h=6f7g8h9i0j" width="640" height="142" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>

But when Flare renders the output, it removes the security hash!!! Up ’til now, that hasn't mattered because Vimeo created this extra security layer but wasn't yet requiring it. Now, you can't access a "Private" Vimeo video without the security hash.

Here are TWO WORKAROUNDS:

1. Go into the rendered pages and add the hash. Well that's OK if you only have one or two...

2. In Vimeo, make the videos "invisible to Vimeo" instead of "Private." Here's what Vimeo says about this setting:

"When you hit save, this video will be removed from all channels and groups, and any credits you've added will be removed."

Make sure that's an appropriate solution for your video. It doesn't remove the video from your account; you can still see and manipulate it.

I reported this to MadCap as a bug.

Hope this helps someone.
"I'm a technical writer, not a developer," she said...
Alan at jjj
Jr. Propeller Head
Posts: 7
Joined: Mon Jan 24, 2022 4:49 am

Re: Alert: If You Embed "Private" Vimeo Videos...

Post by Alan at jjj »

Unfortunately with the latest release of Flare 2022, this bug still hasn't been fixed. So you might be interested in using my solution to automatically fix the rendered Flare output.

This takes the form of some post-build processing automatically started from your Target that spawns a Powershell script file that resides in the Content Explorer root directory. For easy maintenance, enter your set of correct Vimeo video codes + hash codes in the Flare VariableSet named VimeoCodes in the following format. For example:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<CatapultVariableSet>
  <Variable
    Name="Video1"
    Comment="note: 3 x fake hash codes"
    EvaluatedDefinition="646085504?h=ae2e02edaj">646085504?h=ae2e02edaj</Variable>
  <Variable
    Name="Video2"
    Comment=""
    EvaluatedDefinition="646070519?h=f0b3d9c4fj">646070519?h=f0b3d9c4fj</Variable>
  <Variable
    Name="Video3"
    Comment=""
    EvaluatedDefinition="646070879?h=243c069c7j">646070879?h=243c069c7j</Variable>
</CatapultVariableSet>
but please note these example codes are not genuine Vimeo videos.

In your Target's properties (Build Events|Post-Build Event Command box) enter the following 4 commands:

Code: Select all

set PROJECTDIR=$(ProjectDirectory)
set OUTPUTDIR=$(OutputDirectory)
cd %PROJECTDIR%Content
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File .\Fix-jutVimeoCodes.ps1 *>> .\Fix-jutVimeoCodes.log
Finally place the following PowerShell script as filename Fix-jutVimeoCodes.ps1 in your Content Explorer root directory:

Code: Select all

# Powershell script: Fix-jutVimeoCodes.ps1 by alanatjjj@gmail.com 23-JUN-2022. Fixes Vimeo URLs broken by Flare. USE AT YOUR OWN RISK.
#
# Notes/Assumptions: 
#  1. Only tested in Windows 10, PowerShell 5.1, Flare 2021r3 & 2022. 
#  2. Assumes HTML output is generated in the Output "Content" subdirectory - see Target|Advanced|Output Options.
#  3. Edits all .htm files (not .html files) even if there are no changes, and preserves the original versions in .bak files.
#  4. Fixes only the Vimeo video code + hash code pairs stored in the "VimeoCodes" Flare VariableSet file in the same project.
#  5. The example video code + hash code pairs are not genuine videos. Ensure you insert your own genuine codes.

#UTILITIES-----------------------

function Test-jutFound ($index) {
#returns True if key found (ie. $index is > -1) for more readable code.
#for use, for example, with the index from a IndexOf or LastIndexOf string method for finding a key. 
  Return (-1 -lt $index)
}

function Test-jutDirExists ($dir) {
#wrapper to simplify usage to determine if directory exists
  Return (Test-Path -Path $dir -PathType Container)
}

function Test-jutFileExists ($file) {
#wrapper to simplify usage to determine if file exists
  Return (Test-Path -Path $file -PathType Leaf)
}

function Set-jutConstant ($name, $value, $description) {
#simplifies definition of a constant value
  if ( Test-jutFileExists "Variable:$name" ) {   #can also test for variables by using "Variable:" 'drive'
    Remove-Variable -Name $name -Scope Global -Force
  }
  Set-Variable -Name $name -Value "$value" -Option ReadOnly -Scope Global -Description "$description"   #must be ReadOnly instead of Constant so it can be recreated
}

#CONSTANTS-----------------------

#Characters   
Set-jutConstant 'BACKSLASH'         '\'   'Character: backslash'
Set-jutConstant 'COMMA'             ','   'Character: comma'
Set-jutConstant 'DOT'               '.'   'Character: dot'
Set-jutConstant 'QUOTE'             '"'   'Character: quote'
Set-jutConstant 'SLASH'             '/'   'Character: slash'
Set-jutConstant 'UNDERSCORE'        '_'   'Character: underscore'
Set-jutConstant 'AMPERSAND'         '&'   'Character: ampersand'
Set-jutConstant 'ENTITYAMP'         '&'   'Character: ampersand HTML entity'

#filenames & partial filenames
Set-jutConstant 'OUTPUTDIR'         $Env:OUTPUTDIR.TrimEnd($BACKSLASH)   'Absolute pathname of directory where Flare builds the output files'   #also ensures that $OUTPUTDIR doesn't end in a "\" - the Powershell properties convention
Set-jutConstant 'PARTPATHCONTENTNS' '\Content'                           'Partial pathname: Content with no final backslash'
Set-jutConstant 'CONTENTDIR'        ($OUTPUTDIR + $PARTPATHCONTENTNS)    'The Content dir in $OUTPUTDIR'
Set-jutConstant 'EXTBAK'            '.bak'                               'Extension for a general purpose backup/temporary file'
Set-jutConstant 'VIDEOSFILE'        ($Env:PROJECTDIR + 'Project\VariableSets\VimeoCodes.flvar')   'File of Flare variables containing Vimeo private video codes (partial URLs)'
Set-jutConstant 'MIDVIMEOCODE'      '?h='                                'Delimiter midway through Vimeo video code - eg. within full code: "646085504?h=ae2e02eda1"'

#messaging
Set-jutConstant 'OUTWIDTH'          1000                       'Width of lines written to console / log file - prevents wrapping'
Set-jutConstant 'DATEFORMAT'        'dd/MM/yyyy HH:mm'         'Message datetime format'
Set-jutConstant 'WARN'              '***WARNING:'              'Message prefix: Warning'
Set-jutConstant 'ERR'               '***ERROR:'                'Message prefix: Error'



#console messages
'.', '.', '.', '====Fix-jutVimeoCodes.ps1=================================================================================================================='
'Project directory env var   :  >{0}<  ' -f   $Env:PROJECTDIR   #from Flare Target Post Build commands as passed by $(ProjectDirectory) variable - note includes a final "\"
'Output  directory env var   :  >{0}<  ' -f   $Env:OUTPUTDIR    #from Flare Target Post Build commands as passed by $(OutputDirectory)  variable - note includes a final "\"
'Output  directory processing:  >{0}<  ' -f   $OUTPUTDIR        #note that any final "\" has been removed

$now = Get-Date -Format $DATEFORMAT

'', "Post build processing $now"



#MAIN-------------------------------------------------------------------------------------------------------------------------
#Flare [v2021r3] breaks the Vimeo hash code embedded in the URLs (Madcap bug #172869). This code repairs the URLs.
# Rev 2b: now detects both terminators of the truncated URL - '"' if Vimeo player has all the default settings, and '&' if Vimeo player has one or more non-default settings. ie:
#  eg1. corrects from: <iframe class="vimeo-player_0" src="https://player.vimeo.com/video/646085504?&byline=0&title=0&portrait=0" frameborder="0" allowfullscreen="1" width="640px" height="323px"></iframe>
#                  to: <iframe class="vimeo-player_0" src="https://player.vimeo.com/video/646085504?h=ae2e02eda1&byline=0&title=0&portrait=0" frameborder="0" allowfullscreen="1" width="640px" height="323px"></iframe>
#    repair is here---------------------------------------------------------------------------------^^^^^^^^^^^^
#  eg2. corrects from: <iframe class="vimeo-player_0" src="https://player.vimeo.com/video/646085504?" frameborder="0" allowfullscreen="1" width="560px" height="315px"></iframe>
#                  to: <iframe class="vimeo-player_0" src="https://player.vimeo.com/video/646085504?h=ae2e02eda1" frameborder="0" allowfullscreen="1" width="560px" height="315px"></iframe>
#    repair is here---------------------------------------------------------------------------------^^^^^^^^^^^^
$videos = $null

#console messages
'', '', "Repairing Vimeo video URLs in ""$CONTENTDIR"""

if ( ! (Test-jutFileExists $VIDEOSFILE) ) {

  "$ERR Unable to fix broken Vimeo URLs as can't find file of codes: $VIDEOSFILE"

} else {
	
  #obtain the correct set of vimeo codes from Flare's variable set file
  $videos = Select-Xml -Path $VIDEOSFILE -XPath "/CatapultVariableSet/Variable[contains(., `"$MIDVIMEOCODE`")]"
#debug:  $videos.Node | Format-List



  #for every .htm file in output dir
  Get-ChildItem -Path $CONTENTDIR -Recurse -Attributes !Directory -Filter *.htm | ForEach-Object {

    $htm = $_.FullName
    $bak = $htm + $EXTBAK

    #preserve original file
    if ( Test-jutFileExists $htm ) {
      if ( Test-jutFileExists $bak ) {
        Remove-Item -Path $bak -Force
      }
      Rename-Item -Path $htm -NewName $bak -Force
    }

    " processing: $htm"
    $changes = $null;



    #for every line in file
    (Get-Content -Path $bak) | ForEach-Object {

      $line = $_;
		  
		  
		  
      #for every vimeo code
      $videos | ForEach-Object {
		
        $video = $_
        $varname =  $video.Node.Name
        $goodcode = $video.Node.InnerXml
        $badcode =  $goodcode.Substring(0, ($goodcode.IndexOf($MIDVIMEOCODE) + 1))   #this is the corruption caused by Flare - ie. code truncated after the "?" character

        $before = $line;
		
        #set the terminating character(s) for each of the two forms of bad code, then fix
        $term = $ENTITYAMP   #eg: 646085504?& --> 646085504?h=ae2e02eda1&
        $line = $line.Replace(($badcode + $term), ($goodcode + $term))
        $term = $QUOTE       #eg: 646085504?" --> 646085504?h=ae2e02eda1"
        $line = $line.Replace(($badcode + $term), ($goodcode + $term))

        if ( $line -ne $before ) {
          $changes += "   $varname`n";   # "`n" is a newline
          $changes += "$line`n";
        }
	  
      }   #end [for every vimeo code]



      $_ = $line;
      $_;
	  
    } | Set-Content -Path $htm   #end [for every line in file]; output the processed file that if applicable will now be repaired


		  
    #console (log file) info
    if ( $changes ) {
      $changes | Out-String -Width $OUTWIDTH;
    }

  }   #end [for every .htm file in output dir]
  


}

#console message
'', '', 'Post build complete'
When the Target is built and the post-build event commands complete, then your Vimeo URLs will be repaired.

Check the Fix-jutVimeoCodes.log file for details. Note that the original versions of the *.htm output files will be retained as *.htm.bak files, so you might want to delete them before publishing your web.

Hope you find this useful.
Best wishes
Alan
Alan at jjj
Jr. Propeller Head
Posts: 7
Joined: Mon Jan 24, 2022 4:49 am

Re: Alert: If You Embed "Private" Vimeo Videos...

Post by Alan at jjj »

Unfortunately with the latest release of Flare 2023, this bug still hasn't been fixed. My code shown in the previous post fixes the Vimeo URLs in the Flare 2023 output.
Post Reply