mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-01 07:27:35 +00:00
[AB-xxx] fixing youtube sometimes not returning videos even if specified
This commit is contained in:
@@ -26,7 +26,7 @@ public class YoutubeSearchServiceBean implements YoutubeSearchService {
|
||||
@Override
|
||||
public YoutubeVideo searchOneVideoForQuery(String query) {
|
||||
try {
|
||||
YouTube.Search.List search = youTube.search().list("id,snippet");
|
||||
YouTube.Search.List search = youTube.search().list("id");
|
||||
search.setQ(query);
|
||||
search.setType("video");
|
||||
search.setMaxResults(1L);
|
||||
@@ -35,6 +35,9 @@ public class YoutubeSearchServiceBean implements YoutubeSearchService {
|
||||
if(items.isEmpty()) {
|
||||
throw new YoutubeVideoNotFoundException();
|
||||
}
|
||||
if(items.stream().noneMatch(searchResult -> searchResult.getId().get("kind").equals("youtube#video"))) {
|
||||
throw new YoutubeVideoNotFoundException();
|
||||
}
|
||||
return youtubeVideoService.getVideoInfo(items.get(0).getId().getVideoId());
|
||||
} catch (IOException e) {
|
||||
throw new YoutubeAPIException(e);
|
||||
|
||||
Reference in New Issue
Block a user