src/main/java/zoot/tube/schedule/TaskScheduler.java
/**
     * Reverts all Videos in a Playlist to their stored version.
     *
     * @param task the Task to use.
     * @param credential the Credential to use.
     */
Reverts all Videos in a Playlist to their stored version.
@param task the Task to use.
@param credential the Credential to use.
Reverts all Videos in a Playlist to their stored version . @param task the Task to use . @param credential the Credential to use .
private void revertVideosInPlaylist(Task task, Credential credential) {
        System.out.println("Running Task ID: " + task.getID());
        System.out.println("Reverting Videos to previous privacy status");
        SimpleYouTubeAPI youTubeAPI = new SimpleYouTubeAPI(credential);
        System.out.println("Loading previous privacy statuses...");
        String contentAsString = TaskIO.loadContentUnderTask(task);
        VideoIdHolder[] videoIdHolders = gson.fromJson(contentAsString, VideoIdHolder[].class);
        System.out.println("Getting Videos from YouTube");
        List<Video> videos = new ArrayList<>();
        for (VideoIdHolder holder : videoIdHolders) {
            Video video = youTubeAPI.getVideoByID(holder.getId());
            video.getStatus().setPrivacyStatus(holder.getPrivacyStatus());
            videos.add(video);
        }
        System.out.println("Reverting Videos to previous privacy...");
        for (Video video : videos) {
            System.out.println("Reverting: " + video.getId());
            youTubeAPI.updateVideoVisibility(video, video.getStatus().getPrivacyStatus());
        }
        System.out.println("Cleaning up task...");
        TaskIO.deleteContentUnderTask(task);
    }
private void revertVideosInPlaylist ( Task task , Credential credential ) { System . out . println ( "Running Task ID: " + task . getID ( ) ) ; System . out . println ( "Reverting Videos to previous privacy status" ) ; SimpleYouTubeAPI youTubeAPI = new SimpleYouTubeAPI ( credential ) ; System . out . println ( "Loading previous privacy statuses..." ) ; String contentAsString = TaskIO . loadContentUnderTask ( task ) ; VideoIdHolder [ ] videoIdHolders = gson . fromJson ( contentAsString , VideoIdHolder [ ] . class ) ; System . out . println ( "Getting Videos from YouTube" ) ; List < Video > videos = new ArrayList < > ( ) ; for ( VideoIdHolder holder : videoIdHolders ) { Video video = youTubeAPI . getVideoByID ( holder . getId ( ) ) ; video . getStatus ( ) . setPrivacyStatus ( holder . getPrivacyStatus ( ) ) ; videos . add ( video ) ; } System . out . println ( "Reverting Videos to previous privacy..." ) ; for ( Video video : videos ) { System . out . println ( "Reverting: " + video . getId ( ) ) ; youTubeAPI . updateVideoVisibility ( video , video . getStatus ( ) . getPrivacyStatus ( ) ) ; } System . out . println ( "Cleaning up task..." ) ; TaskIO . deleteContentUnderTask ( task ) ; }
Reverts all Videos in a Playlist to their stored version.
Reverts all Videos in a Playlist to their stored version .