LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > antiX / MX Linux
User Name
Password
antiX / MX Linux This forum is for the discussion of antiX and MX Linux.

Notices


Reply
  Search this Thread
Old 12-10-2021, 12:31 PM   #1
Snugbug
Member
 
Registered: May 2020
Posts: 97

Rep: Reputation: Disabled
MX 19.4 xfce 64bit - yt-dlp - how to remove string in brackets, please?


Using youtube-dl with no options afterwards, I used to get the file with the file name, followed by its extension.

But now, with the successor of youtube-dl, called yt-dlp, using it alike, I'm getting a file with the file name, followed by some brackets like this [] and a string inside, according to the final section of the url of the wanted clip and then, there's the file extension.

How can I remove the brackets and the string inside, in order to have only the file name and its extension, like it used to be with youtube-dl, please?
 
Old 12-10-2021, 12:41 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
You can specify the output template with -o.
 
Old 12-10-2021, 04:14 PM   #3
Snugbug
Member
 
Registered: May 2020
Posts: 97

Original Poster
Rep: Reputation: Disabled
As far as I understand that guide, I have to add the string that I want to remove, manually, to each and every single download command.

But that's not what I had in mind, sorry, because since that string is different for each download, that's very uncomfortable.
What I'm asking for is how to remove these brackets with the string inside, automatically?
 
Old 12-10-2021, 04:25 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,138

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Instead of just looking at the examples shruggy posted, page up to get to the start of the section, and start reading.
 
Old 12-10-2021, 05:03 PM   #5
Snugbug
Member
 
Registered: May 2020
Posts: 97

Original Poster
Rep: Reputation: Disabled
After reading this section, I still have no clue as for what to do to get rid of the brackets and the string, sorry.

Let's try it another way.

This is a script, I once created for youtube-dl, which used to work very well:

Code:
#!/bin/bash
echo " Download with youtube-dl "
echo "**************************"
echo 'Currently installed Version:'; youtube-dl --version
echo
echo If available, an update of youtube-dl will be performed.
echo

sudo youtube-dl -U
# sudo python3 -m pip install -U yt-dlp
echo

echo "Currently, target folder according to 'youtube-dl.conf' is :"
echo
sleep 1
echo "$(grep -v '#' /home/username/.config/youtube-dl.conf)"
# Note: There's the path to the target folder in the youtube-dl.conf.
sleep 2
clear

echo " Download with youtube-dl "
echo "**************************"
echo
echo
read -p "Please enter URL of wanted file: `echo $'\n> '`" a
echo
sleep 1

youtube-dl "${a}"
echo
sleep 2

read -n 1 -s -r -p "Hit any key to finish..."
echo
kill -9 $PPID
What I found out so far is that I have to replace

Code:
sudo youtube-dl -U
with

Code:
sudo python3 -m pip install -U yt-dlp
to make the update work for yt-dlp and to replace

Code:
youtube-dl "${a}"
with

Code:
yt-dlp "${a}"
to get the wanted file.

Now, I want to remove the brackets and the string, but unfortunately, I don't understand this cryptical stuff well enough to get the removal done.

Last edited by Snugbug; 12-10-2021 at 05:08 PM.
 
Old 12-11-2021, 04:33 PM   #6
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554

The differences between yt-dlp and youtube-dl are described in the yt-dlp readme, along with mention of the option "--compat-options youtube-dl" to revert those changes.

 
1 members found this post helpful.
Old 12-13-2021, 04:39 PM   #7
Snugbug
Member
 
Registered: May 2020
Posts: 97

Original Poster
Rep: Reputation: Disabled
The only section that I found, referring to the output template, is this
Quote:
The default output template is %(title)s [%(id)s].%(ext)s. There is no real reason for this change. This was changed before yt-dlp was ever made public and now there are no plans to change it back to %(title)s-%(id)s.%(ext)s. Instead, you may use --compat-options filename
but there's no information about how to revert something.

