Loading a Spider

Before writing a spider, make sure the App can find it. The api field in Site configuration decides how it runs.

Minimal Site configuration

{
  "key": "demo",
  "name": "Demo",
  "type": 3,
  "api": "./demo.js",
  "ext": {}
}

type is always 3; key must be unique and name is the display name.

Site.api
The api field in configuration
→csp_
Java JAR
Extends Spider inside the JAR
→.js
QuickJS
ES module default export
→.py
Python
Extends base.spider.Spider

Java JAR

Configuration value: api: "csp_Demo"

Put the class at com.github.catvod.spider.Demo and extend the abstract Spider; the root configuration must provide spider or the site's jar. Compile against catvod-api.jar as a compileOnly dependency; the TV root task :apiJar generates it at build/outputs/api/catvod-api.jar.

Python

Configuration value: api: "./demo.py"

Relative paths resolve from the configuration file location; export a Spider class extending base.spider.Spider.

QuickJS

Configuration value: api: "./demo.js"

JavaScript runs on QuickJS; relative paths resolve from the configuration file location. Use an ES module that default-exports an object or a function returning one.

Tip

Relative paths also work for ext and jar. See the configuration reference 路 Site for every field.

Next