Skip to main content

HTML Code for video downloader app

Copy this html code for video downloader app. You can use it in your project.


<html lang="en">
 <head>
  <meta charset="utf-8"></meta>
  <meta content="width=device-width, initial-scale=1.0" name="viewport"></meta>
  <title>
    Video Player and Downloader App. Some video can not download.
  </title>
  <script src="https://cdn.tailwindcss.com">
  </script>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"></link>
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&amp;display=swap" rel="stylesheet"></link>
 </head>
 <body class="bg-gray-100 font-roboto">
  <div class="container mx-auto p-4">
   <div class="max-w-lg mx-auto bg-white shadow-md rounded-lg p-6">
    <h1 class="text-2xl font-bold mb-4 text-center">
     Video Player and Downloader
    </h1>
    <div class="mb-4">
     <label class="block text-gray-700 font-bold mb-2" for="video-url">
      Paste YouTube Video URL 
     </label>
     <input class="w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" id="video-url" placeholder="Enter video URL here" type="text" />
    </div>
    <div class="mb-4 hidden" id="video-container">
     <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" class="w-full rounded-lg" frameborder="0" height="315" id="video-player" src="">
     </iframe>
    </div>
    <button class="w-full bg-green-500 text-white font-bold py-2 px-4 rounded-lg hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-500" id="download-btn">
     <i class="fas fa-download mr-2">
     </i>
     Download Video
    </button>
   </div>
  </div>
  <script>
   document.getElementById('video-url').addEventListener('input', function() {
            const url = this.value;
            const videoId = getVideoId(url);
            if (videoId) {
                const embedUrl = getEmbedUrl(url, videoId);
                if (embedUrl) {
                    document.getElementById('video-player').src = embedUrl;
                    document.getElementById('video-container').classList.remove('hidden');
                } else {
                    document.getElementById('video-container').classList.add('hidden');
                }
            } else {
                document.getElementById('video-container').classList.add('hidden');
            }
        });

        document.getElementById('download-btn').addEventListener('click', function() {
            const url = document.getElementById('video-url').value;
            const videoId = getVideoId(url);
            if (videoId) {
                const downloadUrl = getDownloadUrl(url, videoId);
                if (downloadUrl) {
                    window.open(downloadUrl, '_blank');
                } else {
                    alert('Download not supported for this video.');
                }
            } else {
                alert('Please enter a valid video URL.');
            }
        });

        function getVideoId(url) {
            const youtubeRegex = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
            const facebookRegex = /(?:https?:\/\/)?(?:www\.)?facebook\.com\/.*\/videos\/([0-9]+)/;
            const instagramRegex = /(?:https?:\/\/)?(?:www\.)?instagram\.com\/(?:p|reel)\/([a-zA-Z0-9_-]+)/;
            const tiktokRegex = /(?:https?:\/\/)?(?:www\.)?tiktok\.com\/.*\/video\/([0-9]+)/;

            const youtubeMatch = url.match(youtubeRegex);
            if (youtubeMatch) return { platform: 'youtube', id: youtubeMatch[1] };

            const facebookMatch = url.match(facebookRegex);
            if (facebookMatch) return { platform: 'facebook', id: facebookMatch[1] };

            const instagramMatch = url.match(instagramRegex);
            if (instagramMatch) return { platform: 'instagram', id: instagramMatch[1] };

            const tiktokMatch = url.match(tiktokRegex);
            if (tiktokMatch) return { platform: 'tiktok', id: tiktokMatch[1] };

            return null;
        }

        function getEmbedUrl(url, videoId) {
            switch (videoId.platform) {
                case 'youtube':
                    return `https://www.youtube.com/embed/${videoId.id}`;
                case 'facebook':
                    return `https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(url)}`;
                case 'instagram':
                    return `https://www.instagram.com/p/${videoId.id}/embed`;
                case 'tiktok':
                    return `https://www.tiktok.com/embed/v2/${videoId.id}`;
                default:
                    return null;
            }
        }

        function getDownloadUrl(url, videoId) {
            switch (videoId.platform) {
                case 'youtube':
                    return `https://www.ssyoutube.com/watch?v=${videoId.id}`;
                case 'facebook':
                    return `https://www.getfvid.com/downloader?url=${encodeURIComponent(url)}`;
                case 'instagram':
                    return `https://www.downloadgram.com/?url=${encodeURIComponent(url)}`;
                case 'tiktok':
                    return `https://www.ttdownloader.com/?url=${encodeURIComponent(url)}`;
                default:
                    return null;
            }
        }
  </script>
 </body>
</html>

Comments

Popular posts from this blog

Submit Your Website on all Search Engines to get Traffic on your website

  Submit Your Website on all Search Engines to get Traffic on your website In this article, I'm going to give you 63 Big Search engines to submit your website. after submit your website on these Search engines your website can Instantly start to get lots of traffic. you will have to submit your website on all search engines. if you will not submit your website on search engines then your website will not show in Search results.  yandex search engines like when someone will try to search your website on Google then your website will not show in search result. you will have to submit your website on Google Console. similarly I have collected all search Engines to submit your website and get free lots of traffic. read this full articles. 63+ Search Engines that I have collected to submit your website and get over 500K free traffic instantly Today..   Check out all these search engines -  1 -  ASR (Active Search Results ) 2 -  Google 3-  Amidalla 4 - ...

Earn Money From Google AdMob ( Make Money Online 2024 ) | PASSIVE INCOME 2024

Earn Passive Money From Google AdMob ( Make Money Online ) |  https://cpamarketingbeginners.blogspot.com/ Admob Earnings Earn Instantly Hundreds of dollars without doing hard work with Google AdMob. Google Ad Mob is a Google's Product. AdMob is A Just like AdSense. You can Earn Money From Your Website and YouTube Channel Using AdSense. But if you want to earn money from Your app and Game then you can Use AdMob.  Google Run Ads on Website, YouTube Channel, App and Game Application. when Someone Clicks on that ads then You can Earn money. You can Earn $1 - $5 only on one Click.  Earning depends on Traffic quality and Category. If you have made your website, YouTube Channel or App on Business category and If you are getting traffic from United states, United kingdom, Canada, Germany.... then you can earn high amount of money. In this article, I am going to share with you how you can earn money from admob. read this full article. Guys, First of all you will have to make game ...

Make $100 Online TODAY (EASY Method) [2024] | EARN MONEY

Would You like to earn $100 Per day? You should read this full articles. Because I am going to share with you best and trusted platform to earn your first and fast $100 today. Make $100 Online TODAY (EASY Method) [2024] | EARN MONEY You can see payments proof, All these people are cashing out their money every single day. You can earn up to $100 daily with this platform. This platform's name is shrtfly.com  . This is amazing platform. This platform is available worldwide so no matter what country you are in. You can use this platform to make money online. shrtfly platform have 1 Million Publishers. This platform show clean ads only. You can not get virus , Malware and adult type ads. It's a AdSense Compatible Platform.  How to earn $100 per day with shrtfly platform. You can Visit on these platform like mxplayer.in , YouTube.com, bilibili, Facebook or any social media platform and then copy URL Of that movies and reel. You can also copy website url. watch full tutorial ab...