OwnTube-tv / web-client

Portable video client for PeerTube in React Native
https://owntube-tv.github.io/web-client/
The Unlicense
3 stars 12 forks source link

Create a Service for providing video/category data #10

Closed ar9708 closed 5 months ago

ar9708 commented 7 months ago

From #3, we need a service that provides categories and video data per the format used in PeerTube.

Add data model representing a subset of a PeerTube video object:

{
  "id": number,
  "name": string,
  "category": object,
  "thumbnailPath": string,
}

A Category object looks like this if set:

{
  "id": 3,
  "label": "Vehicles"
}

Or if not mapped to a specific category, a Category object looks like this:

{
  "id": null,
  "label": "Unknown"
}

The public interface should look something like this:

class VideoService {

  private videos = [];

  // extracted from "category" info in private videos list
  public getVideoCategoryLabels(): Array[CategoryLabel]

  // relies on first getting category labels
  public getVideosForCategory(categoryLabel): Array[Video]
}

The React components will use VideoService.getVideoCategoryLabels() and VideoService.getVideosForCategory() to render their contents.

Acceptance criterion: