Commit 
							
							·
						
						97fddf5
	
1
								Parent(s):
							
							9e23844
								
fix imagemagick installation in dockerfile. moved youtube utils to other project.
Browse files- Dockerfile +2 -6
- requirements.txt +0 -0
- utils/download_audio.py +0 -17
- utils/download_video.py +0 -16
    	
        Dockerfile
    CHANGED
    
    | @@ -7,12 +7,8 @@ WORKDIR /app | |
| 7 | 
             
            # Copy the current directory contents into the container at /app
         | 
| 8 | 
             
            COPY . /app
         | 
| 9 |  | 
| 10 | 
            -
            # | 
| 11 | 
            -
            RUN apt-get update &&  | 
| 12 | 
            -
                apt-get install -y imagemagick && \
         | 
| 13 | 
            -
                apt-get clean && \
         | 
| 14 | 
            -
                rm -rf /var/lib/apt/lists/*
         | 
| 15 | 
            -
             | 
| 16 | 
             
            # Install any needed packages specified in requirements.txt
         | 
| 17 | 
             
            RUN pip install --no-cache-dir -r requirements.txt
         | 
| 18 |  | 
|  | |
| 7 | 
             
            # Copy the current directory contents into the container at /app
         | 
| 8 | 
             
            COPY . /app
         | 
| 9 |  | 
| 10 | 
            +
            #Install ImageMagick
         | 
| 11 | 
            +
            RUN apt-get update && apt-get install -y imagemagick && sed -i '91d' /etc/ImageMagick-6/policy.xml
         | 
|  | |
|  | |
|  | |
|  | |
| 12 | 
             
            # Install any needed packages specified in requirements.txt
         | 
| 13 | 
             
            RUN pip install --no-cache-dir -r requirements.txt
         | 
| 14 |  | 
    	
        requirements.txt
    CHANGED
    
    | Binary files a/requirements.txt and b/requirements.txt differ | 
|  | 
    	
        utils/download_audio.py
    DELETED
    
    | @@ -1,17 +0,0 @@ | |
| 1 | 
            -
            from pytube import YouTube
         | 
| 2 | 
            -
            import logging
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            def download_audio(video_url, output_path, filename):
         | 
| 5 | 
            -
                try:
         | 
| 6 | 
            -
                    # Creating YouTube object
         | 
| 7 | 
            -
                    yt = YouTube(video_url)
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                    # Selecting the audio stream with the highest quality
         | 
| 10 | 
            -
                    audio_stream = yt.streams.filter(only_audio=True).first()
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                    # Downloading the audio file
         | 
| 13 | 
            -
                    audio_stream.download(output_path=output_path,filename=filename)
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                    logging.info(f"Audio downloaded successfully at {output_path}/{audio_stream.default_filename}")
         | 
| 16 | 
            -
                except Exception as e:
         | 
| 17 | 
            -
                    logging.info(f"An error occurred: {e}")
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
    	
        utils/download_video.py
    DELETED
    
    | @@ -1,16 +0,0 @@ | |
| 1 | 
            -
            from pytube import YouTube
         | 
| 2 | 
            -
            import os
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            def download_video(input_file, output_path, filename):
         | 
| 5 | 
            -
                full_filename = f"{filename}.mp4"
         | 
| 6 | 
            -
                try:
         | 
| 7 | 
            -
                    yt = YouTube(input_file)
         | 
| 8 | 
            -
                    video_stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
         | 
| 9 | 
            -
                    if video_stream:
         | 
| 10 | 
            -
                        video_stream.download(output_path=output_path,filename=full_filename)
         | 
| 11 | 
            -
                        video_title = os.path.join(output_path, full_filename)
         | 
| 12 | 
            -
                        return video_title
         | 
| 13 | 
            -
                    else:
         | 
| 14 | 
            -
                        return "No suitable stream found for this video."
         | 
| 15 | 
            -
                except Exception as e:
         | 
| 16 | 
            -
                    return f"An error occurred: {str(e)}"
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  |