Coder Social home page Coder Social logo

brightcoveos / java-mapi-wrapper Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 10.0 385 KB

This project provides a starting point for integrating the Brightcove Media API into your application. It provides simple ways to interact with the API.

Home Page: http://opensource.brightcove.com

Java 100.00%

java-mapi-wrapper's People

Contributors

bcmhansen avatar mcongrove avatar mister-ben avatar three4clavin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-mapi-wrapper's Issues

FindModifiedVideos call has incorrect documentation.

pageSize and pageNumber in FindModifiedVideos() from the ReadApi are documented as optional nullable values. If null is passed for either of these values, the API crashes.

pageSize may not be omitted, since if is compared to MAX_VIDEOS_PER_PAGE without checking whether it is null. Autoboxing a null Integer to a primitive int results in a NullPointerException.

Playlists: ClassCastException when JSONObject$Null is returned in response

This error occurs when FindPlaylistsByIds(..) is called with an id that no longer matches to any playlist (the Playlist has been deleted at Brightcove - or never existed).

In this case, JSONObject$Null is being returned within the result array and gets cast to JSONObject, which raises a ClassCastException:

public class Playlists extends ArrayList {
...

public Playlists(JSONObject jsonObj) throws JSONException {
    JSONArray jsonItems = jsonObj.getJSONArray("items");
    for(int itemIdx=0;itemIdx<jsonItems.length();itemIdx++){
                    JSONObject jsonItem = (JSONObject)jsonItems.get(itemIdx);
        Playlist playlist = new Playlist(jsonItem);
        add(playlist);
    }

    ...

}

    ...

}

Parsing the JSON response from "updateVideo" must be changed from "getString('result')" to "getJSONObject('result')" in order to comply with JSON spec

A valid response from BrightCove after executing "updateVideo" as an example:

{
    "result": {
        "id": ANY_NUMBER,
        "name": "video name",
        "adKeys": null,
        "shortDescription": "video description",
        "longDescription": "video long description",
        "creationDate": "1450813675021",
        "publishedDate": "1450813675021",
        "lastModifiedDate": "1450813675056",
        "linkURL": null,
        "linkText": null,
        "tags": [
            "tag1",
            "tag2"
        ],
        "videoStillURL": null,
        "thumbnailURL": null,
        "referenceId": null,
        "length": 0,
        "economics": "AD_SUPPORTED",
        "playsTotal": null,
        "playsTrailingWeek": null
    },
    "error": null,
    "id": null
}

the code part in the class WriteApi should be changed from

            Video result = null;
            if(response.getString("result") != null) {
                String jsonResult = response.getString("result");
                result = new Video(jsonResult);
            }

to

            Video result = null;
            if (response.has("result")
                    && response.getJSONObject("result") != null) {
                JSONObject jsonResult = response.getJSONObject("result");
                result = new Video(jsonResult);
            }

HTTP Error 417 on Write

Whenever I try to write (reading works just fine) to Brightcove using the java media api wrapper (v. 3.0.4) I get the following error:

200: Couldn't communicate with Media API - HTTP server returned error response code) Message: 'Response code from HTTP server: '417'

Http Error 417 is:
'If your client system is not a Web browser, the problem can only be resolved by examining what the client is trying to do then discussing with your ISP why the Web server fails the 'Expect' request sent by the client system.'

In order to solve this issue, I have overriden the WriteApi, in order to modify the executeCommand method to provide an addition param when doing the HTTP post:

HttpPost method = new HttpPost(uri);
method.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);:

The above solves my problem. Is there a chance of adding a way of providing custom Http Parameters when doing an http post to Brightcove?

UpdatePlaylist issue in WriteApi

Always get JSONException after call UpdatePlaylist from WriteApi. I have found that the WriteApi is trying to construct Playlist as

Playlist result = new Playlist(response);

However all playlist json attributes are under the "result" in response so I have modified the code to

Playlist result = new Playlist(response.getJSONObject("result"));

Now I am getting JSONException because of the "tagInclusionRule" attribute in response but I see that's the issue of brightcoveos/java-commons PlayList object where this is missing. According to http://support.brightcove.com/en/video-cloud/docs/media-api-objects-reference#Playlist it should be there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.