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

Feature/add transcoded url meta #295

Closed
wants to merge 6 commits into from

Conversation

pranvinit
Copy link

Types of changes

What types of changes does your code introduced to project?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update

Details

  1. Add a _rt_transcoded_url meta field to the attachment to save the transcoded URL.
  2. Add an editable URL form field in the media modal.
  3. Add a toggle to set Adaptive Bitrate Streaming in the transcoder settings page.
  4. WIP: Progress bar functionality.

Checklist

Put an x in the boxes that apply.

  • Lint and tests pass locally with my changes
  • I have added necessary documentation (if appropriate)

Closing issues

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis identified issues

action-phpcs-code-review has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.

phpcs scanning turned up:

🚫 29 errors

⚠️ 12 warnings


skipped-files

Maximum number of lines exceeded (15000):

  • assets/build/blocks/rt-player/index.js

Note that the above file(s) were not analyzed due to their length.


Powered by rtCamp's GitHub Actions Library

Posting will continue in further review(s)

admin/rt-transcoder-handler.php Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
admin/rt-transcoder-handler.php Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
admin/rt-transcoder-handler.php Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

admin/rt-transcoder-handler.php Outdated Show resolved Hide resolved
// if ( $usage_info[ $this->api_key ]->remaining < 524288000 && ! get_site_option( 'rt-transcoding-usage-limit-mail' ) ) {
// $this->nearing_usage_limit( $usage_info );
// } elseif ( $usage_info[ $this->api_key ]->remaining > 524288000 && get_site_option( 'rt-transcoding-usage-limit-mail' ) ) {
// update_site_option( 'rt-transcoding-usage-limit-mail', 0 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 space before comment text but found 2; use block comment if you need indentation (Squiz.Commenting.InlineComment.SpacingBefore).

// update_site_option( 'rt-transcoding-usage-limit-mail', 0 );
// }
// if ( strtotime( $usage_info[ $this->api_key ]->plan->expires ) > time() ) {
// add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_media_transcoding' ), 21, 2 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Spaces must be used for mid-line alignment; tabs are not allowed (Universal.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed).

// update_site_option( 'rt-transcoding-usage-limit-mail', 0 );
// }
// if ( strtotime( $usage_info[ $this->api_key ]->plan->expires ) > time() ) {
// add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_media_transcoding' ), 21, 2 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 space before comment text but found 2; use block comment if you need indentation (Squiz.Commenting.InlineComment.SpacingBefore).

// }
// if ( strtotime( $usage_info[ $this->api_key ]->plan->expires ) > time() ) {
// add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_media_transcoding' ), 21, 2 );
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).

@@ -264,27 +268,27 @@
'api_token' => $this->api_key,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 7 space(s) between "'api_token'" and double arrow, but found 4 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

@@ -264,27 +268,27 @@
'api_token' => $this->api_key,
'job_type' => $job_type,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 8 space(s) between "'job_type'" and double arrow, but found 5 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

@@ -264,27 +268,27 @@
'api_token' => $this->api_key,
'job_type' => $job_type,
'job_for' => $job_for,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 9 space(s) between "'job_for'" and double arrow, but found 6 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

