mps-youtube / yewtube

yewtube, forked from mps-youtube , is a Terminal based YouTube player and downloader. No Youtube API key required.
GNU General Public License v3.0
8.07k stars 648 forks source link

Combine results of two searches #854

Open gmnz opened 6 years ago

gmnz commented 6 years ago

I had to reformulate my question, because it contained a logical mistake, so what I need is this: I search for dog related videos: /dog I get a list of dog related videos: Dog video 1 Dog video 2 etc. Then I search for cat related videos: /cat I get: Cat video 1 Cat video 2 I would like to be able to search for /cat and /dog at the same time and get as the result the same videos but in one combined list sorted e.g. by date: Dog video 24.6.2018 Cat video 23.6.2018 Dog video 16.5.2018 Cat video 4.3.2018 etc.

Sorry for formulating the question wrong on the first try.

ritiek commented 6 years ago

For videos you can use | as OR so it looks like /dog|cat.

Quoting from https://developers.google.com/youtube/v3/docs/search/list#parameters:

The q parameter specifies the query term to search for.

Your request can also use the Boolean NOT (-) and OR (|) operators to exclude videos or to find videos that are associated with one of several search terms. For example, to search for videos matching either "boating" or "sailing", set the q parameter value to boating|sailing. Similarly, to search for videos matching either "boating" or "sailing" but not "fishing", set the q parameter value to boating|sailing -fishing. Note that the pipe character must be URL-escaped when it is sent in your API request. The URL-escaped value for the pipe character is %7C.

But something like this wouldn't work for searching users.

gmnz commented 6 years ago

@ritiek Your solution gives me a different list of results, not a combination of the two searches. But you've made me realize my question was formulated wrong, so thanks anyway!

kraetzin commented 6 years ago

@gmnz Perhaps I've misunderstood but the OR operator does seem to give me a combination of the two searches. For example if I search /muse and /radiohead, then combine the two as /muse | radiohead, the resulting list is indeed a combination of the two lists. As for listing by date I don't believe that is implemented, but you can use /<search term> -a YYYY-MM-DD to limit searches to after the date YYYY-MM-DD.