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

**Search** for appropriate video(s) on YouTube #3319

Closed
kernc opened this issue Jul 22, 2014 · 6 comments
Closed

**Search** for appropriate video(s) on YouTube #3319

kernc opened this issue Jul 22, 2014 · 6 comments

Comments

@kernc
Copy link

@kernc kernc commented Jul 22, 2014

This is a feature request. This is how I imagine it:

The user uses --yt-search (or appropriate) switch with a string argument which can either be a search query or a filename with search queries one per line. youtube-dl then uses publicly provided YouTube API to get for each query the most similar matches, electing the most preferable one by some heuristic involving e.g. result position, Levenshtein string distance, video meta-attributes like quality, popularity, ..., and downloads it (acting as if that was the url provided, honoring all other command line switches, for each query), or reports no suitable matches found.

If you find this a desirable feature, I may be able to provide a pull request if you remind me in a few weeks. However, if you think there is not a lot of work which is more elegantly accomplished by someone who knows the codebase better, I'd take anybody up on that. :P

In either case, some guidelines and feedback are in order.

@dean
Copy link

@dean dean commented Jul 22, 2014

If anyone wants to use this for reference, I wrote something that shells out to youtube-dl to do exactly what's being asked: https://github.com/dean/YoutubeDL.

@phihag
Copy link
Contributor

@phihag phihag commented Jul 22, 2014

This feature is already implemented.

Use youtube-dl "ytsearch:sleeping bunny" to search for a single video.
Use --default-search ytsearch2: to download the top 2 videos on YouTube for every input.
Use --batch-file urls.list to read a list of URLs from the file urls.list. Every entry that is not a valid URL will be resolved with the default search.

Where did you look for this feature, and what search terms did you use? --default-search and --batch-file are documented in the output of youtube-dl --help, and ytsearch: and friends are mentioned there as well and listed in depth in the output of youtube-dl --extractor-descriptions.

@phihag phihag closed this Jul 22, 2014
@phihag
Copy link
Contributor

@phihag phihag commented Jul 22, 2014

@dean No offense, but you've essentially recreated parts of youtube-dl. In particular, have a look at the --reject-title and --batch-file options. Also note the ytsearch:, ytuser:, yttoplist: (and various other) extractors . To top it off, there is no need to construct URLs from YouTube IDs, youtube-dl will happily accept YouTube IDs.

@kernc
Copy link
Author

@kernc kernc commented Jul 22, 2014

Gah, I'm sorry. I did notice --default-search in passing but didn't think much of "gvsearch2:". Similarly, I never cared to inspect --extractor-description as I was only expecting to see a list of supported websites. 😳

Thanks for the help and for maintaining such a well-though piece of software!

@dean
Copy link

@dean dean commented Jul 31, 2014

@phihag Sorry for the late reply, but I'm not quite sure you read exactly what my code does. Mine will take queries in the form of 'title - artist\n' for each line of a file, query youtube with the search terms, then look at the results and compare lengths of videos, whether or not a video is hd, and look at view counts to determine the best video to download (although it's audio only at the moment). It's meant to be smarter than just taking the first result of the queried string.

@phihag
Copy link
Contributor

@phihag phihag commented Jul 31, 2014

I'm well-aware that your algorithm does more than simple searching. Nevertheless, search and information extraction is highly redundant with the built-in features of youtube-dl. Try -j and the aforementioned --default-search.

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
3 participants
You can’t perform that action at this time.