---
id: yts
name: YTS
description: "YTS is a Public torrent site specialising in HD movies of small size"
type: public
language: en-US
encoding: UTF-8
requestDelay: 2.5 # 2.5 requests per second (2 causes problems)
links:
  # if the primary domain changes then don't forget to update the details, download and poster replace args
  - https://yts.bz/
  # official domain list are at https://yifystatus.com/ and official proxies list are at https://ytsproxies.com/
  - https://yts.unblockninja.com/
  - https://yts.ninjaproxy1.com/
  - https://yts.proxyninja.org/
  - https://yts.proxyninja.net/
  - https://yts.torrentbay.st/
  - https://yts.torrentsbay.org/
legacylinks:
  - https://yts.am/ # redirects to .bz
  - https://yts.ag/ # redirects to .bz
  - https://yts.gg/ # redirects to .bz
  - https://yts.mx/
  - https://yts.mrunblock.bond/
  - https://yts.nocensor.cloud/
  - https://yts.unblockit.download/
  - https://yts.lt/ # redirects to .bz

caps:
  categorymappings:
    # note: the API does not support searching with categories, so these are dummy ones for torznab compatibility
    # we map these newznab cats with the returned quality value in the releases routine.
    - {id: 45, cat: Movies/HD, desc: "Movies/x264/720p"}
    - {id: 44, cat: Movies/HD, desc: "Movies/x264/1080p"}
    - {id: 46, cat: Movies/UHD, desc: "Movies/x264/2160p"}
    - {id: 47, cat: Movies/3D, desc: "Movies/x264/3D"}

  modes:
    search: [q]
    movie-search: [q, imdbid]

settings: []

search:
  paths:
    - path: api/v2/list_movies.json
      response:
        type: json

  inputs:
    query_term: "{{ if .Query.IMDBID }}{{ .Query.IMDBID }}{{ else }}{{ .Keywords }}{{ end }}"
    # without this the API sometimes returns nothing
    limit: 50
    sort_by: date_added
    order_by: desc
  keywordsfilters:
    # ignore ' (e.g. search for america's Next Top Model)
    - name: re_replace
      args: ["[^\\w]+", " "]

  rows:
    selector: data.movies
    attribute: torrents
    multiple: true
    # bug at YTS can return movie_count > 0 and no movie torrents #12598
    missingAttributeEqualsNoResults: true
    count:
      selector: data.movie_count

  fields:
    _quality:
      selector: quality
    category:
      selector: quality
      case:
        "720p": 45
        "1080p": 44
        "2160p": 46
        "3D": 47
        "*": 45
    _audio:
      selector: audio_channels
    _depth:
      selector: bit_depth
    _type:
      selector: type
    _codec:
      selector: video_codec
    year:
      selector: ..year
    title_default:
      selector: ..title
      filters:
        - name: append
          args: " ({{ .Result.year }})"
    title:
      selector: ..title_long
      optional: true
      default: "{{ .Result.title_default }}"
      filters:
        - name: replace
          args: [":", ""]
        - name: append
          args: " {{ .Result._quality }} {{ if eq .Result._type \"web\" }}WEBRip{{ else }}BRRip{{ end }} {{ if eq .Result._audio \"5.1\" }}5.1 {{ else }}{{ end }}{{ if eq .Result._depth \"10\" }}10Bit {{ else }}{{ end }}{{ .Result._codec }} -YTS"
    details:
      selector: ..url
      filters:
        - name: re_replace
          args: ["^https?:\\/\\/yts\\.(mx|lt|bz)\\/", "{{ .Config.sitelink }}"] # fix for 12494
    download:
      selector: url
      filters:
        - name: re_replace
          args: ["^https?:\\/\\/yts\\.(mx|lt|bz)\\/", "{{ .Config.sitelink }}"] # fix for 12494
    infohash:
      selector: hash
    poster:
      selector: ..large_cover_image
      filters:
        - name: re_replace
          args: ["^https?:\\/\\/yts\\.(mx|lt|bz)\\/", "{{ .Config.sitelink }}"] # fix for 12494
    imdbid:
      selector: ..imdb_code
    date:
      selector: date_uploaded_unix
    size:
      selector: size_bytes
    seeders:
      selector: seeds
    leechers:
      selector: peers
    downloadvolumefactor:
      text: 0
    uploadvolumefactor:
      text: 1
# json api v2
