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

How can I export the downloaded file name to a txt file? #27192

Closed
yasuo9x opened this issue Nov 25, 2020 · 7 comments
Closed

How can I export the downloaded file name to a txt file? #27192

yasuo9x opened this issue Nov 25, 2020 · 7 comments
Labels

Comments

@yasuo9x
Copy link

yasuo9x commented Nov 25, 2020

No description provided.

@ochen1
Copy link

ochen1 commented Nov 26, 2020

You can use the flags --simulate and --get-title for this.

youtube-dl --simulate --get-title "https://www.youtube.com/watch?v=YOUTUBE"

In Linux shells, you can redirect the stdout to a file by adding a > output.txt to the end.

youtube-dl --simulate --get-title "https://www.youtube.com/watch?v=YOUTUBE" > output.txt

If this solved your problem, be sure to close the issue, so it doesn't waste the developers' time.

@joeschmoe40
Copy link

joeschmoe40 commented Nov 26, 2020

Title is not the same as "downloaded filename".

So, trying to do it based on the title is not going to work.

What I do is to run the youtube-dl run with "script" - that gets you all the terminal chatter into a file.

Then you grep that file for the word "Destination" and do the appropriate parsing on that line.

@ochen1
Copy link

ochen1 commented Nov 26, 2020

Ahh, I see. I read "How can I export [download] the file name to a txt file" instead. Sorry!

@joeschmoe40
Copy link

Who knows? You could be right. Obviously, neither of us actually knows what OP wants.

I took it as:

I've just done something like:

youtube-dl "ytsearch: some string to search for"

and I got a file downloaded. I want to know the name of that file.

The point is that the actual filename (assuming no -o option given) is based on the title, but has a bunch of other stuff in it - including the extension (e.g., .mp4). So, just knowing the title isn't enough to know the full filename.

I think you've got to either parse the output of the youtube-dl run (as I indicated above) or you have to query the filesystem for files created "recently" (like in the last few minutes). This later method is, of course, a heuristic (read: some guess work involved).

Note also that I'm guessing that the real point in wanting to know the filename is to then feed that filename into a player (e.g., VLC).

Of course, what this all shows is that the easiest way to do it is to use the "-o" option to hard-code the filename. But of course, that might not be what OP wants at all.

@yasuo9x
Copy link
Author

yasuo9x commented Nov 27, 2020

thanks you every one

@pukkandan
Copy link
Contributor

If you want to download AND log the file name, use youtube-dl URL --exec "echo.{}>filenames.txt".

If you want to get the filename without downloading the video, use youtube-dl URL --get-filename >filenames.txt

@remitamine
Copy link
Collaborator

i think you got enough answers here(how to get title, filename, final filename).

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

No branches or pull requests

5 participants