simmcomm/content-api-client

内容API客户端


README

安装

composer require simmcomm/content-api-client

使用

require __DIR__ . '/vendor/autoload.php';

use Flowly\Content\ContentApiClient;

// $access and $secret are from Flowly app API keys module
$client = new ContentApiClient($access, $secret);

// it is possible to inject instance of
// Symfony\Contracts\HttpClient\HttpClientInterface as third parameter for
// custom initialization

// all request arguments and responses are mapped to their class
// mapping classes are located in namespaces Flowly\Content\Request and Flowly\Content\Response
// all methods in api client are accordingly typed (arguments and return value)

// public client api

// before sending any request, it is required to set auth alias:
$client->setAuthAlias('<user uuid or msisdn>');

// used on scene list view
$client->getScenes();

// single scene object 
$client->getScene();

// similar videos, based on scene id passed to this method
$client->getScenesSuggest();

// actors and categories lists
$client->getCategories();
$client->getActors();

// scene or actor can be star rated (1-5 scores)
$client->submitRating();

// used for portal landing page
$client->getScenesLanding();

Flowly内容API

根端点: 'https://api-content.flowly.com'.

GET /scenes

查询

  • categories: int[] = []
    • 类别ID过滤器,空(默认)表示无过滤器
  • categoriesExclude: int[] = []
    • 排除类别过滤器
  • actors: int[] = []
    • 演员ID过滤器,空(默认)表示无过滤器
  • orderBy: "added"|"duration"|"name"|"usage"|"rating" = "added"
    • 值是字符串枚举,错误的值将被忽略并使用默认值
      • "usage": 使用(点击)计数器
      • "rating": 用户评分(点赞/踩,星星;待定)
  • orderDir: "asc"|"desc" = null
    • 强制不同的排序顺序
    • 默认值
      • added: desc
      • duration: desc
      • name: asc
      • usage: desc
      • rating: desc
  • offset: int = 0
  • limit: int = 25
  • links: bool = false
    • 如果为true,则仅提供链接而不是对象
  • videoResolution: 360|480|720|1080 = null
    • 返回指定分辨率的视频链接
    • 值表示视频 高度
    • null表示最高可能分辨率
  • imageResolution: 360|480|640|720|1080 = null
    • 返回指定分辨率的图片链接
    • 值表示图片 宽度
    • null表示最高可能分辨率
    • 封面图片不受影响,它总是1024像素宽
  • licensor: int = null
    • 初始版本中只有afsc(数字标识符)
    • null表示任何
    • 允许的值将在将来扩展(随着新授权商的加入)
  • rating: string = ">=1.0 <=10.0"
    • 内容评分过滤器(见content_rating.md)
    • 使用类似于semver的字符串进行过滤
  • search: string = null
    • 搜索内容描述、类别和演员名称以查找搜索词
  • language: string = null
    • 字符串是ISO 639-1语言代码
    • 如果找到翻译,场景描述将使用该语言
    • 当前支持的语言有
      • de
      • fr
      • it

响应

成功(HTTP 200)

{
    // always `null` for this response type
    "error": null,
    // total number of results matching the query (pagination)
    "count": 6009,
    // count of rows in current response can be derived from scenes array
    "scenes": [
        {
            // internal id, uuid
            "id": "106b55e9-2fcb-482f-b8ca-00c16d21ab6f",
            // 1: straight, 2: gay, 3: ???
            "orientation": 1,
            // downloader friendly name, max 5 tokens from description
            "name": "gemma_massey_and_sammy_jayne.mp4",
            // is description needed???
            "description": "Gemma Massey And Sammy Jayne In Big Boob Lesbian Sex Session",
            // date added, ISO8601 or RFC3339 format
            "added": "2021-01-12T13:26:22+0000",
            // duration in seconds
            "duration": 1435,
            // video hits
            "hits": 175,
            // user rating (likes-dislikes or 1..5 stars)
            "rating": 3.4,
            // see content_rating.md
            "contentRating": 9.0,
            "cover": ".../cover.jpg",
            "thumbnails": [
                {
                    "url": ".../thumbnail.jpg",
                    "contentRating": "CS9.0"
                },
                // ...
            ],
            "categories": [
                {
                    "id": 46,
                    "name": "Lesbians",
                },
                {
                    "id": 10,
                    "name": "Blonde"
                },
                // ...
            ],
            "actors": [
                {
                    "id": 43,
                    "name": "SAMMY JAYNE",
                },
                {
                    "id": 64,
                    "name": "GEMMA MASSEY"
                },
                // ...
            ],
            "videos": {
                "preview": [
                    {
                        "url": ".../1080p/preview.mp4",
                        "contentRating": "CS9.0"
                    }
                    // multiple results are possible with different 
                    // contentRating
                ],
                "teaser": [
                    {
                        "url": ".../1080p/teaser.mp4",
                        "contentRating": "CS9.0"
                    }
                ],
                "full": [
                    {
                        "url": ".../1080p/full.mp4",
                        "contentRating": "CS9.0"
                    }
                ],
            },
        },
        {
            // ...
        }
    ]
}

如果 links==true

{
    "error": null,
    "count": 6009,
    "scenes": [
        "https://api.content-dn.com/scene/106b55e9-2fcb-482f-b8ca-00c16d21ab6f",
        // ...
    ]
}

错误(HTTP 4xx/5xx)

{
    "error": "Whoops...",
    "scenes": [
        // empty array
    ]
}

GET /scene/{id}

参数

  • id: string: 内容ID(uuid)

查询

  • language: string = null
    • 字符串是ISO 639-1语言代码
    • 如果找到翻译,场景描述将使用该语言
    • 当前支持的语言有
      • de
      • fr
      • it

响应

成功(HTTP 200)

{
    error: null,
    scene: {
        // single object as described in GET `/scenes`
    }
}

错误(HTTP 4xx/5xx)

{
    "error": "Whoops...",
    "scene": null
}

GET /scene/{id}/suggest

查找类似内容(按类别、演员等过滤)

参数

  • id: string: 内容ID(uuid)

查询

一些参数与/scenes中相同,因此应用相同的规则。

  • orderBy: "added"|"duration"|"name"|"usage"|"rating" = "added"
  • orderDir: "asc"|"desc" = null
  • links: bool = false
  • minCount: int = 0
    • 强制结果计数(添加随机结果以满足请求的计数)
    • 如果小于1,它将返回多达limit行的行数
  • limit: int = 25
    • 默认值将随时更改
  • language: string = null
    • 字符串是ISO 639-1语言代码
    • 当前支持的语言有
    • 如果找到翻译,场景描述将使用该语言
      • de
      • fr
      • it

响应

/scenes中所述。

GET /categories

响应

成功(HTTP 200)

{
    "error": null,
    "categories": [
        {
            "id": 123,
            "name": "Blonde"
        }
        // ...
    ]
}

错误(HTTP 4xx/5xx)

{
    "error": "Whoops...",
    "categories": []
}

GET /actors

响应

成功(HTTP 200)

{
    "error": null,
    "actors": [
        {
            "id": 123,
            "name": "GEMMA MASSEY"
        }
        // ...
    ]
}

错误(HTTP 4xx/5xx)

{
    "error": "Whoops...",
    "actors": []
}

POST /rating/{type}/{id}

参数

  • type: "scene"|"actor"
  • id: string: 内容ID(uuid)

cookies

  • flid: string
    • 必需
    • 防止垃圾邮件和评分操纵

正文(text/plain)

表示评分(在实现范围内,例如1-5)的整数

4

响应

成功(HTTP 200)

{
    "error": null
}

错误(HTTP 4xx/5xx)

{
    "error": "Something went wrong"
}
错误类型(4xx)

GET /scenes/landing

着陆页

查询

  • orderBy: "added"|"duration"|"name"|"usage"|"rating" = "added"
  • orderDir: "asc"|"desc" = null
  • links: bool = false
  • videoResolution: 360|480|720|1080|null = null
  • imageResolution: 360|480|640|720|1080|null = null
  • licensor: "afsc" = null
  • blockSize: int = 25
    • 每块的结果
  • blacklistedIncluded: bool = false
    • 包括从着陆页响应中黑名单的视频(需要simmcomm/content-api-common@^1.6.3
  • language: string = null
    • 字符串是ISO 639-1语言代码
    • 如果找到翻译,场景描述将使用该语言
    • 当前支持的语言有
      • de
      • fr
      • it

响应

成功(HTTP 200)

{
    // always `null` for this response type
    "error": null,
    "blocks": [
        {
            "description": "Most viewed",
            "scenes": [
                // scene objects
            ]
        },
        {
            "description": "Recently featured",
            "scenes": [
                // scene objects
            ]
        },
        // ...
    ]
}

如果 links==true

{
    // always `null` for this response type
    "error": null,
    "blocks": [
        {
            "description": "Most viewed",
            "scenes": [
                "https://api.content-dn.com/scene/106b55e9-2fcb-482f-b8ca-00c16d21ab6f",
                // ...
            ]
        },
        // ...
    ]
}

错误(HTTP 4xx/5xx)

{
    "error": "Whoops...",
    "blocks": [
        // always empty array for this response type
    ]
}