You should use the methods we have for this in LicensedVideoSwapHelper:

  $helper = new LicensedVideoSwapHelper();
  $helper->setPageStatusSwappable( $page_id );

This would replace lines 73-81