Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return code is 0 when max-filesize/min-filesize is not met #6138

Open
drount opened this issue Jul 1, 2015 · 0 comments
Open

Return code is 0 when max-filesize/min-filesize is not met #6138

drount opened this issue Jul 1, 2015 · 0 comments
Labels

Comments

@drount
Copy link

@drount drount commented Jul 1, 2015

I'm integrating youtube_dl in a python script with the following configuration:

ydl_opts = {
    "outtmpl": u"%s/%%(id)s.%%(ext)s",
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }],
    "prefer_ffmpeg": True,
    "format": "bestaudio",
    "max_filesize": 1000000
}

and the download code:

 def _download(self, video_id):
     try:
         with youtube_dl.YoutubeDL(ydl_opts) as ydl:
             return 0 == ydl.download([http://www.youtube.com/watch?v=%s' % video_id])
     except:
         return False

However, if the downloaded failed because the file size exceeds, the call returns 0 (there has been no problem) so there is no way of knowing that actually the download failed.

I propose that the downloaders throw an exception when they cannot met a parameter:

in youtube_dl/downloader/http.py:

@@ -130,6 +130,7 @@ class HttpFD(FileDownloader):
                 return False
             if max_data_len is not None and data_len > max_data_len:
                 self.to_screen('\r[download] File is larger than max-filesize (%s bytes > %s bytes). Aborting.' % (data_len, max_data_len))
+                raise ExampleException("File is greater than filesize")

or update YoutubeDL class to process False as a result of a call to download and set a corresponding retvalue to a value different than 0 to notify the main process that the download actually failed.

Thank you.

@jaimeMF jaimeMF added the request label Jul 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.