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

[Feature Request] Make --extract work when there are multiple search results #43

Open
boggeroff opened this issue Sep 18, 2021 · 1 comment

Comments

@boggeroff
Copy link

boggeroff commented Sep 18, 2021

Foreword: Trizen, your work is awesome.

System: Ubuntu 21
Version: CLI Pipe Viewer 0.1.3

I'm trying to use pipe-viewer to only extract information. Objective is to have search results, or the video links/IDs most importantly, saved to a file.

This,
pipe-viewer --no-interactive --extract '*TITLE* (*ID*)' --extract-file results.txt 'https://www.youtube.com/watch?v=zfFo8BtPTnc'
produces a file with contents:

Chico Xavier - Contos Desta e Doutra Vida (zfFo8BtPTnc)

The option "--dump json" is ignored.

It would be great if something like this,
pipe-viewer --no-interactive --extract '*TITLE* (*ID*)' --extract-file results.json --dump json --related 'https://www.youtube.com/watch?v=zfFo8BtPTnc'
would output a file with multiple results, instead of an empty file. Json or plain text.

@boggeroff boggeroff changed the title --extract doesn't seem to work [Feature Request] Make --extract work when there are multiple search results Sep 18, 2021
@boggeroff
Copy link
Author

boggeroff commented Sep 18, 2021

A crappy solution to print related videos' ids of a video. Before anyone wants to extend this, consider learning Perl and contribute to the project. Which, I did consider myself but I can't be unfathful to python. And bash is already here as this irritable thing that can't be scraped off.

Install the expect package if you don't have it already.
Put this in an executable:

#!/usr/bin/bash
[ $# -lt 2 ] && { echo 'arg1: range; arg2: video link'; exit 1; }
expect_cmd=$(cat <<- END
spawn pipe-viewer --no-interactive --no-use-colors --std-in=":info=$1" --related "$2"
expect "=>> Press ENTER to continue..." { send "\r" }
expect eof
END
)
/usr/bin/expect -c "$expect_cmd" | grep VideoID | sed -E 's/.*VideoID\s+:\s+([a-zA-Z0-9_-]+)/\1/g'

Use it:

<exe> 1-3 'https://www.youtube.com/watch?v=123456789ab'

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

No branches or pull requests

1 participant