Giter VIP home page Giter VIP logo

pbs_media_manager_client's People

Contributors

acrosman avatar augustuswm avatar jesseves avatar tamw-wnet avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pbs_media_manager_client's Issues

Helper function to extract images and generate different sizes

Both WETA and SCETV need to be able to pull images from shows and episodes and ideally resize them using the PBS image handling service. For example see Latest Episodes section of: https://www.scetv.org/program/reel-south

It seems likely that others may find it useful to be able to do similar things so I figured before we generalize what I have for SCETV into the Drupal module we should check to see if it makes sense to add it to the main client library instead.

Basically I'm proposing adding a helper function that would take an asset with a image, and return a specific image profile. The current functions I use are in the form:
extract_image($data, $image_type, $width, $height) where $image_type are image profiles like Mezzanine
and
image_path($baseURL, $width, $height, $type = '') where $type is the image type itself like jpg.

Possible to Return Seasons that Only Contain Full Length Episodes?

Hey Tam,

Not sure if this is possible, but wanted to check.

I am trying to return only those seasons for a show that contain full length episodes.

For example, on this call:
$seasons=$client->get_show_seasons('adfb2f9d-f61e-4613-ac58-ab3bde582afb');

I get season 45, which only contains a preview. Not a full length episode.

I tired adding parameters such as

$seasons=$client->get_show_seasons('adfb2f9d-f61e-4613-ac58-ab3bde582afb', array('type'=>'full_length', 'platform_slug' => 'partnerplayer' ));

But it had no effect, which I wouldn't expect that it would.

I tried adding 'fetch-related', as well. And while that gave me assets, it still didn't define whether those are Full Length or not.

I thought, perhaps, I could cycle through each season and see if there was a full length episode in there and perform some logic:

foreach($seasons as $season){
$output=$client->get_season_episodes($season['id'], array('type'=>'full_length',  'platform_slug' => 'partnerplayer' ));
print_r($output);
}

But that still returned the episode that only had previews.

I did manage to create a query, but it was way too complex and took more than 20 seconds to run, where I cycled through each season, and each episode to see if there was a full length in there and then push that season and ID to an array to publish. But, I really need this to be under 2 seconds or so.

If you have any thoughts or ideas, I would appreciate hearing them. As always, thanks for your time.

Chet

Strict comparison in make_response_array() generates notices

In make_response_array(), the client checks the HTTP response to see if data is returned using a strict comparison to 0.

However, when an asset doesn't exist, the API returns false, not 0. This is generating undefined offset notices a few lines further down since the function continues to try to process the result even though no result exists.

Is there a reason for the strict comparison? Switching from

if (strpos($data[0], 'HTTP') === 0) {

to

if (strpos($data[0], 'HTTP') == 0) {

clears things up for me.

Need to be able to pass CURL_OPTION values to client

Mark at KUED noted a case where he's using the client via a proxy, but there's not a current means to pass the necessary CURL_OPTION flags to the client to make it work.

I propose to add an overall options array argument to the client constructor, and if that array includes a CURL_OPTIONS array apply those to the 'build_curl_handle()' function.

inconsistent response when no data is available

I didn't really know how else to title this issue, but here are the details:

Currently when asking the client for all Xs under Y (assets under franchise for example), if there are Xs it returns data as an array of objects. One for each X. Great!

...if there are no Xs, it returns Y's top level properties of meta, data, jsonapi, etc.

Perhaps this is expected behavior as written, but I feel it would be more intuitive to simply return an empty array if there are no Xs under Y. It's not an earth-shattering issue. Just something odd I noticed that might merit reexamination. This is otherwise a great client that has saved us a lot of time and headache!

Thanks, Paul Dmytrewycz (KET)

Has anyone been able to do a "tag" query for assets with tags?

Sorry for the hijacking of the issue queue. But, unfortunately, support questions at the PBS Producer Exchange seem to just be ignored.

Curious if anyone has successfully managed to query Media Manager for assets with the same "tag".

I have tried
assets/?tag=mytag
assets/?tags=mytag

And a whole bunch of others. There seems to be no documentation for querying tags over at:
https://docs.pbs.org/display/CDA/Media+Manager+API

I can view the tags that have been set, but can't seem to find the proper way to query/search for those that contain them.

Any help appreciated!

And as always, thank you!

Chet

Improved error handling

Right now, when the API returns a 404 (or really any other error) while searching for assets the error response gets suppressed in get_child_assets()

$result_data = array();
$raw_result = $this->get_child_items_of_type($parent_id, $parent_type, 'asset', $queryargs);
foreach ($raw_result as $result) {
  // only include the right asset_types
  if (!in_array($result['attributes']['object_type'], $asset_types)) {
    continue;
  }
...

I thought about just adding a detection for the error key provided in get_request() and having it return that element of the array at that point. But I realized that might have side effects to other code you might be using already, or cause other headaches I'm not thinking through, so I figured I'd stop and ask what your preferred approach to forwarding those errors would be?

Seems the two primary options would be to make sure error elements of the array bubble up to the caller or throw an exception at get_request() and let it get caught and handled further up the stack. I don't mind either way but I'd like to be able to tell the difference between and empty response (which I've seen the API provide when no data is found) and a true error.

Search Assets for a Particular Show

Sorry for leaving this here, but hoping maybe one of you have encountered this issue. I would post at PBS Digital Forums, but it seems like that is where questions go to die.

I am trying to develop a search of assets based on a show.

For example, show me all assets with Cincinnati in the title for Antiques Roadshow.

However, if I make a call to
https://media.services.pbs.org/api/v1/assets/search/?show-title=Antiques+Roadshow&asset-title=Cincinnati

It returns all assets in the system with Cincinnati in the title.

The docs state:
If searching using asset-title the endpoint will return all assets (clip, full_length, preview) with a title matching the passed asset-title argument. This argument can not be chained with other search arguments; also, it does not support requests chaining more asset-title arguments.

So, I feel I might be out of luck. The only thing I can think of doing is pulling in ALL the assets for the title first, and then cycling through to see if the show matches-- which seems insane.

Just wondering if anybody has another suggestion.

Thanks for any help!

$endpoint not defined in get_item_of_type()

I just pulled down the updated master, and I'm seeing an error in get_item_of_type() that wasn't there previously.

The query is built using the $query variable, but that never gets used. Instead the function ends with

return $this->get_request($endpoint . $querystring);

But $endpoint is never defined.

make_response_array errors on API failure

A call we are making to create_child fails with the below error. This calls to make_response_array which errors when trying to parse with an unset index error at:

$middle = explode(": ", $part, 2);
$myarray[trim($middle[0])] = trim($middle[1]);
HTTP/1.1 400 Bad Request
Server: nginx
Date: Sat, 24 Feb 2018 10:16:02 GMT
Content-Type: application\/json
Content-Length: 77
Connection: keep-alive
Allow: GET, POST, HEAD, OPTIONS
Vary: Accept
X-Frame-Options: SAMEORIGIN

{"errors":{"meta":{"ordinal":["Episode with this ordinal already exists."]}}}

Should make_response_array have a block similar to get_request that is checking for json-like bodies?

platform-slug default value and syntax

@augustuswm @acrosman also RE #10

we should agree on what to do as a default argument value for 'platform-slug'. I propose 'partnerplayer'. That should most closely mirror the most common usecase. I believe that we may be able to request multiple values for 'platform-slug', eg 'partnerplayer,bento' but I am waiting for confirmation. I am almost certain that the behavior of 'platform-slug' is inclusive, so that if something is cleared for both Partner Player and Roku, requesting 'partnerplayer' will return the asset.

response codes need to be updated

@augustuswm discovered that PBS changed their API response codes for update and create endpoints, but in an inconsistent manner. Given the inconsistencies and also to keep this working, we should check for any one of 200, 201, 202, 204 and accept any.

platform-slug for get_item_of_type potentially breaking change

@augustuswm @acrosman There's an announcement from Jenny Markley
http://digitalsupport.pbs.org/support/discussions/topics/12000014567
that "Franchises, shows, and asset objects that are not available on “All Platforms” will not be returned, unless a platform filter is applied (example /shows/<slug|id>/?platform-slug=partnerplayer)."

All of the 'get_show' etc calls are masks for get_item_of_type, which isn't setup to take extra params beyond 'private=true' to tell it to check against the /edit/ endpoint for unpublished assets.

We can either do a possibly breaking change, where we change the 3rd (optional) argument from 'true'/'false' that gets us the 'private' option to an array, where 'private' is one of the array members, or we make that options array a 4th argument and leave 'private' as the 3rd arg. Whichever choice we make would also carry to 'get_show', 'get_asset', etc.

I propose the latter choice (adding a 4th argument that is an options array) as being the most backwards compatible. It seems less elegant on the face of it, but the 'private=true' thing is changing the endpoint URL, while the options array would be changing the params passed.

The 4th argument would be optional of course.

handle the new Replace Asset functionality

PBS has just announced they'll soon add a feature where replacement video files on an already-published asset can be ingested, while leaving the currently-available asset file streamable until the re-ingest completes. It will be available for caption files as well.

https://docs.pbs.org/display/CDA/Update+Asset#UpdateAsset-ReplacingVideoandCaptionFiles

Should be quite useful for when corrections need to be made.

Specific availability date on PBS end hasn't been announced. It seems relatively easy to implement in the client.

@augustuswm FYI

Not sure why a call to an asset is returning an error.

This one is driving me slightly batty.
If I make a call to get the assets of 'Making of American Nutcracker':

$assets=$client->get_child_items_of_type('67a1e24f-0a99-498d-aed7-a4bfcfdb8d38', 'episode', 'asset', array('platform-slug' => 'partnerplayer'));

I get about 7 videos returned which all fit the query. (2 Preview Types and 5 Clip Types).

However, when I to pull detail on the asset:

The 'clips' returns an error with Not Found:
$episode=$client->get_asset('e260a2a6-9bd0-4d4a-89db-ef3caac42909');
$episode=$client->get_asset('88255325-fa52-4dfb-a485-b69b33af687e');

The 'previews' return just fine:
$episode=$client->get_asset('2dacc1ae-e25c-4c21-a4b0-27c5e4631d9f');

Other programs do not have this issue, clips, previews, full-length all return the correct response.

I have looked through the response from the get_child_of_type call, seeing if there is any kind of 'flag' or something that says these assets should not be pulled. But I don't see anything, as they are all available on the partner player.

To further making things strange, these additional clips don't even appear over on the video.pbs.org page:
http://www.pbs.org/show/making-new-american-nutcracker/

So I feel like I should be filtering them out, but not sure what query arg I should add.

Any help appreciated.

Is there a return_count parameter you are aware of?

Been through the docs, but can't seem to find the proper parameter for a return count. If, for example, I wish to only return 5 episodes, or 7 clips, etc.

I tried page-size, and page, but while page limited to 50, page-size had no effect.

Basically, if I want to return only the last 5 Full length episodes of a show:

$output = $client->get_list_data('/assets/', array('show-id'=>$cid,'type'=>'full_length', 'platform_slug' => 'partnerplayer', 'sort' =>'-premiered_on', 'page'=>1) );

Any help appreciated.

audience-scope helper function

@augustuswm @acrosman @jesseves PBS has done something irritating with their 'audience-scope' argument. In the documentation, it can be a comma-separated list aka audience-scope=national,local but in actual practice audience-scope has to be separate query elements, in an order eg audience-scope=national&audience-scope=local.

This is problematic for our 'queryargs' named array element strategy, because if you set an array with two elements that have the same key ('audience-scope'=>'local', 'audience-scope'=>'national', only one of them is gonna be preserved when we generate our query string.

I propose to build into the 'build_pbs_querystring' function logic to split up 'audience-scope'=> 'local,national' into separate elements in the querystring. Or we could wait for PBS to fix their stuff to follow their documentation.

thoughts?

Account for inconsistent CURL header labels

I was pulling my hair out trying to figure out why create_child() wasn't returning the pbs_content_id of my newly created Episode (with which I would then create a new Asset). Episode creation was successfull, but the call was returning null for the new Episode's pbs_content_id.

But only on some AWS instances!

Ultimately, thru a full day's worth of debugging, I figured it out. The CURL headers returned by PBS are not always capitalized! depending, I think, either on the CURL implementation or the PHP version. Your client uses the resultant CURL headers, specifically "Location", to parse out the new child's pbs_content_id. (Let's set aside the fact that burying the most important bit of information about a post result in the headers is pretty much THE most unhelpful way to do it; thanks PBS... )

You use regex to preg_match() the "Location" header from the full string of headers, but the regex is case-sensitive. Thus, a header of "location" is not matched like "Location".

I ended up writing a separate private function, mimicing what create_child() does, but using the following to parse the pbs_content_id out of the CURL headers:

foreach ( preg_split('/\r\n?/', $result) as $header ) {
if ( stripos($header, 'location') !== false ) {
$loc_array = explode('/', rtrim($header,'/'));
return end($loc_array);
}
}

It's slightly heavier than your single regex approach, but using stripos() makes it case-insensitive. (I lack the regex skills to modify your original regex to make it case-insensitive.)

I humbly ask that this change be made to the client, either making the current regex in create_child() case-insensitive or implementing my solution or a variation thereof.

Thanks!

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.