Conforming search query to Roku JSON format

I am trying to adapt my recipe files to read and parse my Roku JSON feed file. There are no categories in my feed. I have it divided into series/seasons/episodes as in the following example:

{
  "lastUpdated": "2023-06-30T11:55:24+00:00",
  "providerName": "Nation Extreme Wrestling",
  "language": "en-US",
  "series": [
    {
      "id": "db771e79bbcf433cb3b417865abf6cde",
      "title": "Nation Extreme Wrestling",
      "seasons": [
        {
          "seasonNumber": 1,
          "title": "NEW 1",
          "episodes": [
            {
              "id": "ead12e119ec74af78de702aee7131fe2",
              "title": "Travis Williams vs Judas Icarus",
              "content": {
                "dateAdded": "2023-06-19T14:26:56+00:00",
                "videos": [
                  {
                    "url": "https://d2n971lt6fos4i.cloudfront.net/NEW+1/Travis_Williams_vs_Judas_Icarus_(S1-EP1)/master.m3u8",
                    "quality": "FHD",
                    "videoType": "hls"
                  }
                ],
                "duration": 904,
                "language": "en-US"
              },
              "thumbnail": "https://d2n971lt6fos4i.cloudfront.net/NEW+1/Travis_Williams_vs_Judas_Icarus_(S1-EP1)/Travis+Williams+vs+Judas+Icarus+(S1-EP1).png",
              "episodeNumber": 1,
              "releaseDate": "2023-07-04",
              "shortDescription": "Golden Boy takes it to Judas Icarus",
              "longDescription": "These guys have been at it many times before, but tonight Travis is going to prove he is going to the top and he's one of the true players in the Pacific Northwest",
              "credits": [
                {
                  "name": "Travis Williams",
                  "role": "",
                  "birthDate": ""
                },
                {
                  "name": "Judas Icarus",
                  "role": "",
                  "birthDate": ""
                }
              ],
              "rating": {
                "rating": "TVPG",
                "ratingSource": "USA_PR"
              }
            },

This is how I have written the categories recipe:

{
  "cooker": "DynamicParser",
  "format": "json",
  "model": "com.amazon.android.model.content.ContentContainer",
  "translator": "ContentContainerTranslator",
  "modelType": "array",
  "query": "$..series[*]",
  "queryResultType": "[]$",
  "matchList": [
    "StringKey@mName"
  ],
  "keyDataType": "StringKey@keyDataPath"
}

This is how I have written the content recipe file:

{
  "cooker": "DynamicParser",
  "format": "json",
  "model": "com.amazon.android.model.content.Content",
  "translator": "ContentTranslator",
  "modelType": "array",
  "query": "$[?(@.series[0] in [$$par0$$])]",
  "matchList": [
    "seasons/episodes/title@mTitle",
    "seasons/episodes/id@mId",
    "seasons/episodes/longDescription@mDescription",
    "seasons/episodes/content/videos/url@mUrl",
    "seasons/episodes/thumbnail@mCardImageUrl",
    "seasons/episodes/thumbnail@mBackgroundImageUrl"
  ]
}

I am using the same JSON url I use for Roku so I know the urlFile is correct, but I keep getting service not available error on loading the app on my test device. Where am I going wrong? Is the syntax incorrect? Have I interpreted the JSON schema correctly? New to this, so hopefully it isn’t a glaring mistake. Looking for any suggestions to correct this.

Hi Gaalen,

Welcome to the Forums, and thank you for posting! Could you please specify, which Amazon SDK / service you are using – is it Amazon Creator by any chance? We need more details to be able to assist you better. Thanks!

1 Like

Hello,

Thanks for responding! I am using Android Studio (Iguana) to build the Fire TV app on the Fire App Builder template. Is that what you needed to know?

1 Like

Just out of curiosity, It looks like you’re using your series as categories. Is this the only way to do it? I’m translating a Roku feed on the fly and then really flattening the movies. I’m curious if there isn’t some kind of “Series” page which lists the Episodes example to look at.

However, I did do some debugging as I was translating the feed. I put a breakpoint in JsonParser.parseWithQuery() on the line that has “if (data == null || data.isEmpty()) {” (line 107 in my JsonParser.java. If you hover over the data, you can make sure the feed is coming in. Then I put a breakpoint on the last line where you return the result. First you can see if you have all of the categories (meaning you’ve created your category recipe correctly). Then if you let it run again until you get to the return statement, you’ll see if you’re parsing the content correctly. Mess around with that class, debugging and I bet you’ll get an idea of what’s happening.

There might be another way to do it, but I am new to this and ended up having to write some python code to translate the json feed to the accepted Amazon category format. Wasn’t very happy with having to do that, but I needed the channel up asap. I will probably look for a less constrictive solution on the next version update.

I will take that into consideration, thanks!