Making WordPress.org


Ignore:
Timestamp:
09/02/2022 05:03:46 AM (3 years ago)
Author:
dd32
Message:

WordPress.TV: Don't link to the mp4 formats which have no audio, expose the original uploaded file, and add these to the WordPress.tv/api/videos.json API.

Fixes #6000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/sidebar-single.php

    r8230 r12043  
    2626                    $videos = array_keys( find_all_videopress_shortcodes( $originalcontent ) );
    2727                    if ( ! empty( $videos ) ) {
    28                         $video = video_get_info_by_guid( $videos[0] );
    29                         $formats = array( 'fmt_std' => 'Low', 'fmt_dvd' => 'Med', 'fmt_hd' => 'High', 'fmt1_ogg' => 'Low' );
     28                        $video     = video_get_info_by_guid( $videos[0] );
     29                        $api_data  = video_get_single_response( $video );
     30                        $formats   = array( 'fmt_std' => 'Low', 'fmt_dvd' => 'Med', 'fmt_hd' => 'High', 'fmt1_ogg' => 'Low' );
    3031                        $mp4_links = array();
    31                         $ogg_link = NULL;
     32                        $ogg_link  = false;
     33
    3234                        foreach ( $formats as $format => $name ) {
    3335                            if ( 'fmt1_ogg' == $format ) {
    3436                                $link = video_highest_resolution_ogg( $video );
    3537                            } else {
     38
     39                                // Check if HLS transcoded, no audio, no need to link to it.
     40                                if ( ! empty( $api_data['files'][ str_replace( 'fmt_', '', $format ) ]['hls'] ) ) {
     41                                    continue;
     42                                }
     43
    3644                                $link = video_url_by_format( $video, $format );
    3745                            }
     
    4654                                $mp4_links[] = "<a href='$link'>$name</a>";
    4755                            }
     56                        }
     57
     58                        if ( ! empty( $api_data['original'] ) ) {
     59                            $mp4_links[] = "<a href='{$api_data['original']}'>Original</a>";
    4860                        }
    4961
Note: See TracChangeset for help on using the changeset viewer.