Ver código fonte

Fix incomplete URL substring sanitation (#7056)

Resolves code scanning alert in https://github.com/ultralytics/yolov5/issues/7055
modifyDataloader
Glenn Jocher GitHub 2 anos atrás
pai
commit
9f4d11379b
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: 4AEE18F83AFDEB23
1 arquivos alterados com 2 adições e 1 exclusões
  1. +2
    -1
      utils/datasets.py

+ 2
- 1
utils/datasets.py Ver arquivo

@@ -15,6 +15,7 @@ from itertools import repeat
from multiprocessing.pool import Pool, ThreadPool
from pathlib import Path
from threading import Thread
from urllib.parse import urlparse
from zipfile import ZipFile

import cv2
@@ -301,7 +302,7 @@ class LoadStreams:
for i, s in enumerate(sources): # index, source
# Start thread to read frames from video stream
st = f'{i + 1}/{n}: {s}... '
if 'youtube.com/' in s or 'youtu.be/' in s: # if source is YouTube video
if urlparse(s).hostname in ('youtube.com', 'youtu.be'): # if source is YouTube video
check_requirements(('pafy', 'youtube_dl==2020.12.2'))
import pafy
s = pafy.new(s).getbest(preftype="mp4").url # YouTube URL

Carregando…
Cancelar
Salvar