function fetchItemVideo(url, downloadFilename) {
    fetch(url).then(res => res.blob()).then(blob => {
        document.getElementsByClassName('layui-layer')[0].remove();
        const a = document.createElement('a');
        document.body.appendChild(a);
        a.style.display = 'none';
        const url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = downloadFilename;
        a.click();
        document.body.removeChild(a);
        window.URL.revokeObjectURL(url)
    })
}
// window.lib.mtop.request({
//     api: "mtop.taobao.cloudvideo.video.queryForH5",
//     v: "1.0",
//     timeout: 1000,
//     data: {
//         videoId: document.getElementById('videoIdInfo').getAttribute('videoId'),
//         from: 'detail'
//     }
// }).then(function(t) {
//     if (t.data.hasOwnProperty('mp4Resources') && t.data.mp4Resources.length) {
//         fetchItemVideo(t.data.mp4Resources[0].video_url, document.getElementById('videoIdInfo').getAttribute('downloadFilename'))
//     }
// });
window.lib.mtop.request({
    api: "mtop.taobao.cloudvideo.video.query",
    v: "3.0",
    timeout: 1000,
    data: {
        videoId: document.getElementById('videoIdInfo').getAttribute('videoId'),
        playScenes: 'shopcenter',
        from: 'detail_pc'
    }
}).then(function(t) {
    if (t.data.hasOwnProperty('resources') && t.data.resources.length) {
        fetchItemVideo(t.data.resources[0].video_url, document.getElementById('videoIdInfo').getAttribute('downloadFilename'))
    }
});