question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please add a switch to trim filename to specific character count

See original GitHub issue

Checklist

  • I’m reporting a feature request
  • I’ve verified that I’m running youtube-dl version 2021.03.14
  • I’ve searched the bugtracker for similar feature requests including closed ones

Description

WRITE DESCRIPTION HERE If you try to download a file that’s over 250 characters, the download will fail, so can you please add a switch that would trim the file name (excluding the extension) to a specific amount of characters to prevent this from happening? E.g., --trim-filename 7 to trim, e.g., this is the original filename.mp4 to this is.mp4 Certain forks have already done this (https://github.com/blackjack4494/youtube-dlc/issues/85), so maybe it can even be carried over, but it would mean a loooot.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
rautamiekkacommented, Mar 17, 2021

Good to know. 😃 Can you explain what the “.” does in .7s? Does it tell it to match until it sees a “.” character and to match only upto x number of characters? I did look at the Python string formatting page, but it was kind of confusing (and I do know a bit of Python, but I’ve never used formatting like that). Are there any other examples you can think of that could be useful? I know you can pad numbers like %(number)03d, etc.

https://docs.python.org/3/library/stdtypes.html#old-string-formatting explains the dot as

5. Precision (optional), given as a '.' (dot) followed by the precision. If specified as '*' (an asterisk), the actual precision is read from the next element of the tuple in values, and the value to convert comes after the precision.

I tested it in an IPython console:

>>> print(
...    "%(title).7s" % {"title":"test0123456789"}
... )
test012
>>> print(
...     "%(title)7s" % {"title":"test0123456789"}
... )
test0123456789

So yeah, the .7s means the incoming value for title is converted into string max 7 chars long.

1reaction
ns-studioscommented, Mar 17, 2021

@garoto Thank you so so so much! I’ve always wanted this, but didn’t realize it was there all along.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove characters from specific length - Stack Overflow
I have tried sed -r command on Linux servers but it's not working on AIX servers. Linux command: sed -r 's/.(.{3}).*/\1/' filename.txt.
Read more >
Remove Data Before or After a Specific Character in Excel
Your browser can't play this video. Learn more. Switch camera.
Read more >
How to rename multiple files in Windows - YouTube
Switch camera. Share. Include playlist. An error occurred while retrieving sharing information. Please try again later. 0:00. 0:00 / 14:10•
Read more >
Handy one-liners for SED
N; s/\n/ /' # count lines (emulates "wc -l") sed -n '$=' TEXT CONVERSION AND ... of file # delete BOTH leading and...
Read more >
Get-ChildItem : The specified path, file name, or both are too ...
Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found