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

format filter filesize not working #8941

Closed
jodersus opened this issue Mar 22, 2016 · 5 comments
Closed

format filter filesize not working #8941

jodersus opened this issue Mar 22, 2016 · 5 comments

Comments

@jodersus
Copy link

@jodersus jodersus commented Mar 22, 2016

Hi,
I am trying to use youtube-dl embedded in a simply python app that limits video download size.
I am using ydl_opts = {'format' : 'best[filesize<16M]'} literally copied from the README Format Selection Examples ([https://github.com/rg3/youtube-dl/blob/master/README.md#format-selection-examples]) but I get ERROR requested format not available:

>>> ydl_opts = {'format':'best[filesize<=16M]'}
>>> u = "https://www.google.es/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjvorrGg9XLAhXD1xQKHYwIDn0QtwIIHTAA&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Da1Y73sPHKxw&usg=AFQjCNEnG8QQmxXN9_8R1c3u-KhK5SrC3A&sig2=2UYmwCW9yFd-Wlh3rh_ZHA"
>>> ydl = YoutubeDL(ydl_opts)
>>> ydl.add_default_info_extractors()
>>> info = ydl.extract_info(u, download = False)
[generic] url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjvorrGg9XLAhXD1xQKHYwIDn0QtwIIHTAA&url=https://www.youtube: Requesting header
WARNING: Falling back on generic information extractor.
[generic] url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjvorrGg9XLAhXD1xQKHYwIDn0QtwIIHTAA&url=https://www.youtube: Downloading webpage
[generic] url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjvorrGg9XLAhXD1xQKHYwIDn0QtwIIHTAA&url=https://www.youtube: Extracting information
[redirect] Following redirect to https://www.youtube.com/watch?v=a1Y73sPHKxw
[youtube] a1Y73sPHKxw: Downloading webpage
[youtube] a1Y73sPHKxw: Downloading video info webpage
[youtube] a1Y73sPHKxw: Extracting video information
[youtube] a1Y73sPHKxw: Downloading MPD manifest
ERROR: requested format not available
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 679, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 731, in process_ie_result
    extra_info=extra_info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 683, in extract_info
    self.report_error(compat_str(e), e.format_traceback())
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 543, in report_error
    self.trouble(error_message, tb)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 513, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: requested format not available

Any help will be greatly appreciated

Best,
Alex

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Mar 22, 2016

filesize metadata is not present for videoaudio formats thus your condition fails. You can add ? to it to allow it to pass when no filesize is present: filesize<?16M.

@dstftw dstftw closed this Mar 22, 2016
@jodersus
Copy link
Author

@jodersus jodersus commented Mar 22, 2016

Thanks. Can I not filter for video-only and audio-only formats separately, at least?

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Mar 22, 2016

Use grouping with parentheses.

@jodersus
Copy link
Author

@jodersus jodersus commented Mar 22, 2016

Ok, I'll look into that. Thanks!

@usamamashkoor
Copy link

@usamamashkoor usamamashkoor commented Oct 17, 2017

@jodersus did you find any solution i am facing the same issue here..?

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
3 participants
You can’t perform that action at this time.