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

Output template to append filesize in GiB,MiB or KiB as shown in -F #2085

Closed
4 tasks done
barkoder opened this issue Dec 22, 2021 · 5 comments
Closed
4 tasks done

Output template to append filesize in GiB,MiB or KiB as shown in -F #2085

barkoder opened this issue Dec 22, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@barkoder
Copy link

Checklist

Description

Basically a %(pretty_filesize)s output template field.

I know that %(filesize)s and %(approx_filesize)s exists.
But I want the value that shows up in -F to show up in my filenames. I know that size is less precise but it's way more human-readable.

I'd like
yt-dlp --get-filename --restrict-filenames -f 135 BaW_jenozKc -o "%(uploader)s-%(upload_date)s-%(title)s-%(id)s-%(pretty_filesize)s.%(ext)s"
to print
Philipp_Hagemeister-20121002-youtube-dl_test_video_a-BaW_jenozKc-849.41KiB.mp4

Or if I want -f 22 BaW_jenozKc then %(pretty_filesize)s should print its corresponding approx. filesize of ~1.82MiB as shown in -F making the output file Philipp_Hagemeister-20121002-youtube-dl_test_video_a-BaW_jenozKc-~1.82MiB.mp4

Thanks.

@barkoder barkoder added enhancement New feature or request triage Untriaged issue labels Dec 22, 2021
@pukkandan pukkandan removed the triage Untriaged issue label Dec 22, 2021
@pukkandan
Copy link
Member

With e0fd957, you can do %(filesize).2DiB

@barkoder
Copy link
Author

%(filesize).2DiB appears to give some sort of approximate size? Instead of the actual size as shown in -F?

Am I mistaken?

$ yt-dlp -F FJSI7QTAt_o | grep 3840x2160
313 webm  3840x2160   25 |    3.98GiB 8320k https | vp9         8320k video only              2160p, webm_dash

f313 is 3.98GiB. And the actual file size when downloaded is also 3.98GiB as shown in -F.

However, when I do

$ yt-dlp --print filename -f 313 FJSI7QTAt_o -o "%(filesize).2DiB"
4.28GiB

4.28GiB is way off the actual size of 3.98GiB.

It's not just f313. It's all formats.
The disparity is wider when the video filesize is larger so I've used f313 to illustrate.
But the %(filesize).2DiB for none of the formats match the correct size value as shown in -F.

Also for -f 22

yt-dlp --print filename -f 22 FJSI7QTAt_o -o "%(filesize).2DiB"
NoneiB

Instead of ~189.70MiB.

@pukkandan
Copy link
Member

The D prefix uses 1000 based suffix. This is why the filesize was appearing different from what you expected. In abbeeeb, I have now added #D to use 1024 instead.

For -f22, the filesize is not known, only the filesize_approx is. If you want to use either, you can use filesize,filesize_approx as the key

