Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.3 kB
3
Indexable
const isaac = PASSKEY
function getIdFromUrl(url) {
    return url.match(/[-\w]{18,}/);
}
const params = new URLSearchParams(window.location.search);
if (params.has('video')) {
    try {
      playvideo()
    }
    catch (e) {
      $('#videoplayer').html(`<div class='alert alert-danger' role='alert'> Resourse File Not Found </div></div></div>`);
      console.log(e)
    }
} else if (params.has('url')) {
    try {
      convert2video()
    }
    catch (e) {
      $('#videoplayer').html(`<div class='alert alert-danger' role='alert'> Resourse File Not Found </div></div></div>`);
      console.log(e)
    }
}

async function convert2video() {
    $('#videoplayer').html(`<div class="loading" id="spinner">Loading&#8230;</div>`);
    var url_video = params.get('url');
    var videourl = await encodeURIComponent(CryptoJS.AES.encrypt(url_video.toString(), isaac))
    window.location.href = "?video="+videourl;
}

async function playvideo() {
        $('#videoplayer').html(`<div class="loading" id="spinner">Loading&#8230;</div>`);
        var enc_videoid = decodeURIComponent(params.get('video'));
        var video_url = await CryptoJS.AES.decrypt(enc_videoid, isaac).toString(CryptoJS.enc.Utf8);
        $('#videoplayer').html(`<video id="vplayer" width="100%" height="100%" playsinline controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']; data-plyr-config="{ "title": "Video"}" data-poster="https://cdn.jsdelivr.net/npm/@googledrive/index@2.2.3/images/poster.jpg" style="--plyr-captions-text-color: #ffffff;--plyr-captions-background: #000000;"><source src="${video_url}" type="video/mp4" /><source src="${video_url}" type="video/webm" /></video>`);
        const player = new Plyr('#vplayer',{ratio: "16:9"});
        document.getElementById("videourl").style.display = 'none';
        document.getElementById("playvideo").style.display = 'none';
        document.getElementById("dlgate").style.display = 'block';
        document.getElementById("spinner").style.display = 'none';
}

document.querySelector("#playvideo").addEventListener("click", async function(event) {
    event.preventDefault();
    try {
            var link = document.getElementById("videourl").value;
            if (link.startsWith('https://')) {
                $('#videoplayer').html(`<div class='alert alert-danger' role='alert'> Loading... </div></div></div>`);
                var videourl = encodeURIComponent(CryptoJS.AES.encrypt(link.toString(), isaac))
                window.location.href = "?video="+videourl;
            } else {
                $('#videoplayer').html(`<div class='alert alert-danger' role='alert'> Invalid Video Link </div></div></div>`);
            }

    } catch (e) {
            console.log(e)
    } finally {
    }
});

document.querySelector("#download").addEventListener("click", async function(event) {
    event.preventDefault();
    var enc_videoid = decodeURIComponent(params.get('video'));
    var video_url = await CryptoJS.AES.decrypt(enc_videoid, isaac).toString(CryptoJS.enc.Utf8);
    window.location.href = video_url;
});
document.getElementById("spinner").style.display = 'none';