src/main/java/com/alibaba/intl/voddemo/controllers/VideosController.java
@RequestMapping("/videos")
    public ResponseEntity<List<Video>> findAllVideos() {
        LOGGER.debug("Finding the last 100 videos...");

        var client = new DefaultAcsClient(clientProfile);
        var request = new GetVideoListRequest();
        request.setPageSize(100);

        try {
            var response = client.getAcsResponse(request);
            if (response.getVideoList() == null || response.getVideoList().isEmpty()) {
                return ResponseEntity.ok(Collections.emptyList());
            }

            var videos = response.getVideoList().stream()
                    .map(video -> new Video(
                            video.getVideoId(),
                            video.getTitle(),
                            video.getDescription() == null ? "" : video.getDescription(),
                            video.getStatus(),
                            video.getDuration(),
                            video.getCreationTime(),
                            video.getCoverURL(),
                            video.getSnapshots()))
                    .collect(Collectors.toList());
            return ResponseEntity.ok(videos);
        } catch (ClientException e) {
            LOGGER.warn("Unable to find the 100 last videos: " + e.getMessage(), e);
            return ResponseEntity.badRequest().body(null);
        }
    }
/**
     * @return 100 last uploaded videos.
     */
@return 100 last uploaded videos.
@return 100 last uploaded videos .
@RequestMapping("/videos")
    public ResponseEntity<List<Video>> findAllVideos() {
        LOGGER.debug("Finding the last 100 videos...");
        var client = new DefaultAcsClient(clientProfile);
        var request = new GetVideoListRequest();
        request.setPageSize(100);
        try {
            var response = client.getAcsResponse(request);
            if (response.getVideoList() == null || response.getVideoList().isEmpty()) {
                return ResponseEntity.ok(Collections.emptyList());
            }
            var videos = response.getVideoList().stream()
                    .map(video -> new Video(
                            video.getVideoId(),
                            video.getTitle(),
                            video.getDescription() == null ? "" : video.getDescription(),
                            video.getStatus(),
                            video.getDuration(),
                            video.getCreationTime(),
                            video.getCoverURL(),
                            video.getSnapshots()))
                    .collect(Collectors.toList());
            return ResponseEntity.ok(videos);
        } catch (ClientException e) {
            LOGGER.warn("Unable to find the 100 last videos: " + e.getMessage(), e);
            return ResponseEntity.badRequest().body(null);
        }
    }
@ RequestMapping ( "/videos" ) public ResponseEntity < List < Video > > findAllVideos ( ) { LOGGER . debug ( "Finding the last 100 videos..." ) ; var client = new DefaultAcsClient ( clientProfile ) ; var request = new GetVideoListRequest ( ) ; request . setPageSize ( 100 ) ; try { var response = client . getAcsResponse ( request ) ; if ( response . getVideoList ( ) == null || response . getVideoList ( ) . isEmpty ( ) ) { return ResponseEntity . ok ( Collections . emptyList ( ) ) ; } var videos = response . getVideoList ( ) . stream ( ) . map ( video -> new Video ( video . getVideoId ( ) , video . getTitle ( ) , video . getDescription ( ) == null ? "" : video . getDescription ( ) , video . getStatus ( ) , video . getDuration ( ) , video . getCreationTime ( ) , video . getCoverURL ( ) , video . getSnapshots ( ) ) ) . collect ( Collectors . toList ( ) ) ; return ResponseEntity . ok ( videos ) ; } catch ( ClientException e ) { LOGGER . warn ( "Unable to find the 100 last videos: " + e . getMessage ( ) , e ) ; return ResponseEntity . badRequest ( ) . body ( null ) ; } }
@return 100 last uploaded videos.
@return 100 last uploaded videos .