# AIOStreams Config → Self-Hosted Scraper Mapping

This maps the AIOStreams Tamtaro SEL v2.6.1 config (the "Recommended TorBox Essential" template) to equivalent implementation in a self-hosted Node.js scraper addon.

## Core Architecture Difference

| Aspect | AIOStreams | Self-Hosted Scraper |
|--------|-----------|---------------------|
| Source type | Aggregates OTHER Stremio addons | Directly scrapes torrent sites |
| Filtering | SEL (Stream Expression Language) — user-configurable expressions | Hard-coded filters in code, or configurable via JSON config |
| Dedup | Built-in deduplicator with 3 keys | Custom dedup module |
| Sort | Configurable sort chains per context type | Split sort (cached/uncached) in scoring module |
| Formatter | Custom template language with conditionals | `buildStreamName()` + `buildStreamDescription()` functions |
| Sync | Synced URLs for community-maintained rules | N/A — rules are code, updated in repo |

## Config Field Mapping

| AIOStreams Config Key | Self-Hosted Equivalent | Notes |
|-----------------------|----------------------|-------|
| `services[]` | `config.js` debrid section | Maps debrid provider credentials (RD/TB keys) |
| `presets[].type` | External addon fetcher in `src/services/externalAddonFetcher.js` | AIOStreams uses addon instances. Self-hosted scrapers can optionally mirror this for addons like Torrentio |
| `formatter.definitions.custom.name` | `buildStreamName()` in `src/core/streamFormatter.js` | Template language → JavaScript template literals |
| `formatter.definitions.custom.description` | `buildStreamDescription()` | Same pattern |
| `preferredQualities` | Quality labels in formatter | Ordered list of quality preferences |
| `preferredResolutions` | Resolution sort in `scoring.js` | Resolution priority for sorting |
| `excludedVisualTags` | `parseRelease()` reject patterns | 3D, H-SBS, AI tags |
| `sortCriteria.global` | Split sort in `scoring.js` | Cached-first, then quality/seeders |
| `deduplicator` | `src/core/smartDedup.js` | 3-key strategy: infoHash, filename, smart fingerprint |
| `seasonEpisodeMatching` | `src/core/metadataMatcher.js` | Strict S/E matching with tolerance |
| `yearMatching` | `src/core/metadataMatcher.js` | Year tolerance ±1, strict mode |
| `titleMatching` | `src/core/metadataMatcher.js` | Exact mode with similarity threshold |
| `excludedStreamExpressions` | Filtering in metadataMatcher + parseRelease | Bad 4K anime, upscaled 4K, DV-only, etc. |
| `rankedRegexPatterns` | Regex scoring in `scoring.js` | Vidhin's release group tier patterns |
| `preferredStreamTypes` | Type field in formatter | debrid > p2p > http |
| `preferredLanguages` | Language filter in description | English, Original, Dual Audio |
| `size` per resolution | Size limits in route | 4K: 0-100GB, etc. |

## SEL Expression → Code Mapping

| SEL Expression | Code Equivalent |
|----------------|-----------------|
| `cached(streams)` | `r.cachedProviders?.length > 0` |
| `resolution(streams, '2160p')` | `r.quality === '4K'` |
| `quality(streams, 'Bluray')` | `detectQualityLabel() === 'BluRay'` |
| `visualTag(streams, 'DV')` | `parsed.isDV` |
| `negate(source, target)` | `results.filter(r => !excludedSet.has(r))` |
| `merge(a, b)` | `[...a, ...b]` with dedup |
| `count(streams)` | `streams.length` |
| `seeders(streams)` | `r.seeders > threshold` |
| `language(streams, 'English')` | `parsed.languages.includes('ENG')` |

## Source: Tamtaro SEL v2.6.1 Template

- https://raw.githubusercontent.com/Tam-Taro/SEL-Filtering-and-Sorting/main/AIOStreams%20Templates/Tamtaro-Recommended-TorBox-Essential.json
- https://github.com/Tam-Taro/SEL-Filtering-and-Sorting
- https://docs.aiostreams.viren070.me/
- https://raw.githubusercontent.com/Vidhin05/Releases-Regex/main/English/regexes.json