The only section that I found, referring to reverting something is this
Quote:
The default format selector is bv*+ba/b. This means that if a combined video + audio format that is better than the best video-only format is found, the former will be prefered. Use -f bv+ba/b or --compat-options format-spec to revert this
but it doesn't refer to the output template.

So I don't understand what you mean or what I have to do to get the old output template.

Could you please just tell me what exactly I have to do, instead of pointing me to some readme that I don't understand anyway?
I did read it several times, but still, I've got no clue about what to do, to get this fixed.
 
Old 12-13-2021, 06:56 PM   #8
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
@Snugbug

FWIW I am still using youtube-dl. Is there a feature of yt-dlp that you must use?

eg for mp3 I run...but I am sure there are smarter ways
Code:
youtube-dl  https://youtu.be/N_KB0Ow4fVo -x --audio-format mp3
[youtube] N_KB0Ow4fVo: Downloading webpage
[download] Destination: Dave Cousins Blue Angel The Strawbs-N_KB0Ow4fVo.webm
[download] 100% of 9.57MiB in 02:01
[ffmpeg] Destination: Dave Cousins Blue Angel The Strawbs-N_KB0Ow4fVo.mp3
Deleting original file Dave Cousins Blue Angel The Strawbs-N_KB0Ow4fVo.webm (pass -k to keep)
 
Old 12-13-2021, 07:38 PM   #9
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Maybe I'm not understanding the problem, but the documentation looks pretty clear to me. Is the following what you want?
Code:
yt-dlp -o '%(title)s.%(ext)s' 'https://www.youtube.com/watch?v=aqz-KE-bpKQ'
Evo2.
 
Old 12-14-2021, 07:37 AM   #10
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554
Quote:
Originally Posted by Snugbug View Post
The only section that I found, referring to the output template, is this

Quote:
The default output template is %(title)s [%(id)s].%(ext)s. There is no real reason for this change. This was changed before yt-dlp was ever made public and now there are no plans to change it back to %(title)s-%(id)s.%(ext)s. Instead, you may use --compat-options filename
but there's no information about how to revert something.
Read the highlighted text.


Quote:
The only section that I found, referring to reverting something...
Aside from the first two, every bullet point in the "Differences in default behavior" section is referring to reverting/undoing/resetting an change in defaults that yt-dlp developers made.


Quote:
Could you please just tell me what exactly I have to do, instead of pointing me to some readme that I don't understand anyway?
In addition to linking to the documentation I provided the exact option you just need to make all non-bug yt-dlp behaviour the same as youtube-dl.

:|

If you don't want to type it every time, put it in a config file - that section includes an example of using a config file for changing the output filename.


Last edited by boughtonp; 12-14-2021 at 07:47 AM.
 
1 members found this post helpful.
Old 08-09-2023, 02:27 PM   #11
0314R
LQ Newbie
 
Registered: Aug 2023
Posts: 1

Rep: Reputation: 0
solution, though late

20 months late, but you just gotta add this option:

--replace-in-metadata "title" " \(.*?\)" ""

you can leave out the question mark if you want greedy pattern matching instead of non-greedy, as explained here: https://docs.python.org/3/library/re...ression-syntax

Last edited by 0314R; 08-09-2023 at 02:32 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Want to grep data between square brackets(Including brackets) harshagr Programming 20 02-15-2018 07:23 AM
LXer: TI DLP chipset targets 3D imaging devices, runs Linux LXer Syndicated Linux News 0 05-15-2013 10:20 AM
LXer: Configure An Email Gateway With Scrollout F1 Anti-Spam & DLP LXer Syndicated Linux News 0 07-23-2012 02:11 PM
LXer: TI ships Linux-ready DLP eval module for pico projectors LXer Syndicated Linux News 0 01-26-2012 04:10 PM
46" Samsung DLP Screen displays as 50" - Can't see the whole screen! magnet-o Linux - Newbie 2 02-08-2011 07:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > antiX / MX Linux

All times are GMT -5. The time now is 11:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration