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

use --get-title while not simulating? #24654

Closed
MarByteBeep opened this issue Apr 6, 2020 · 9 comments
Closed

use --get-title while not simulating? #24654

MarByteBeep opened this issue Apr 6, 2020 · 9 comments
Labels

Comments

@MarByteBeep
Copy link

@MarByteBeep MarByteBeep commented Apr 6, 2020

Checklist

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

Description

I'm trying to download a video AND get title information displayed in the console log as well. When invoking

youtube-dl.exe SmanVIJ80EY --no-call-home --newline -x -o "out.$(ext)s" 2>&1

I see a lot of information, but neither of it contains the video title. I also tried -v for extra information, but here too: no video title.

There is a way to obtain that using --get-title, but when supplying that, no actual download takes place. It merely simulates.

To get this information, I then have to call the tool twice, which is a lot slower, since there seems to be a significant startup time.

Is there a way to get the video title in the output in the same pass as downloading it?

@MarByteBeep MarByteBeep added the request label Apr 6, 2020
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Apr 6, 2020

--print-json.

@dstftw dstftw closed this Apr 6, 2020
@MarByteBeep
Copy link
Author

@MarByteBeep MarByteBeep commented Apr 6, 2020

--print-json behaves completely different. There is no progress indication anymore and it basically dumps all information to the stdout. Just compare the outputs of these two commands:

youtube-dl.exe SmanVIJ80EY --no-call-home --newline -x -o "out.$(ext)s" 2>&1
youtube-dl.exe SmanVIJ80EY --no-call-home --print-json --newline -x -o "out.$(ext)s" 2>&1

The first one outputs something like this:

[youtube] SmanVIJ80EY: Downloading webpage
[youtube] SmanVIJ80EY: Downloading MPD manifest
[dashsegments] Total fragments: 27
[download] Destination: out.$(ext)s
[download]   3.7% of ~15.61KiB at Unknown speed ETA 00:01
[download]   3.7% of ~15.61KiB at Unknown speed ETA 00:01
[download]   0.1% of ~1.03MiB at 999.83KiB/s ETA 00:48
[download]   0.3% of ~1.03MiB at  2.93MiB/s ETA 00:21
[download]   0.7% of ~1.03MiB at  3.42MiB/s ETA 00:10
...

The latter outputs no progress, only one big information json. It would be great if something like this could be outputted:

[youtube] SmanVIJ80EY: Downloading webpage
[youtube] SmanVIJ80EY: Downloading MPD manifest
[videotitle] the answer to life, universe and everything is .. 42
[dashsegments] Total fragments: 27
[download] Destination: out.$(ext)s
[download]   3.7% of ~15.61KiB at Unknown speed ETA 00:01
[download]   3.7% of ~15.61KiB at Unknown speed ETA 00:01
[download]   0.1% of ~1.03MiB at 999.83KiB/s ETA 00:48
[download]   0.3% of ~1.03MiB at  2.93MiB/s ETA 00:21
[download]   0.7% of ~1.03MiB at  3.42MiB/s ETA 00:10
...
@MarByteBeep
Copy link
Author

@MarByteBeep MarByteBeep commented Apr 6, 2020

@dstftw since you immediately closed this issue; I'm not sure if you get these updates, but please check my previous comment on --print-json

@MarByteBeep MarByteBeep mentioned this issue Apr 7, 2020
3 of 3 tasks complete
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Apr 7, 2020

No such feature exists.

@MarByteBeep
Copy link
Author

@MarByteBeep MarByteBeep commented Apr 7, 2020

@dstftw that I know; hence the reason for a feature request

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Apr 7, 2020

I don't think this deserves an option.

@MarByteBeep
Copy link
Author

@MarByteBeep MarByteBeep commented Apr 7, 2020

@dstftw you already have the option --get-title. The only thing that is missing is to display that in one go. I don't understand why it would take two runs to get something as trivial as a video title.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Apr 7, 2020

--get-title is a simulate option, it's not supposed to download anything and it won't.

@MarByteBeep
Copy link
Author

@MarByteBeep MarByteBeep commented Apr 7, 2020

@dstftw by changing the __forced_printings method in YouTubeDL.py, we can have the best of both worlds. It displays [videotitle] <title> in non-simulation mode. And keeps the same behavior in simulation mode. If possible, can you please add this change?

    def __forced_printings(self, info_dict, filename, incomplete):
        def print_title():
            if (not incomplete or info_dict.get(field) is not None):
                if (self.params.get('forcetitle', False)):
                    self.to_stdout(info_dict["title"])
                else:
                    self.to_stdout("[videotitle] %s" % info_dict["title"])
				    
        def print_mandatory(field):
            if (self.params.get('force%s' % field, False)
                    and (not incomplete or info_dict.get(field) is not None)):
                self.to_stdout(info_dict[field])

        def print_optional(field):
            if (self.params.get('force%s' % field, False)
                    and info_dict.get(field) is not None):
                self.to_stdout(info_dict[field])

        print_title()
        print_mandatory('id')
        if self.params.get('forceurl', False) and not incomplete:
            if info_dict.get('requested_formats') is not None:
                for f in info_dict['requested_formats']:
                    self.to_stdout(f['url'] + f.get('play_path', ''))
            else:
                # For RTMP URLs, also include the playpath
                self.to_stdout(info_dict['url'] + info_dict.get('play_path', ''))
        print_optional('thumbnail')
        print_optional('description')
        if self.params.get('forcefilename', False) and filename is not None:
            self.to_stdout(filename)
        if self.params.get('forceduration', False) and info_dict.get('duration') is not None:
            self.to_stdout(formatSeconds(info_dict['duration']))
        print_mandatory('format')
        if self.params.get('forcejson', False):
            self.to_stdout(json.dumps(info_dict))
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
2 participants
You can’t perform that action at this time.