src/main/java/zoot/tube/schedule/TaskScheduler.java
/**
     * Makes all Videos in a Playlist private.
     *
     * Stores the state of the Videos before changes.
     *
     * @param task the Task to use.
     * @param credential the Credential to use.
     */
Makes all Videos in a Playlist private.
Stores the state of the Videos before changes.

@param task the Task to use.
@param credential the Credential to use.
Makes all Videos in a Playlist private . Stores the state of the Videos before changes . @param task the Task to use . @param credential the Credential to use .
private void makeVideosInPlaylistPrivate(Task task, Credential credential) {
        System.out.println("Running Task ID: " + task.getID());
        System.out.println("Setting Videos in Playlist to private");
        SimpleYouTubeAPI youTubeAPI = new SimpleYouTubeAPI(credential);
        System.out.println("Getting the Playlist");
        Playlist playlist = youTubeAPI.getPlaylistByID(task.getRelevantID());
        System.out.println("Getting the PlaylistItems");
        List<PlaylistItem> playlistItems = youTubeAPI.getPlaylistItemsFromPlaylist(playlist);
        List<Video> videos = new ArrayList<>();
        List<VideoIdHolder> holders = new ArrayList<>();
        for (PlaylistItem playlistItem : playlistItems) {
            String videoId = playlistItem.getContentDetails().getVideoId();
            System.out.println("Getting Video ID: " + videoId);
            Video video = youTubeAPI.getVideoByID(videoId);
            videos.add(video);
            video.setEtag(null);
            holders.add(new VideoIdHolder(video.getId(), video.getStatus().getPrivacyStatus()));
        }
        System.out.println("Saving previous privacy statuses...");
        TaskIO.saveContentUnderTask(task, gson.toJson(holders));
        System.out.println("Making Videos Private...");
        for (Video video : videos) {
            System.out.println("Making Video Private ID: " + video.getId());
            youTubeAPI.updateVideoVisibility(video, PrivacyStatus.PRIVATE);
        }
    }
private void makeVideosInPlaylistPrivate ( Task task , Credential credential ) { System . out . println ( "Running Task ID: " + task . getID ( ) ) ; System . out . println ( "Setting Videos in Playlist to private" ) ; SimpleYouTubeAPI youTubeAPI = new SimpleYouTubeAPI ( credential ) ; System . out . println ( "Getting the Playlist" ) ; Playlist playlist = youTubeAPI . getPlaylistByID ( task . getRelevantID ( ) ) ; System . out . println ( "Getting the PlaylistItems" ) ; List < PlaylistItem > playlistItems = youTubeAPI . getPlaylistItemsFromPlaylist ( playlist ) ; List < Video > videos = new ArrayList < > ( ) ; List < VideoIdHolder > holders = new ArrayList < > ( ) ; for ( PlaylistItem playlistItem : playlistItems ) { String videoId = playlistItem . getContentDetails ( ) . getVideoId ( ) ; System . out . println ( "Getting Video ID: " + videoId ) ; Video video = youTubeAPI . getVideoByID ( videoId ) ; videos . add ( video ) ; video . setEtag ( null ) ; holders . add ( new VideoIdHolder ( video . getId ( ) , video . getStatus ( ) . getPrivacyStatus ( ) ) ) ; } System . out . println ( "Saving previous privacy statuses..." ) ; TaskIO . saveContentUnderTask ( task , gson . toJson ( holders ) ) ; System . out . println ( "Making Videos Private..." ) ; for ( Video video : videos ) { System . out . println ( "Making Video Private ID: " + video . getId ( ) ) ; youTubeAPI . updateVideoVisibility ( video , PrivacyStatus . PRIVATE ) ; } }
Makes all Videos in a Playlist private.
Makes all Videos in a Playlist private .
// Get the Videos from the PlaylistItems and get current privacy statuses.