Skip to content

Architecture

Amila Welihinda edited this page Jun 27, 2016 · 6 revisions

Adapter Architecture

The project uses an Adapter architecture to simplify the retrieval of torrents and movies. Movies and torrents are fetched independently. Providers are responsible for 'providing' torrents, movies, and other data. Generally, these are API's for a website. Providers 'provide' content to Adapters, which conform the data returned from the providers and return a single array of results.

Convention

Naming: The filename and object/class name of a provider precedes its appropriate suffix:

For example, a PirateBay provider would be named PirateBayTorrentProvider or. PBTorrentProvider

Suffixes include TorrentProvider, MetadataProvider, and others.

Methods: A provider must return a promise in the expected format with a static method named provide

Torrents

A torrent provider should have a 'static' method that should return an array of objects:

ExampleTorrentProvider.provide(imdbId)

// Returns array of availabe torrents
// Preferrably, these should be ordered by best quality.
//
// [
//   {
//     quality: <string>, 1080p || 720p,
//     magnet: <string>
//     seeders: <number>
//     provder: <string>
//     leechers: <number>
//   },
//   ...
// ]

Extensive details that are specific to a provider can be provided as a second argument in the form of an object:

ExampleTorrentProvider.provide(imdbId, {
 searchQuery: 'harry potter and the half...', // Example of a custom query paramater
 ...otherCustomOptions
})

Metatdata Providers

ExampleTorrentProvider.provide(imdbId, {
 searchQuery: 'harry potter and the half...', // Example of a custom query paramater
 ...otherCustomOptions
})
Clone this wiki locally