感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Example Feeds and Recipes

The following are some example feeds and their corresponding recipes. Because the query syntax can be somewhat complex depending on your feed, these examples will help clarify how to target different elements.

XML Example 1: iTunes spec

This example shows a recipe configuration for a feed that conforms to the iTunes RSS tags specification.

Feed:

https://s3-us-west-1.amazonaws.com/devportal-reference-docs/fire-app-builder/feeds/feed1.xml

Category recipe:

{
  "cooker": "DynamicParser",
  "format": "xml",
  "model": "com.amazon.android.model.content.ContentContainer",
  "translator": "ContentContainerTranslator",
  "modelType": "array",
  "query": "/rss/channel/item//*[name()='itunes:category']",
  "queryResultType": "[]$",
  "matchList": [
    "#attributes/text@mName"
  ],
  "keyDataType":"#attributes/text@keyDataPath"
}

Contents recipe:

{
  "cooker": "DynamicParser",
  "format": "xml",
  "model": "com.amazon.android.model.content.Content",
  "translator": "ContentTranslator",
  "modelType": "array",
  "query": "//item[./*[name()='itunes:category'][@text='$$par0$$']]",
  "matchList": [
    "title/#text@mTitle",
    "guid/#text@mId",
    "description/#text@mDescription",
    "enclosure/#attributes/url@mUrl",
    "itunes:image/#attributes/href@mCardImageUrl",
    "itunes:image/#attributes/href@mBackgroundImageUrl"
  ]
}

BasicFileBasedUrlGeneratorConfig.json:

{
  "url_file": "urlFile_xmlfeed1.json"
}

urlFile_xmlfeed1.json

{
  "urls": [
    "https://s3-us-west-1.amazonaws.com/devportal-reference-docs/fire-app-builder/feeds/feed1.xml"
  ]
}

Navigator.java

...
public static final String NAVIGATOR_FILE = "Navigator_xmlfeed1.json";
...

Navigator_xmlfeed1.json

{
  "config": {
    "showRelatedContent": true,
    "useCategoryAsDefaultRelatedContent": true,
    "searchAlgo": "basic",
    "enableCEA608": false,
    "enableRecentRow": true,
    "maxNumberOfRecentItems": 5
  },
  "branding": {
    "globalTheme": "AppTheme",
    "lightFont" : "Roboto Light",
    "boldFont" : "Roboto Bold",
    "regularFont" : "Roboto Regular"
  },
  "globalRecipes": [
    {
      "categories": {
        "dataLoader": "recipes/xmlfeed1_DataLoaderRecipe0.json",
        "dynamicParser": "recipes/xmlfeed1_CategoriesRecipe.json"
      },
      "contents": {
        "dataLoader": "recipes/xmlfeed1_DataLoaderRecipe0.json",
        "dynamicParser": "recipes/xmlfeed1_ContentsRecipe.json"
      }
    }
  ],
  "graph": {
    "com.amazon.android.tv.tenfoot.ui.activities.SplashActivity": {
      "verifyScreenAccess": false,
      "verifyNetworkConnection": true,
      "onAction": "CONTENT_SPLASH_SCREEN"
    },
    "com.amazon.android.tv.tenfoot.ui.activities.ContentBrowseActivity": {
      "verifyScreenAccess": false,
      "verifyNetworkConnection": true,
      "onAction": "CONTENT_HOME_SCREEN"
    },
    "com.amazon.android.tv.tenfoot.ui.activities.ContentDetailsActivity": {
      "verifyScreenAccess": false,
      "verifyNetworkConnection": true,
      "onAction": "CONTENT_DETAILS_SCREEN"
    },
    "com.amazon.android.tv.tenfoot.ui.activities.ContentSearchActivity": {
      "verifyScreenAccess": false,
      "verifyNetworkConnection": true,
      "onAction": "CONTENT_SEARCH_SCREEN"
    },
    "com.amazon.android.uamp.ui.PlaybackActivity": {
      "verifyScreenAccess": false,
      "verifyNetworkConnection": true,
      "onAction": "CONTENT_RENDERER_SCREEN"
    }
  }
}

xmlfeed1_DataLoaderRecipe0.json

{
  "task": "load_data",
  "url_generator": {
    "url_index": "0"
  }
}