Skip to content

Commit

Permalink
migrate from youtube-dl to yt-dlp
Browse files Browse the repository at this point in the history
youtube-dl seems to be abandoned as of June 2021-ish. yt-dlp is the new maintained fork. fixes snarfed#48
  • Loading branch information
snarfed committed Oct 24, 2021
1 parent 346d34c commit 05081a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
#
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import requests
import webob
import webob.exc
import youtube_dl
import yt_dlp

HTML_HEADER = """\
<!DOCTYPE html>
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -176,7 +176,7 @@ def download_progress_hook(progress):
# download video and extract mp3
yield 'Downloading (this can take a while)...<br />\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...<br />\n'.encode()
Expand Down Expand Up @@ -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('<p>%s</p>\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 <a href="http://rg3.github.io/youtube-dl/supportedsites.html">
Here are the <a href="https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md">
supported sites</a>. If this site isn't supported, it may also post
its videos on YouTube. Try there!
""")
Expand Down

0 comments on commit 05081a4

Please sign in to comment.