@@ -264,27 +268,27 @@
'api_token' => $this->api_key,
'job_type' => $job_type,
'job_for' => $job_for,
'file_url' => rawurlencode( $url ),
'file_origin' => rawurlencode( $url ),
'callback_url' => rawurlencode( trailingslashit( home_url() ) . 'index.php' ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 4 space(s) between "'callback_url'" and double arrow, but found 1 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

@@ -264,27 +268,27 @@
'api_token' => $this->api_key,
'job_type' => $job_type,
'job_for' => $job_for,
'file_url' => rawurlencode( $url ),
'file_origin' => rawurlencode( $url ),
'callback_url' => rawurlencode( trailingslashit( home_url() ) . 'index.php' ),
'force' => 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 11 space(s) between "'force'" and double arrow, but found 8 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

@@ -264,27 +268,27 @@ public function wp_media_transcoding( $wp_metadata, $attachment_id, $autoformat
'api_token' => $this->api_key,
'job_type' => $job_type,
'job_for' => $job_for,
'file_url' => rawurlencode( $url ),
'file_origin' => rawurlencode( $url ),
'callback_url' => rawurlencode( trailingslashit( home_url() ) . 'index.php' ),
'force' => 0,
'formats' => ( true === $autoformat ) ? ( ( 'video' === $type_array[0] ) ? 'mp4' : 'mp3' ) : $autoformat,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 9 space(s) between "'formats'" and double arrow, but found 6 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

'callback_url' => rawurlencode( trailingslashit( home_url() ) . 'index.php' ),
'force' => 0,
'formats' => ( true === $autoformat ) ? ( ( 'video' === $type_array[0] ) ? 'mp4' : 'mp3' ) : $autoformat,
'thumb_count' => $options_video_thumb,
'thumbnail_count' => $options_video_thumb,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Array double arrow not aligned correctly; expected 1 space(s) between "'thumbnail_count'" and double arrow, but found 2 (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).

if ( ! is_wp_error( $upload_page ) &&
(
isset( $upload_page['response']['code'] ) &&
200 === intval( $upload_page['response']['code'] )
)
) {
$upload_info = json_decode( $upload_page['body'] );
if ( isset( $upload_info->status ) && $upload_info->status && isset( $upload_info->job_id ) && $upload_info->job_id ) {
$job_id = $upload_info->job_id;
error_log(json_encode($upload_info));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: error_log() found. Debug code should not normally be used in production (WordPress.PHP.DevelopmentFunctions.error_log_error_log).

if ( ! is_wp_error( $upload_page ) &&
(
isset( $upload_page['response']['code'] ) &&
200 === intval( $upload_page['response']['code'] )
)
) {
$upload_info = json_decode( $upload_page['body'] );
if ( isset( $upload_info->status ) && $upload_info->status && isset( $upload_info->job_id ) && $upload_info->job_id ) {
$job_id = $upload_info->job_id;
error_log(json_encode($upload_info));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 spaces after opening parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket).

if ( ! is_wp_error( $upload_page ) &&
(
isset( $upload_page['response']['code'] ) &&
200 === intval( $upload_page['response']['code'] )
)
) {
$upload_info = json_decode( $upload_page['body'] );
if ( isset( $upload_info->status ) && $upload_info->status && isset( $upload_info->job_id ) && $upload_info->job_id ) {
$job_id = $upload_info->job_id;
error_log(json_encode($upload_info));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: json_encode() is discouraged. Use wp_json_encode() instead (WordPress.WP.AlternativeFunctions.json_encode_json_encode).

if ( ! is_wp_error( $upload_page ) &&
(
isset( $upload_page['response']['code'] ) &&
200 === intval( $upload_page['response']['code'] )
)
) {
$upload_info = json_decode( $upload_page['body'] );
if ( isset( $upload_info->status ) && $upload_info->status && isset( $upload_info->job_id ) && $upload_info->job_id ) {
$job_id = $upload_info->job_id;
error_log(json_encode($upload_info));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket).

@@ -1151,7 +1156,12 @@ public function handle_callback() {
}

if ( ! empty( $post_array['files'] ) ) {
$this->add_transcoded_files( $post_array['files'], $attachment_id, $job_for );
if ( ! empty($post_array['files']['mpd']) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 spaces after opening parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket).

@@ -1151,7 +1156,12 @@ public function handle_callback() {
}

if ( ! empty( $post_array['files'] ) ) {
$this->add_transcoded_files( $post_array['files'], $attachment_id, $job_for );
if ( ! empty($post_array['files']['mpd']) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 spaces before closing parenthesis; 0 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket).

@@ -1151,7 +1156,12 @@ public function handle_callback() {
}

if ( ! empty( $post_array['files'] ) ) {
$this->add_transcoded_files( $post_array['files'], $attachment_id, $job_for );
if ( ! empty($post_array['files']['mpd']) ) {
update_post_meta( $attachment_id, '_rt_transcoded_url', $post_array['download_url'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 spaces before closing parenthesis; 2 found (PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket).

$this->add_transcoded_files( $post_array['files'], $attachment_id, $job_for );
if ( ! empty($post_array['files']['mpd']) ) {
update_post_meta( $attachment_id, '_rt_transcoded_url', $post_array['download_url'] );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 space after closing brace; newline found (Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace).

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

@@ -1633,6 +1643,9 @@ private function filter_transcoder_response() {
} elseif ( ! empty( $post_var['files']['mp3'][0] ) ) {
$post_array['files']['mp3'][] = filter_var( $post_var['files']['mp3'][0], FILTER_SANITIZE_URL );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 space after closing brace; newline found (Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace).

@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '9a42bf9ab6cdcc318598');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing file doc comment (Squiz.Commenting.FileComment.Missing).

@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '9a42bf9ab6cdcc318598');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 space after the array opener in a single line array. Found: no spaces (NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerSingleLine).

@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '9a42bf9ab6cdcc318598');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).

@@ -0,0 +1 @@
<?php return array('dependencies' => array(), 'version' => '9a42bf9ab6cdcc318598');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Expected 1 space before the array closer in a single line array. Found: no spaces (NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceBeforeArrayCloserSingleLine).

@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'e4cc6333f7212ea97e3b');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing file doc comment (Squiz.Commenting.FileComment.Missing).

assets/build/blocks/rt-player/index.asset.php Show resolved Hide resolved
assets/build/blocks/rt-player/index.asset.php Show resolved Hide resolved
assets/build/blocks/rt-player/index.asset.php Show resolved Hide resolved
inc/classes/class-assets.php Show resolved Hide resolved
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

inc/classes/class-blocks.php Show resolved Hide resolved
@pranvinit pranvinit closed this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants