studionow / pybrightcove

Python Implementation of the Brightcove Backend Integration API
http://help.brightcove.com/developer/docs/mediaapi/media-API.cfm
MIT License
29 stars 28 forks source link

Handle PENDING itemStatus #40

Open jantman opened 10 years ago

jantman commented 10 years ago

Despite what the Media API Reference says, today we just started seeing a "PENDING" value for ItemState. This causes a pybrightcove error:

File "/app/lib/python2.6/site-packages/pybrightcove/connection.py", line 295, in item_lister **kwargs) File "/app/lib/python2.6/site-packages/pybrightcove/connection.py", line 273, in get_list _connection=self) File "/app/lib/python2.6/site-packages/pybrightcove/connection.py", line 356, in init self.items.append(item_class(data=item, _connection=_connection)) File "/app/lib/python2.6/site-packages/pybrightcove/video.py", line 296, in init self._load(data) File "/app/lib/python2.6/site-packages/pybrightcove/video.py", line 436, in _load self.item_state = data.get('itemState', None) File "/app/lib/python2.6/site-packages/pybrightcove/video.py", line 473, in setattr raise exceptions.PyBrightcoveError(msg) PyBrightcoveError: Video.item_state must be either ItemStateEnum.ACTIVE or ItemStateEnum.INACTIVE or ItemStateEnum.DELETED

Working with Brightcove to see how this undocumented value is coming back in API calls, and whether they'll update the docs.

jantman commented 10 years ago

Here's a slightly anonymized version of the JSON element in the pybrightcove API response to the find_modified_videos call. This was taken directly off-the-wire using Wireshark:

    {
        "creationDate": "1370282946041",
        "economics": "AD_SUPPORTED",
        "endDate": null,
        "id": <integer here>,
        "itemState": "PENDING",
        "lastModifiedDate": "1370282946244",
        "length": 120000,
        "linkText": null,
        "linkURL": null,
        "longDescription": "Long string here",
        "name": "Shorter string here",
        "playsTotal": null,
        "playsTrailingWeek": null,
        "publishedDate": null,
        "referenceId": "numbers",
        "renditions": [],
        "shortDescription": "long string here",
        "tags": [],
        "thumbnailURL": "http://pthumbnails.5min.com/foo",
        "videoStillURL": "http://pthumbnails.5min.com/foo"
    },
jantman commented 10 years ago

Sometime in the last ~24 hours the Media API Reference (http://docs.brightcove.com/en/video-cloud/media/reference.html) was updated to include the Pending ItemStateEnum value.