Create service to retrieve youtube API videos + playlists
We need to create a service that accepts an api token as a secret and allows us to retrieve Youtube API data on request. We should make use of caching to reduce the number of calls to the YT API. We will need to make use of the Videos list and Playlist list API to retrieve this data. We will need to request the id,snippet,player
parts for each of the API calls. This should provide extremely similar data across both calls and give us the ability to do additional filters in the future.
The service will accept a configuration object that takes a map of channel names to their channel IDs. As some channels can't be looked up easily through the Channels API, this is the cleanest way to store the lookups for known content providers.
Example of expected config:
eclipse.media-provider.youtube.jakartaa=<some id>
eclipse.media-provider.youtube.eclipsefdn=<some id>
eclipse.media-provider.youtube.some_other_channel=<some id>
This API will need to do some pre-loading to pull in lists of videos that are available for each of the configured content creators' channels. This can be done by fetching the Channel list endpoint, specifying the channel ID from the configuration, and getting the ID of the 'uploads' playlist from the relatedPlaylists
section. We can then use that ID and use the PlaylistItems list endpoint to retrieve all of the videos for a channel.
The other playlist IDs in the channel list return will also be tracked to ensure that lookups for playlists are always for managed content creators and not any other channels. If a playlist is requested and it is not found in the cached list of playlists, the request is rejected with a 400 Bad Request response.
We can cache just the IDs of the videos rather than the whole object to save some space as we won't request a majority of videos uploaded to a channel. This can be compared against the requested content ID to ensure the request is for a managed property. If it isn't, then we reject the request with a 400 Bad Request response.