Skip to content

Commit

Permalink
YouTube Usage example comments (#10106)
Browse files Browse the repository at this point in the history
* YouTube Usage example comments

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update dataloaders.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
glenn-jocher committed Nov 9, 2022
1 parent 892c4cd commit c1fcfe8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True, tr
# Start thread to read frames from video stream
st = f'{i + 1}/{n}: {s}... '
if urlparse(s).hostname in ('www.youtube.com', 'youtube.com', 'youtu.be'): # if source is YouTube video
# YouTube format i.e. 'https://www.youtube.com/watch?v=Zgi9g1ksQHc' or 'https://youtu.be/Zgi9g1ksQHc'
check_requirements(('pafy', 'youtube_dl==2020.12.2'))
import pafy
s = pafy.new(s).getbest(preftype="mp4").url # YouTube URL
Expand Down

0 comments on commit c1fcfe8

Please sign in to comment.