Downloading youtube videos with the help of jenkins
In this blog, we will outline the process of downloading YouTube videos using Jenkins, an automation server, and GitHub, a code hosting platform, through integration. Jenkins will automate the process of downloading YouTube videos based on triggers set up in a GitHub repository.
Prerequisites:
Access to a Jenkins server.
Access to a GitHub repository.
Basic knowledge of Jenkins pipelines and GitHub repositories.
Step 1: Write python code for downloading youtube videos in github repository
from pytube import YouTube
def download_video(video_url, output_path): try: yt = YouTube(video_url) stream = yt.streams.get_highest_resolution() # Get the highest resolution stream if stream: print("Downloading video:", yt.title)
stream.download
(output_path) print("Video downloaded successfully to:", output_path) else: print("Error: No stream available for the given video URL.") except Exception as e: print("Error occurred:", str(e))
if name == "main": # Example usage: video_url = "
https://www.youtube.com/watch?v=VIDEO_ID
" output_path = "/path/to/save/video" download_video(video_url, output_path)
Step 3: Install git with the help of yum install git.
Step 4:Create job in jenkins select freestyle.
Step 5: Click on git and add your repository address from github.
Step 6: Write cammands for execution and save.
sudo yum install python-pip -y
sudo yum install python3-pip -y
pip --version
pip install pytube
python3 (your file name)
Step 7: Build Now .
Congratulations your automation for Downloading youtube videos with the help of jenkins is done.