-
-
Notifications
You must be signed in to change notification settings - Fork 122
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 feature #92
Labels
Comments
sealedtx
added
enhancement
New feature or request
help wanted
Extra attention is needed
labels
Jul 16, 2021
You want to be able to search for videos and music with unlimited frequency |
I'm working on the implementation of the search feature. RequestSearchResult request = new RequestSearchResult("search query")
.type(TypeField.VIDEO) // Videos only
.match(FeatureField._3D,
FeatureField.HD,
FeatureField.SUBTITLES) // 3D HD videos with subtitles
.during(DurationField.OVER_20_MINUTES) // more than 20 minutes videos
.uploadedThis(UploadDateField.MONTH) // uploaded this month
.sortBy(SortField.VIEW_COUNT); // results sorted by view count
// or
RequestSearchResult request = new RequestSearchResult("search query")
.select(
TypeField.VIDEO,
FeatureField.HD,
(...)
UploadDateField.MONTH)
.sortBy(SortField.VIEW_COUNT);
SearchResult result = downloader.search(request).data();
// Retrieve next page (about 20 items per page)
if (result.hasNext()) {
RequestSearchContinuation nextRequest = new RequestSearchContinuation(result);
SearchResult nextResult = downloader.getNextPage(nextRequest).data();
}
// result details
System.out.println(result.estimatedResults());
// result items
List<SearchResultItem> items = result.items();
List<SearchResultVideoDetails> videos = result.videos();
List<SearchResultChannelDetails> channels = result.channels();
List<SearchResultPlaylistDetails> playlists = result.playlists();
List<SearchResultShelfDetails> shelves = result.shelves();
// item cast
SearchResultItem item = result.items().get(0);
if (item.isChannel()) {
System.out.println(item.asChannel().author());
} else if (item.isShelf()) {
for(SearchResultVideoDetails video : item.asShelf().videos()) {
System.out.println(video.videoId());
}
}
// Base 64 (use another base 64 encoder for search parameters)
// Classic JDK and Android API >= 26
Base64Encoder.Default.set(bytes -> Base64.getUrlEncoder().encodeToString(bytes));
// or
JdkBase64Encoder.setAsDefault();
// Android API < 26
Base64Encoder.Default.set(bytes -> Base64.encodeToString(bytes, Base64.URL_SAFE)); |
@Grodou wow, thank a lot for contribution!
Can you submit Pull request so it would be easier to review your code? |
Grodou
added a commit
to Grodou/java-youtube-downloader
that referenced
this issue
May 15, 2022
resolves sealedtx#92
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature request: A simple search function to retrieve a list of video links/ videoIds (and maybe with their associated thumbnail/description).
The text was updated successfully, but these errors were encountered: