Retrieving all shows from all users on Wordpress Multisite

Aloha.

I am using Podlove in a Multisite Wordpress configuration… life would be tremendously easier if there was some way at the admin/parent/root level of the multisite… to be able to retrieve a list of every show created on the individual subdomains of the network… I am actually the user for every site… and I would like the Top Level domain to display a list of every show hosted on the subdomains of the pod love hosted multisites…

Mahalo nui loa!

I put the question out there and then, hopefully by the time I dig through all I can, there is an answer posted that gives me greater guidance.

Here is what I have for now:

I am getting the a Network object, but that looks to just be for created Templates.
I see all the top level ‘Podcasts’ for a users in the Admin’s Dashboard. So accessibility appears to be available.

What I want to be able to do is get granular show data for each of those Podcasts… meaning the Show data created via the Show Module.

everything is marked as private… how to I get past this as admin (/Podlove/get_podcast()):

object(Podlove\Template\Podcast)#120 (1) { [“podcast”:“Podlove\Template\Podcast”:private]=> object(Podlove\Model\Podcast)#1586 (2) { [“data”:“Podlove\Model\Podcast”:private]=> array(2) { [“limit_items”]=> int(-1) [“media_file_base_uri”]=> string(1) “/” } [“blog_id”:“Podlove\Model\Podcast”:private]=> int(1) } }

Hey,

There’s a feature explicitly for what you are trying to do: Network lists. You can find this in your WordPress network settings page.

Screenhot Firefox Developer Edition 2023-04-15 17.08.41@2x

There you can create a list and add all podcasts of your network. Then access the list via Podlove Template, for example network.lists({id: "example"}). See Network | Podlove Documentation for available template API.

Aloha. I appreciate your response.

I have two questions:

These network lists… are they manually created, I mean, does each Podcast and related shows have to be manually created, and then calling the network list by slug displays the list? I was kind of hoping for something more real time… that would query and bring back a response of shows that may have been created.

Which leads to the second question… I have spent the last 24 hours going through the PODLOVE REST API.

Is there a route and endpoint for shows? I am not seeing it. I get the Podcast object when I query /podlove/v2/podcasts and episodes when I /podlove/v2/episodes… but I can’t find a route for shows and I haven’t looked at the index listing by making a call to wp-json yet. There is no show docs listed in the API.

Which leads to another question. I had once before pulled up show info via the templates… but I lost that setup. I cannot remember how to pull a show object via PHP. If I remember correctly… I had to back into episode data and find related show info.

I created my own routes and endpoints because I thought I could pull up Podcast, shows and episodes in via PHP Podlove related calls. But I got stuck with only getting top level Podcast data with no clear way of getting Show information.

Any more detailed ways to get me back on track would be much appreciated.

Thx

Mokana

I pulled a full listing and there are no routes for getting show data via the API, so I will have to build one up.

The API docs are outdated related to how to pull up data for a specific episode.

The doc states this:

/podlove/v2/episodes/{id}/media

Where this is how it must be called:

podlove\v2\episodes(?P[\d]+).

There is no call into media as it is returned from the above call.

Circling back to getting Show data via PHP… any guidance is appreciated…

Template Tags:

Show

episode.show

As stated above… in the past… in order to get show information…I had to go through the Episode object and grab the show object.

When you create an Episode… and have the show module enable… at the bottom… you can select either the Default… Podcast No show assigned… or a show…

It seems to be that Shows are not attached to the Podcast… but only at the Episode level… Episodes either belong to the Podcast or to a Show and Shows can only belong to Episodes.

I was hoping a Podcast object would bring back a fully encapsulated object containing everything. It appears not to.

The Episode REST API does not bring back any show information whilst Template calls do…

So I will have to build up my own route and endpoint to bring back aggregated show data…

Yes, but the idea was that you add all podcasts of the network once and then you have a handy way of displaying them as a list. But that doesn’t work if you frequently add/remove podcasts in your network or, as it seems, you are actually interested in Shows.

That is correct. Shows were born as episode-metadata, that’s why you won’t find any convenient “give me a list of all shows” method / endpoint.

I do regret that we released the “Show” feature at all. We should have either gone all the way and support multiple podcasts per instance, or just insist on one per instance. Shows are a rather painful compromise.

If you’re comfortable in PHP, your best bet is the PHP template API, and likely some digging beyond it. (Nothing stops you from using the internal Podlove\Modules\Shows\Model\Show class etc. directly).

Aloha!

Just when I think I am getting close… ugh!

I really would appreciate anyone uncovering what I am missing.

I am getting the expected results in the form of an Array of Objects when I make this call:

$podcast = \Podlove\get_podcast();
$arrayOfObjects = $podcast->episodes(array("show" => $slug ));
return var_dump($arrayOfObjects);

I get an array comprised of the Episode Object and the Post Object. The object is filled with exactly what I expect. The issue is that I cannot access anything in object(Podlove\Template\Episode) but can access everything in the WP_Post Object. Actually can access one property, and that is the Audio file SLUG!

array(3) {
  [0]=>
  object(Podlove\Template\Episode)#1520 (2) {
    ["episode":"Podlove\Template\Episode":private]=>
    object(Podlove\Model\Episode)#1568 (4) {
      ["is_new":"Podlove\Model\Base":private]=>
      bool(false)
      ["data":"Podlove\Model\Base":private]=>
      array(19) {
        ["id"]=>
        string(1) "4"
        ["post_id"]=>
        string(2) "87"
        ["title"]=>
        string(16) "DDDDDDDDDDDDDDDD"
        ["subtitle"]=>
        NULL
        ["summary"]=>
        NULL
        ["number"]=>
        string(1) "3"
        ["type"]=>
        string(4) "full"
        ["enable"]=>
        NULL
        ["slug"]=>
        string(30) "StateOfPlay/StateOfPlayLeadIn3"

.
.
.
["post":"Podlove\Template\Episode":private]=>
    object(WP_Post)#1523 (24) {
      ["ID"]=>
      int(87)
      ["post_author"]=>
      string(1) "1"
      ["post_date"]=>
      string(19) "2023-04-29 12:30:15"
      ["post_date_gmt"]=>
      string(19) "2023-04-29 22:30:15"
      ["post_content"]=>
      string(0) ""
      ["post_title"]=>
      string(5) "SOP 3"

I do this:

foreach ($arrayOfObjects as $object) {
                //return var_dump($episode);
                $episode = $object->episode(); THIS ALWAYS RESULTS IN A NULL
                $post       = $object->post();       THIS ALWAYS WORKS AND I GET THE POST OBJECT
                $postID   = $post->ID;                WORKS AS EXPECTED!
                $title        =  $object->title(); It always returns null!!!
                $slug.      = $object->slug(); WORKS EVERY TIME! I get expected results!
}

In summary, I have full access to every property of the WP_Post Object. The only property that I have access to, or rather that returns a value, in the Podlove\Template\Episode Object is the Slug… it always comes back as expected.

Episode Object requires the Method Call… $object->slug(); whereas once I pull the WP_Post object with the method call… I can access the properties $postID = $post->ID;

With the Episode Object, it isn’t consistent. Why can’t I access all properties as I do the $object->slug() property.

Is this a CASTING issue? What am I missing?

Thx for any and all guidance here! I am pulling my hair.

I never did find an answer to the above conundrum…

I resorted to calling the static: $episode = Episode::find_one_by_property(‘post_id’, $id); which means I am working from the top, meaning getting the Wordpress Post ID and drilling down.

The above call returns a single object:

object(Podlove\Model\Episode)#718 (3) {
[“is_new”:“Podlove\Model\Base”:private]=>
bool(false)
[“data”:“Podlove\Model\Base”:private]=>
array(19) {
[“id”]=>
string(1) “2”
[“post_id”]=>
string(2) “76”
[“title”]=>
string(23) “BBBBBBBBBBBBBBBBBBBBBBB”
[“subtitle”]=>
string(9) “Making it”
[“summary”]=>
string(10) “Working it”
[“number”]=>
string(1) “1”
[“type”]=>
string(4) “full”
[“enable”]=>
NULL
[“slug”]=>
string(27) “WordsToSay/WordsToSayLeadIn”
[“duration”]=>
string(12) “00:02:35.716”
[“cover_art”]=>
NULL
[“chapters”]=>
string(2) "
"
[“recording_date”]=>
NULL
[“explicit”]=>
NULL
[“license_name”]=>
NULL
[“license_url”]=>
NULL
[“soundbite_start”]=>
NULL
[“soundbite_duration”]=>
NULL
[“soundbite_title”]=>
NULL
}
[“blog_id”:“Podlove\Model\Episode”:private]=>
int(2)
}

I then access the properties in the [“data”] array directory using:

$episode->id
$episode->title
$episode->slug
.
.
.
Only method call that works is $episode->title() whilst all others are fatal.

I am not going to go through every line of code, I will simply assume it is how the Base and Episode Classes are defining their sets of methods and accessors.

I simply found a solution that works.