diff --git a/Dockerfile b/Dockerfile index 4edecec..00a46d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR $APP_HOME COPY . ./ # Install production dependencies. -RUN pip install b2sdk gunicorn requests webob youtube-dl +RUN pip install b2sdk gunicorn requests webob yt-dlp RUN apt-get update -y && apt-get install -y ffmpeg && apt-get clean # Run the web service on container startup. Here we use the gunicorn diff --git a/README.md b/README.md index d36142b..b6dd8a9 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ # huffduff-video -Extracts the audio from videos on YouTube, Vimeo, and [many more sites](http://rg3.github.io/youtube-dl/supportedsites.html) and sends it to [Huffduffer](http://huffduffer.com/). +Extracts the audio from videos on YouTube, Vimeo, and [many more sites](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md) and sends it to [Huffduffer](http://huffduffer.com/). See [huffduff-video.snarfed.org](http://huffduff-video.snarfed.org/) for bookmarklet and usage details. -Uses [youtube-dl](http://rg3.github.io/youtube-dl/) to download the video and extract its audio track. Stores the resulting MP3 file in [Backblaze B2](https://www.backblaze.com/b2/). +Uses [yt-dlp](https://github.com/yt-dlp/yt-dlp) to download the video and extract its audio track. Stores the resulting MP3 file in [Backblaze B2](https://www.backblaze.com/b2/). License: this project is placed in the public domain. Alternatively, you may use it under the [CC0 license](http://creativecommons.org/publicdomain/zero/1.0/). ## Related projects -* [Podify](https://www.podify.org/) is a self-hosted app that also serves feeds of the generated MP3 files. Also backed by youtube-dl. +* [Podify](https://www.podify.org/) is a self-hosted app that also serves feeds of the generated MP3 files. Backed by youtube-dl. * [youtube-dl-api-server](https://github.com/jaimeMF/youtube-dl-api-server) is a web front-end that uses youtube-dl to extract and return a video's metadata. * [Flask webapp and Chrome extension](https://charlesleifer.com/blog/a-flask-front-end-and-chrome-extension-for-youtube-dl/) for using youtube-dl to download a video to local disk. * [iOS workflow](http://www.512pixels.net/blog/2014/12/from-youtube-to-huffduffer-with-workflow) that does the same thing as huffduff-video, except all client side: downloads a YouTube video, converts it to MP3, uploads the MP3 to Dropbox, and passes it to Huffduffer. @@ -86,7 +86,7 @@ sudo chsh ubuntu # install and set up huffduff-video cd ~/src git clone https://github.com/snarfed/huffduff-video.git -sudo pip3 install b2sdk boto webob youtube-dl +sudo pip3 install b2sdk webob yt-dlp # add these lines to /etc/httpd/conf/httpd.conf # @@ -127,8 +127,8 @@ cd cat > ~/crontab << EOF # clean up /tmp every hour 0 * * * * find /tmp/ -user www-data -not -newermt yesterday | xargs rm -# auto upgrade youtube-dl daily -10 10 * * * sudo pip3 install -U youtube-dl; sudo service apache2 restart +# auto upgrade yt-dlp daily +10 10 * * * sudo pip3 install -U yt-dlp; sudo service apache2 restart # recopy robots.txt to S3 since our bucket expiration policy deletes it monthly 1 2 3 * * aws s3 cp --acl=public-read ~/src/huffduff-video/s3_robots.txt s3://huffduff-video/robots.txt EOF diff --git a/app.py b/app.py index 6bfab7c..3229783 100644 --- a/app.py +++ b/app.py @@ -21,7 +21,7 @@ import requests import webob import webob.exc -import youtube_dl +import yt_dlp HTML_HEADER = """\ @@ -139,7 +139,7 @@ def download_progress_hook(progress): }], 'progress_hooks': [download_progress_hook], } - ydl = youtube_dl.YoutubeDL(options) + ydl = yt_dlp.YoutubeDL(options) with handle_errors(write): info = ydl.extract_info(url, download=False) @@ -176,7 +176,7 @@ def download_progress_hook(progress): # download video and extract mp3 yield 'Downloading (this can take a while)...
\n'.encode() with handle_errors(write): - youtube_dl.YoutubeDL(options).download([url]) + yt_dlp.YoutubeDL(options).download([url]) # upload to B2 yield 'Uploading to B2...
\n'.encode() @@ -237,14 +237,14 @@ def close(self): @contextlib.contextmanager def handle_errors(write): - """Wraps youtube_dl calls in a try/except and handles errors.""" + """Wraps yt_dlp calls in a try/except and handles errors.""" try: yield except Exception as e: write('

%s

\n' % e) - if isinstance(e, (youtube_dl.DownloadError, youtube_dl.utils.ExtractorError)): + if isinstance(e, (yt_dlp.DownloadError, yt_dlp.utils.ExtractorError)): write("""\ -Here are the +Here are the supported sites. If this site isn't supported, it may also post its videos on YouTube. Try there! """)