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

Determining file size without downloading #4376

Closed
rikato06 opened this issue Dec 4, 2014 · 7 comments
Closed

Determining file size without downloading #4376

rikato06 opened this issue Dec 4, 2014 · 7 comments

Comments

@rikato06
Copy link

@rikato06 rikato06 commented Dec 4, 2014

How do I know the total size of the video without downloading?

Thank you.

@phihag phihag changed the title Hello Determining file size without downlodaing Dec 4, 2014
@phihag phihag changed the title Determining file size without downlodaing Determining file size without downloading Dec 4, 2014
@phihag
Copy link
Contributor

@phihag phihag commented Dec 4, 2014

In general, we may not know the filesize before actually downloading. You can, however, pass the -j option and look at the filesize or filesize_approx fields in the result:

$ youtube-dl http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334 -j | jq .filesize
37083683
$ youtube-dl 'http://www.snotr.com/video/13708/Drone_flying_through_fireworks' -j | jq .filesize_approx
98566144

Note that support for this feature totally depends on the site, and in some cases, even on the format you're picking (with -f).

I'd leave this issue open as a request for a more comprehensive option --get-filesize, which would actually need to query the URL, but since it lacks any context, I doubt I could design a good solution. Feel free to provide more context.

P.S.: Next time, we'd appreciate if you'd pick a more specific title than hello. This is an issue tracker with lots of issues in it, so we need some sorting.

@phihag phihag closed this Dec 4, 2014
@rikato06
Copy link
Author

@rikato06 rikato06 commented Dec 4, 2014

Unfortunately.
I have tried them all.
Unable to retrieve video size without downloading.

My Code :

youtubedl . ' --get-filesize -o "'.$randname.'.%(ext)s" ' . $url; ?>
@phihag
Copy link
Contributor

@phihag phihag commented Dec 4, 2014

There is no option --get-filesize at the moment. I am not sure what "tried them" refers to. I have posted two examples where this works. As I said before, without context, I do not see a way to move forward with any implementation.

@rikato06
Copy link
Author

@rikato06 rikato06 commented Dec 5, 2014

Thank you very much for the help.

@sjurajpuchky
Copy link

@sjurajpuchky sjurajpuchky commented Dec 9, 2017

Hack /usr/lib/python2.7/site-packages/youtube_dl/downloader/http.py
update line 142 and add there print(data_len)
do not forget delete /usr/lib/python2.7/site-packages/youtube_dl/downloader/http.pyc
to update changes
then you can use --max-filesize 1k to skip downloading

@sjurajpuchky
Copy link

@sjurajpuchky sjurajpuchky commented Dec 9, 2017

you can use also grep to filter filesize only
for example
youtube-dl -f 22 --max-filesize 1k https://www.youtube.com/watch?v=hfTta26iiJ4|grep "^[0-9]"

@lorenz944
Copy link

@lorenz944 lorenz944 commented Jan 28, 2020

@phihag i want to download a mp4 video from here: https://speedvideo.net/embed-2992oz2oqv79.html. Now this url provides 3 mp4 videos (and a php file whose obviously i don't care):each of them has a different quality and so a different filesize. youtube-dl is unable to tell me anything about these videos:

youtube-dl --verbose -F "https://speedvideo.net/embed-2992oz2oqv79.html"
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '-F', 'https://speedvideo.net/embed-2992oz2oqv79.html']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2020.01.24
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: ffmpeg git-2020-01-26-5e62100, ffprobe git-2020-01-26-5e62100
[debug] Proxy map: {}
[generic] embed-2992oz2oqv79: Requesting header
WARNING: Falling back on generic information extractor.
[generic] embed-2992oz2oqv79: Downloading webpage
[generic] embed-2992oz2oqv79: Extracting information
[download] Downloading playlist: None
[generic] playlist None: Collected 4 video ids (downloading 4 of them)
[download] Downloading video 1 of 4
[info] Available formats for 2992oz2oqv79:
format code extension resolution note
0 unknown_video unknown
[download] Downloading video 2 of 4
[info] Available formats for 2992oz2oqv79:
format code extension resolution note
0 unknown_video unknown
[download] Downloading video 3 of 4
[info] Available formats for 2992oz2oqv79:
format code extension resolution note
0 unknown_video unknown
[download] Downloading video 4 of 4
[info] Available formats for thum:
format code extension resolution note
0 php unknown
[download] Finished downloading playlist: None