Ashish0804 added a commit to Ashish0804/yt-dlp that referenced this issue Jan 1, 2022
commit 8efffaf
Author: MinePlayersPE <mineplayerspealt@gmail.com>
Date:   Sat Jan 1 13:12:33 2022 +0700

    [XVideos] Check HLS formats (yt-dlp#2193)

    Closes yt-dlp#1823
    Authored by; MinePlayersPE

commit 26f2aa3
Author: Ashish Gupta <39122144+Ashish0804@users.noreply.github.com>
Date:   Sat Jan 1 02:32:23 2022 +0530

    [hotstar] Add extractor args to ignore tags (yt-dlp#2116)

    Authored by: Ashish0804

commit 3464a27
Author: pgaig <87302379+pgaig@users.noreply.github.com>
Date:   Fri Dec 31 21:58:23 2021 +0100

    [VrtNU] Handle empty title (yt-dlp#2147)

    Closes yt-dlp#2146
    Authored by: pgaig

commit 497d77e
Author: Ashish Gupta <Ashish08@protonmail.com>
Date:   Fri Dec 31 10:41:42 2021 +0530

    [KelbyOne] Add extractor (yt-dlp#2181)

    Closes yt-dlp#2170
    Authored by: Ashish0804

commit 9040e2d
Author: LE <llacb47@users.noreply.github.com>
Date:   Fri Dec 31 15:11:35 2021 -0500

    [mixcloud] Detect restrictions (yt-dlp#2169)

    Authored by; llacb47

commit 6134fbe
Author: MinePlayersPE <mineplayerspealt@gmail.com>
Date:   Sat Jan 1 03:10:46 2022 +0700

    [TikTok] Pass cookies to formats (yt-dlp#2171)

    Closes yt-dlp#2166
    Authored by: MinePlayersPE

commit cfcf60e
Author: MinePlayersPE <mineplayerspealt@gmail.com>
Date:   Sat Jan 1 03:09:30 2022 +0700

    [BiliIntl] Add login (yt-dlp#2172)

    and misc improvements

    Authored by: MinePlayersPE

commit 4afa3ec
Author: Felix S <felix.von.s@posteo.de>
Date:   Fri Dec 31 20:06:45 2021 +0000

    [extractor] Detect more subtitle codecs in MPD manifests (yt-dlp#2174)

    Authored by: fstirlitz

commit 11aa91a
Author: MinePlayersPE <mineplayerspealt@gmail.com>
Date:   Thu Dec 30 11:20:17 2021 +0700

    [TikTok] Fix extraction for sigi-based webpages (yt-dlp#2164)

    Fixes: yt-dlp#2133
    Authored by: MinePlayersPE

commit abbeeeb
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Thu Dec 30 08:43:40 2021 +0530

    [outtmpl] Alternate form for `D` and fix suffix's case

    Fixes: yt-dlp#2085 (comment), https://github.com/yt-dlp/yt-dlp/pull/2132/files#r775729811

commit 2c539d4
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Thu Dec 30 08:15:48 2021 +0530

    [cookies] Fix bug when keyring is unspecified

    Closes yt-dlp#2167

commit 042931a
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Thu Dec 30 08:15:07 2021 +0530

    Allow escaped `,` in `--extractor-args`

    Closes yt-dlp#2152

commit 96f13f0
Author: MinePlayersPE <mineplayerspealt@gmail.com>
Date:   Thu Dec 30 05:00:44 2021 +0700

    [TikTok] Change app version (yt-dlp#2161)

    Closes yt-dlp#2133, yt-dlp#2135
    Authored by: MinePlayersPE, llacb47

commit 4b93532
Author: u-spec-png <54671367+u-spec-png@users.noreply.github.com>
Date:   Tue Dec 28 20:42:14 2021 +0000

    [Drooble] Add extractor (yt-dlp#1547)

    Closes yt-dlp#1527
    Authored by: u-spec-png

commit dd5e60b
Author: u-spec-png <54671367+u-spec-png@users.noreply.github.com>
Date:   Tue Dec 28 18:58:06 2021 +0000

    [Instagram] Add story/highlight extractor (yt-dlp#2006)

    Fixes ytdl-org/youtube-dl#25575
    Authored by: u-spec-png

commit e540c56
Author: MinePlayersPE <mineplayerspealt@gmail.com>
Date:   Tue Dec 28 09:38:23 2021 +0700

    [TikTok] Fallback to feed API endpoint (yt-dlp#2142)

    Authored by: MinePlayersPE
    Workaround for yt-dlp#2133

commit 45d86ab
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Tue Dec 28 04:21:13 2021 +0530

    Allow unicode characters in `info.json`

    Closes yt-dlp#2139

commit f02d24d
Author: Pierre Mdawar <pierre@mdawar.dev>
Date:   Tue Dec 28 03:38:31 2021 +0530

    [utils] Fix `format_bytes` output for Bytes (yt-dlp#2132)

    Authored by: pukkandan, mdawar

commit ceb9832
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Tue Dec 28 02:52:11 2021 +0530

    Don't treat empty containers as `None` in `sanitize_info`

commit 7537e35
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Tue Dec 28 02:49:02 2021 +0530

    [gfycat] Fix `uploader`
@barkoder
Copy link
Author

Hey @pukkandan Thanks for the help but could you make it so that the decimals are not truncated?

yt-dlp --print filename -f 313 FJSI7QTAt_o -o "%(filesize)#DB"
3GiB

which is almost ~1GB away from the actual size of 3.98GiB

I'd very much like the output to be 3.98GiB as shown in -F.

Thanks!

@pukkandan
Copy link
Member

It accepts the same format as float. So just do %(filesize)#.2DB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants