use of se.michaelthelin.spotify.model_objects.specification.Episode in project spotify-web-api-java by spotify-web-api-java.
the class GetEpisodeExample method getEpisode_Sync.
public static void getEpisode_Sync() {
try {
final Episode episode = getEpisodeRequest.execute();
System.out.println("Name: " + episode.getName());
} catch (IOException | SpotifyWebApiException | ParseException e) {
System.out.println("Error: " + e.getMessage());
}
}
use of se.michaelthelin.spotify.model_objects.specification.Episode in project aiode by robinfriedli.
the class SearchCommand method searchSpotifyEpisode.
private void searchSpotifyEpisode() throws Exception {
if (getCommandInput().isBlank()) {
throw new InvalidCommandException("No search term entered");
}
int limit = getArgumentValueWithTypeOrElse("select", Integer.class, 20);
Callable<List<Episode>> loadTrackCallable = () -> getSpotifyService().searchEpisode(getCommandInput(), argumentSet("own"), limit);
List<Episode> found;
if (argumentSet("own")) {
found = runWithLogin(loadTrackCallable);
} else {
found = runWithCredentials(loadTrackCallable);
}
if (!found.isEmpty()) {
EmbedBuilder embedBuilder = new EmbedBuilder();
Util.appendEmbedList(embedBuilder, found, episode -> episode.getName() + " - " + episode.getShow().getName() + " - " + episode.getShow().getPublisher(), "Episode - Show - Publisher");
sendMessage(embedBuilder);
} else {
throw new NoSpotifyResultsFoundException(String.format("No podcast episode found for '%s'", getCommandInput()));
}
}
use of se.michaelthelin.spotify.model_objects.specification.Episode in project aiode by robinfriedli.
the class AbstractPlayableLoadingCommand method loadSpotifyShow.
private void loadSpotifyShow(AudioManager audioManager) throws Exception {
int limit = getArgumentValueWithTypeOrElse("select", Integer.class, 20);
Callable<List<ShowSimplified>> albumLoadCallable = () -> getSpotifyService().searchShow(getCommandInput(), argumentSet("own"), limit);
List<ShowSimplified> shows;
if (argumentSet("own")) {
shows = runWithLogin(albumLoadCallable);
} else {
shows = runWithCredentials(albumLoadCallable);
}
if (shows.size() == 1) {
ShowSimplified show = shows.get(0);
List<Episode> episodes = runWithCredentials(() -> getSpotifyService().getShowEpisodes(show.getId()));
PlayableFactory playableFactory = audioManager.createPlayableFactory(getSpotifyService(), trackLoadingExecutor);
List<Playable> playables = playableFactory.createPlayables(shouldRedirectSpotify(), episodes);
handleResults(playables);
loadedShow = show;
} else if (shows.isEmpty()) {
throw new NoSpotifyResultsFoundException(String.format("No shows found for '%s'", getCommandInput()));
} else {
askQuestion(shows, ShowSimplified::getName, ShowSimplified::getPublisher);
}
}
use of se.michaelthelin.spotify.model_objects.specification.Episode in project aiode by robinfriedli.
the class AbstractPlayableLoadingCommand method loadSpotifyEpisode.
private void loadSpotifyEpisode(AudioManager audioManager) throws Exception {
int limit = getArgumentValueWithTypeOrElse("select", Integer.class, 20);
Callable<List<Episode>> loadTrackCallable = () -> getSpotifyService().searchEpisode(getCommandInput(), argumentSet("own"), limit);
List<Episode> found;
if (argumentSet("own")) {
found = runWithLogin(loadTrackCallable);
} else {
found = runWithCredentials(loadTrackCallable);
}
if (found.size() == 1) {
createPlayableForEpisode(found.get(0), audioManager);
} else if (found.isEmpty()) {
throw new NoSpotifyResultsFoundException(String.format("No Spotify episode found for '%s'", getCommandInput()));
} else {
askQuestion(found, episode -> String.format("%s by %s", episode.getName(), episode.getShow().getName()));
}
}
use of se.michaelthelin.spotify.model_objects.specification.Episode in project aiode by robinfriedli.
the class QueueCommand method getPlayablesForOption.
private List<Playable> getPlayablesForOption(Object chosenOption, PlayableFactory playableFactory) throws Exception {
if (chosenOption instanceof Track || chosenOption instanceof YouTubeVideo || chosenOption instanceof Episode) {
Playable track = playableFactory.createPlayable(shouldRedirectSpotify(), chosenOption);
loadedTrack = track;
return Collections.singletonList(track);
} else if (chosenOption instanceof PlaylistSimplified) {
PlaylistSimplified playlist = (PlaylistSimplified) chosenOption;
List<SpotifyTrack> tracks = runWithCredentials(() -> getSpotifyService().getPlaylistTracks(playlist));
List<Playable> playables = playableFactory.createPlayables(shouldRedirectSpotify(), tracks);
loadedSpotifyPlaylist = playlist;
return playables;
} else if (chosenOption instanceof YouTubePlaylist) {
YouTubePlaylist youTubePlaylist = (YouTubePlaylist) chosenOption;
List<Playable> playables = playableFactory.createPlayables(youTubePlaylist);
loadedYouTubePlaylist = youTubePlaylist;
return playables;
} else if (chosenOption instanceof AlbumSimplified) {
AlbumSimplified album = (AlbumSimplified) chosenOption;
List<Track> tracks = runWithCredentials(() -> getSpotifyService().getAlbumTracks(album.getId()));
List<Playable> playables = playableFactory.createPlayables(shouldRedirectSpotify(), tracks);
loadedAlbum = album;
return playables;
} else if (chosenOption instanceof AudioTrack) {
Playable playable = playableFactory.createPlayable(shouldRedirectSpotify(), chosenOption);
loadedAudioTrack = (AudioTrack) chosenOption;
return Collections.singletonList(playable);
} else if (chosenOption instanceof AudioPlaylist) {
List<Playable> playables = playableFactory.createPlayables(shouldRedirectSpotify(), chosenOption);
loadedAudioPlaylist = (AudioPlaylist) chosenOption;
return playables;
} else if (chosenOption instanceof ShowSimplified) {
ShowSimplified show = (ShowSimplified) chosenOption;
List<Episode> episodes = runWithCredentials(() -> getSpotifyService().getShowEpisodes(show.getId()));
List<Playable> playables = playableFactory.createPlayables(shouldRedirectSpotify(), episodes);
loadedShow = show;
return playables;
}
throw new UnsupportedOperationException("Unsupported chosen option type: " + chosenOption.getClass());
}
Aggregations