Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Search arguments not working #66

Open
NerfyGek0 opened this issue Mar 16, 2022 · 4 comments
Open

Search arguments not working #66

NerfyGek0 opened this issue Mar 16, 2022 · 4 comments

Comments

@NerfyGek0
Copy link

NerfyGek0 commented Mar 16, 2022

Issue

Search arguments don't seem to work. I would specifically like to use the --after argument

I am a git and python noob. I am sorry if the answer is right there and I did not see it, I am trying.

Example:

Searching for /<some_topic> -l or /<some_topic> --live return the same results as /<come_topic>.
I was expecting that it would only return live streams. I have tried all other arguments as well (-d, -a, -c) all seem to ignore the arguments. I used --live in the above example as it does not require a value; so easy to replicate issue.

I have search the issues for yewtube (open and closed) but did not find anything obviously related to this.

Possible Answer

Looking at commands/search.py the section that seems to handle the arguments appears commented out. Not sure if this is the answer or if it has been re-implemented elsewhere. If this functionality has been removed then maybe the embedded help text help search menu should be updated?

Environment

Fedora Silverblue 35 > Installed via toobox (fedora 35 image)
Installed yt using pipx
YewTube version 2.8.1
python 3.10.2
youtube-dl 2021-12-17

@rachmadaniHaryono
Copy link

i can confirm this

@command(r'(?:search|\.|/)\s*([^./].{1,500})', 'search')
def search(term):
""" Perform search. """
try: # TODO make use of unknowns
args, unknown = parser.parse_known_args(term.split())
video_duration = args.duration if args.duration else 'any'
if args.category:
if not args.category[0].isdigit():
args.category = g.categories.get(args.category[0])
else:
args.category = "".join(args.category)
after = args.after
term = ' '.join(args.search)
except SystemExit: # <------ argsparse calls exit()
g.message = c.b + "Bad syntax. Enter h for help" + c.w
return
if not term or len(term) < 2:
g.message = c.r + "Not enough input" + c.w
g.content = content.generate_songlist_display()
return
logging.info("search for %s", term)
#query = generate_search_qs(term, videoDuration=video_duration, after=after, category=args.category, is_live=args.live)
msg = "Search results for %s%s%s" % (c.y, term, c.w)
failmsg = "Found nothing for %s%s%s" % (c.y, term, c.w)
wdata = pafy.search_videos(term, int(config.PAGES.get))

it just mean all option will be ignored and yewtube will do normal search

there is possibility to create custom search but i have to dig deeper https://github.com/alexmercerind/youtube-search-python#search-with-a-filter-or-sort

@NerfyGek0
Copy link
Author

Thanks rachmadaniHaryono,

If this is a TODO and its not going to be implemented for a while then maybe the below lines should be removed from the help so people do not try to use it. I spent more time than I would like to admit today trying to figure out what I was doing wrong :)

Search Arguments:
{2}-d, --duration{1} Can be any/short/medium/long
{2}-a, --after{1} Date in {2}YYYY-MM-DD{1} or {2}YYYY-MM-DD{1}T{2}HH:MM{1} format
{2}-l, --live{1} Limit search to livestreams
{2}-c, --category{1} Search within a category, (number or string)
Available categories:
{2}{3}{1}

Should I make a pull request to remove these lines as it seems to be a simple (non-code) change. Would this be ok?

@rachmadaniHaryono
Copy link

Should I make a pull request to remove these lines as it seems to be a simple (non-code) change. Would this be ok?

that depend on @iamtalhaasghar

there are more option

  1. delete as you suggested
  2. just add note that it is not used for now
  3. move the help text to comment section. it is still on the code but as comment

i am against option 1 because it will be added later

my best recommendation is option 2

also it is not only help text but also this part

parser.add_argument('-d', '--duration', choices=('any', 'short', 'medium', 'long'))
parser.add_argument('-a', '--after')
parser.add_argument('-l', '--live', nargs="?", const=True)
parser.add_argument('-c', '--category', nargs=1)

it also show that there is need to unify help text and that argument parser

@NerfyGek0
Copy link
Author

Agree, 2 or 3 would be better options. Maybe something like this:

Search Arguments:
Please note these are in development and are currently unavailable.
-d, --duration Can be any/short/medium/long
-a, --after Date in YYYY-MM-DD or YYYY-MM-DDTHH:MM format
-l, --live Limit search to livestreams
-c, --category Search within a category, (number or string)

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

No branches or pull requests

3 participants