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

max-filesize or similar doesn't work for twitter or facebook with python #26861

Closed
mateusfmcota opened this issue Oct 10, 2020 · 1 comment
Closed
Labels

Comments

@mateusfmcota
Copy link

@mateusfmcota mateusfmcota commented Oct 10, 2020

Checklist

  • [ x] I'm asking a question
  • [ x] I've looked through the README and FAQ for similar questions
  • [ x] I've searched the bugtracker for similar questions including closed ones

Question

I'm trying to limit the filesize download throught a python script but it doesn't work on sites like twitter or facebook but works on youtube

ydl_opts = {
            'download_archive': './video',
            'restrictfilenames': True,
            'format': 'best[filesize<50M]',
            'outtmpl': os.getcwd()+'/a/%(title)s-%(id)s.%(ext)s',
            'prefer_ffmpeg': True,
            'postprocessor_args': ['-preset', 'ultrafast'],
            'postprocessors': [{
                'key': 'FFmpegVideoConvertor',
                'preferedformat': 'mp4'
            }],
            'verbose': True
            # 'extension' : 'mp4'
        }

Here's a few combinations of formats I tried also but they didn't worked:

            'format': [{
                'max_filesize': '50MiB'
            }],
            'format': '[filesize<=50M]',
            'format': [{'max-filesize' : '50MiB'}],

Here's the output when I download something from twitter:

[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 3.8.6 (CPython) - Linux-5.8.13-arch1-1-x86_64-with-glibc2.2.5
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[twitter] 1314998435385421824: Downloading guest token
[twitter] 1314998435385421824: Downloading JSON metadata
[twitter] 1314998435385421824: Downloading m3u8 information
ERROR: requested format not available
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 863, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 1635, in process_video_result
    raise ExtractorError('requested format not available',
youtube_dl.utils.ExtractorError: requested format not available

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 863, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 1635, in process_video_result
    raise ExtractorError('requested format not available',
youtube_dl.utils.ExtractorError: requested format not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in down
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 820, in extract_info
    self.report_error(compat_str(e), e.format_traceback())
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 625, in report_error
    self.trouble(error_message, tb)
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 595, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: requested format not available

How can I control the max file size to be downloaded and to make it work on every site.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Oct 17, 2020

You can't. Not all site provides filesize metadata.

@dstftw dstftw closed this Oct 17, 2020
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.