So i can't select the best quality video to download and i have to download all the videos (succesfully):

youtube-dl https://speedvideo.net/embed-2992oz2oqv79.html
[generic] embed-2992oz2oqv79: Requesting header
WARNING: Falling back on generic information extractor.
[generic] embed-2992oz2oqv79: Downloading webpage
[generic] embed-2992oz2oqv79: Extracting information
[download] Downloading playlist: None
[generic] playlist None: Collected 4 video ids (downloading 4 of them)
[download] Downloading video 1 of 4
[download] Destination: Speedvideo.net (1)-2992oz2oqv79.unknown_video
[download] 100% of 285.45MiB in 05:36
[download] Downloading video 2 of 4
[download] Destination: Speedvideo.net (2)-2992oz2oqv79.unknown_video
[download] 71.9% of 702.93MiB at 820.06KiB/s ETA 04:06 [download] Got server HTTP error: [WinError 10054] Connessione in corso interrotta forzatamente dall'host remoto. Retrying (attempt 1 of 10)...
[download] Destination: Speedvideo.net (2)-2992oz2oqv79.unknown_video
[download] 100% of 702.93MiB in 18:48
[download] Downloading video 3 of 4
[download] Destination: Speedvideo.net (3)-2992oz2oqv79.unknown_video
[download] 100% of 143.39MiB in 02:34
[download] Downloading video 4 of 4
[download] Destination: Speedvideo.net (4)-thum.php
[download] 100% of 8.00B in 00:00
[download] Finished downloading playlist: None

So,it seems that at the download moment youtube-dl knows the size of the videos.
Now, the google chrome browser extension "videoDownloadHelper" can tell me the filesize of the videos:
image

Here is the detail of the best of the 3 videos:
image

youtube-dl does not provide me any informations about size or approximated size:

youtube-dl --skip-download -j https://speedvideo.net/embed-2992oz2oqv79.html
WARNING: Falling back on generic information extractor.
{"url": "https://speedvideo.net/getvideo///:8779/stl424biu3xyftxxypl5eqapjxmxpmsn62vh33qwvburkr2xushk5xxhlmwq/v.mp4/2992oz2oqv79", "age_limit": 0, "format_id": "0", "_filename": "Speedvideo.net (1)-2992oz2oqv79.unknown_video", "playlist_id": null, "playlist": null, "display_id": "2992oz2oqv79", "fulltitle": "Speedvideo.net (1)", "format": "0 - unknown", "ext": "unknown_video", "title": "Speedvideo.net (1)", "webpage_url_basename": "embed-2992oz2oqv79.html", "playlist_uploader": null, "protocol": "https", "http_headers": {"Accept-Encoding": "gzip, deflate", "Accept-Language": "en-us,en;q=0.5", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3611.2 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8", "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,;q=0.7", "Cookie": "lang=1; __cfduid=dd7615b34b31b70dec5e8f4fb183bcd951580232527"}, "id": "2992oz2oqv79", "extractor": "generic", "webpage_url": "https://speedvideo.net/embed-2992oz2oqv79.html", "playlist_uploader_id": null, "n_entries": 4, "requested_subtitles": null, "extractor_key": "Generic", "playlist_index": 1, "playlist_title": null, "uploader": "speedvideo.net"}
{"url": "https://speedvideo.net/getvideo///:8779/stl424biu3xyftxxypl5eqapjxmxpmsn62vh33qwvzurkr2xushgp3gu3qca/v.mp4/2992oz2oqv79", "age_limit": 0, "format_id": "0", "_filename": "Speedvideo.net (2)-2992oz2oqv79.unknown_video", "playlist_id": null, "playlist": null, "display_id": "2992oz2oqv79", "fulltitle": "Speedvideo.net (2)", "format": "0 - unknown", "ext": "unknown_video", "title": "Speedvideo.net (2)", "webpage_url_basename": "embed-2992oz2oqv79.html", "playlist_uploader": null, "protocol": "https", "http_headers": {"Accept-Encoding": "gzip, deflate", "Accept-Language": "en-us,en;q=0.5", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3611.2 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,
/;q=0.8", "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,;q=0.7", "Cookie": "lang=1; __cfduid=dd7615b34b31b70dec5e8f4fb183bcd951580232527"}, "id": "2992oz2oqv79", "extractor": "generic", "webpage_url": "https://speedvideo.net/embed-2992oz2oqv79.html", "playlist_uploader_id": null, "n_entries": 4, "requested_subtitles": null, "extractor_key": "Generic", "playlist_index": 2, "playlist_title": null, "uploader": "speedvideo.net"}
{"url": "https://speedvideo.net/getvideo/////:8779/stl424biu3xyftxxypl5eqapjxmxpmsn62vh33qwvjurkr2xushnwzzbuvcq/v.mp4/2992oz2oqv79", "age_limit": 0, "format_id": "0", "_filename": "Speedvideo.net (3)-2992oz2oqv79.unknown_video", "playlist_id": null, "playlist": null, "display_id": "2992oz2oqv79", "fulltitle": "Speedvideo.net (3)", "format": "0 - unknown", "ext": "unknown_video", "title": "Speedvideo.net (3)", "webpage_url_basename": "embed-2992oz2oqv79.html", "playlist_uploader": null, "protocol": "https", "http_headers": {"Accept-Encoding": "gzip, deflate", "Accept-Language": "en-us,en;q=0.5", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3611.2 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8", "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,;q=0.7", "Cookie": "lang=1; __cfduid=dd7615b34b31b70dec5e8f4fb183bcd951580232527"}, "id": "2992oz2oqv79", "extractor": "generic", "webpage_url": "https://speedvideo.net/embed-2992oz2oqv79.html", "playlist_uploader_id": null, "n_entries": 4, "requested_subtitles": null, "extractor_key": "Generic", "playlist_index": 3, "playlist_title": null, "uploader": "speedvideo.net"}
{"url": "https://prw.speedvideo.net/thum.php?file=", "age_limit": 0, "format_id": "0", "_filename": "Speedvideo.net (4)-thum.php", "playlist_id": null, "playlist": null, "display_id": "thum", "fulltitle": "Speedvideo.net (4)", "format": "0 - unknown", "ext": "php", "title": "Speedvideo.net (4)", "webpage_url_basename": "embed-2992oz2oqv79.html", "playlist_uploader": null, "protocol": "https", "http_headers": {"Accept-Encoding": "gzip, deflate", "Accept-Language": "en-us,en;q=0.5", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3611.2 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,
/;q=0.8", "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,;q=0.7", "Cookie": "lang=1; __cfduid=dd7615b34b31b70dec5e8f4fb183bcd951580232527"}, "id": "thum", "extractor": "generic", "webpage_url": "https://speedvideo.net/embed-2992oz2oqv79.html", "playlist_uploader_id": null, "n_entries": 4, "requested_subtitles": null, "extractor_key": "Generic", "playlist_index": 4, "playlist_title": null, "uploader": "speedvideo.net"}

One possible solution: I could consult videodownloadhelper and download the heaviest file in terms of MegaByte and it works:

youtube-dl --min-filesize 700M "https://speedvideo.net/embed-2992oz2oqv79.html"
[generic] embed-2992oz2oqv79: Requesting header
WARNING: Falling back on generic information extractor.
[generic] embed-2992oz2oqv79: Downloading webpage
[generic] embed-2992oz2oqv79: Extracting information
[download] Downloading playlist: None
[generic] playlist None: Collected 4 video ids (downloading 4 of them)
[download] Downloading video 1 of 4
[download] File is smaller than min-filesize (299315010 bytes < 734003200 bytes). Aborting.
[download] Downloading video 2 of 4
[download] Destination: Speedvideo.net (2)-2992oz2oqv79.unknown_video
[download] 2.9% of 702.93MiB at 3.11MiB/s ETA 03:39
ERROR: Interrupted by user

but it's a cumbersome solution. Is there another solution? thank you by the way, youtube-dl is amazing and you contributors are awesome to doing this for free.

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