Skip to content

Commit

Permalink
look at lenght of the videos to compare them
Browse files Browse the repository at this point in the history
this is the temporary workaround I found, I wish i could find a better option but this will do for now.

Videos will be stored instead of lenghts so if I find a better way to compare, I can do that instead
  • Loading branch information
kytpbs committed Aug 27, 2024
1 parent 876e960 commit bb19a67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Tests/video_system/download_tester.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import os
import requests
import static_ffmpeg
import subprocess
from src.downloader import VIDEO_RETURN_TYPE, VideoFile

static_ffmpeg.add_paths(weak=True) # add the ffmpeg if not already added

def _get_video_duration(video_path: str) -> float:
result = subprocess.run(["ffprobe", "-v", "error", "-show_entries",
"format=duration", "-of",
"default=noprint_wrappers=1:nokey=1", video_path],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=False)
return float(result.stdout)


class DownloadTester:
def download_single_video_test(self, videos: VIDEO_RETURN_TYPE, should_be_path: str):
Expand All @@ -18,8 +29,6 @@ def download_multiple_video_test(self, videos: VIDEO_RETURN_TYPE, should_be_path


def _test_download(self, video: VideoFile, should_be_path: str):
with open(video.path, "rb") as downloaded, open(
should_be_path, "rb" # change to "wb" to run fix tests
) as should_be:
# should_be.write(downloaded.read()) # uncomment to fix tests
assert downloaded.read() == should_be.read(), "Downloaded file does not match the expected file"
video_duration = _get_video_duration(video.path)
should_be_duration = _get_video_duration(should_be_path)
assert video_duration == should_be_duration, f"video_duration was '{video_duration}' should have been: '{should_be_duration}'"
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description = run the tests with pytest
deps =
pytest>=8
pytest-asyncio
static-ffmpeg
-r requirements.txt
passenv = *
commands =
Expand Down

0 comments on commit bb19a67

Please sign in to comment.