1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Don't download videos longer than 3 hours

This commit is contained in:
Steffo 2019-06-04 18:49:33 +02:00
parent 55c6d61062
commit 9c452be47d
2 changed files with 9 additions and 0 deletions

View file

@ -3,7 +3,9 @@ import ffmpeg
import os import os
import typing import typing
import time import time
import datetime
from .youtubedl import YtdlFile, YtdlInfo from .youtubedl import YtdlFile, YtdlInfo
from ..error import FileTooBigError
from ..utils import fileformat from ..utils import fileformat
@ -18,6 +20,9 @@ class RoyalPCMFile(YtdlFile):
def __init__(self, info: "YtdlInfo", **ytdl_args): def __init__(self, info: "YtdlInfo", **ytdl_args):
# Preemptively initialize info to be able to generate the filename # Preemptively initialize info to be able to generate the filename
self.info = info self.info = info
# If the video is longer than 3 hours, don't download it
if self.info.duration >= datetime.timedelta(hours=3):
raise FileTooBigError("File is over 3 hours long")
# Set the time to generate the filename # Set the time to generate the filename
self._time = time.time() self._time = time.time()
# Ensure the file doesn't already exist # Ensure the file doesn't already exist

View file

@ -41,3 +41,7 @@ class RoyalnetResponseError(Exception):
class ExternalError(Exception): class ExternalError(Exception):
"""Something went wrong in a non-Royalnet component and the command execution cannot be completed.""" """Something went wrong in a non-Royalnet component and the command execution cannot be completed."""
class FileTooBigError(Exception):
"""The file to be downloaded would be too big to store; therefore, it has been skipped."""