Query media files based on their OSS URLs

Updated at:

Call the QueryMediaListByURL operation to look up media files by their Object Storage Service (OSS) URLs. This is useful when you have an OSS URL and need to retrieve the corresponding media ID or associated metadata such as playback information, snapshots, or summaries.

The following example uses ApsaraVideo Media Processing (MPS) SDK for Java to call QueryMediaListByURL. The request includes optional parameters to control which details are returned in the response.

package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>Use your AccessKey ID and AccessKey secret to initialize the client.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is configured. 
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is configured. 
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-qingdao.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.mts20140618.Client client = Sample.createClient();
        com.aliyun.mts20140618.models.QueryMediaListByURLRequest queryMediaListByURLRequest = new com.aliyun.mts20140618.models.QueryMediaListByURLRequest()
                // The URL of the media file to be queried.
                .setFileURLs("http://example-bucket-****.oss-cn-shanghai.aliyuncs.com/example.mp4")
                // Specify whether to include playback information in the response.
                .setIncludePlayList(true)
                // Specify whether to include snapshot information in the response.
                .setIncludeSnapshotList(true)
                // Specify whether to include media information in the response.
                .setIncludeMediaInfo(true)
                // Specify whether to include summaries in the response.
                .setIncludeSummaryList(true);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.queryMediaListByURLWithOptions(queryMediaListByURLRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and never ignore exceptions in your project. In this example, error messages are displayed for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL of the corresponding error diagnostics page.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and never ignore exceptions in your project. In this example, error messages are displayed for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL of the corresponding error diagnostics page.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Request parameters

Parameter

Type

Description

FileURLs

String

The OSS URL of the media file to query. Replace the example URL with your actual file URL.

IncludePlayList

Boolean

Set to true to include playback information in the response.

IncludeSnapshotList

Boolean

Set to true to include snapshot information in the response.

IncludeMediaInfo

Boolean

Set to true to include media information in the response.

IncludeSummaryList

Boolean

Set to true to include summaries in the response.