1

I'm trying to upload a video to my own youtube account using the v3 api and the Java library. If I call this method, I will see a video permanently stuck at the "processing..." stage in my youtube account. An exception never reaches my catch blocks, and I've managed to upload the same videos by logging into youtube directly and by using the drive api (with somewhat similar code to what's listed below). What am I missing?

    public boolean saveToYoutube(File fileOrig) {

        YouTube service = new YouTube.Builder(httpTransport, jsonFactory, getCredential()).build();

        // Add extra information to the video before uploading.
        Video video = new Video();

        VideoStatus status = new VideoStatus();
        status.setPrivacyStatus("private"); //public, private
        video.setStatus(status);

        VideoSnippet snippet = new VideoSnippet();
        snippet.setTitle("test");
        snippet.setDescription("this is a test video");
            List<String> tags = new ArrayList<String>();
            tags.add("test");
            tags.add("example");
            tags.add("java");
            tags.add("YouTube Data API V3");
            tags.add("erase me");
            snippet.setTags(tags);
        video.setSnippet(snippet);

        try {
            InputStreamContent content = new InputStreamContent("video/avi", new FileInputStream(fileOrig));
            YouTube.Videos.Insert videoInsert = service.videos().insert("snippet,status", video, content);

            Video returnedVideo = videoInsert.execute();
            System.out.println("\n================== Returned Video ==================\n");
            System.out.println("  - Id: " + returnedVideo.getId());
            System.out.println("  - Title: " + returnedVideo.getSnippet().getTitle());
            System.out.println("  - Tags: " + returnedVideo.getSnippet().getTags());
            System.out.println("  - Privacy Status: " + returnedVideo.getStatus().getPrivacyStatus());
            System.out.println("  - Video Count: " + returnedVideo.getStatistics().getViewCount());
        } catch (GoogleJsonResponseException e) {
            System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                    + e.getDetails().getMessage());
            e.printStackTrace();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        return true;
    }

Note: I can see the correct title, tags, and privacy level of the video in my account.

Jag
  • 1,840
  • 1
  • 17
  • 25
  • I have this issue for .NET . If anyone knows how to solve it, please let us know. – user3255303 Apr 08 '14 at 22:23
  • Check out this SO question: http://stackoverflow.com/questions/18022444/youtube-api-3-upload-video-access-not-configured-android I believe the code you use is similar that shown in the question. Maybe it will be of use. – Jon G Jul 08 '14 at 15:41

0 Answers0