---
id: anthelion-api
replaces:
  - tehconnectionme
  - anthelion
name: Anthelion (API)
description: "Anthelion (ANT) is a Private Torrent Tracker for MOVIES"
language: en-US
type: private
encoding: UTF-8
# Status: https://ant.trackerstatus.info/
links:
  - https://anthelion.me/

caps:
  categorymappings:
    - {id: 2000, cat: Movies}
    - {id: 2030, cat: Movies/SD}
    - {id: 2040, cat: Movies/HD}
    - {id: 2045, cat: Movies/UHD}
    - {id: 2050, cat: Movies/BluRay}
    - {id: 2080, cat: Movies/WEB-DL}
    - {id: 8000, cat: Other}

  modes:
    search: [q]
    movie-search: [q, imdbid, tmdbid]
    # note: the api any supports movie search so there is no tv season/episode support.
    # not using year search because torznab adds it to the q= which results in &q=keyword+2022&year=2022 sent to api !?!

settings:
  - name: apikey
    type: text
    label: APIKey
  - name: info_key
    type: info
    label: About your API key
    default: "Find or Generate a new API Key by accessing your <a href=\"https://anthelion.me/\" target=\"_blank\">Anthelion</a> account <i>Settings</i> page and scrolling down to the <b>API Key</b> section.<br>Tick the <b>Search</b> and <b>Download</b> checkboxes and click the <b>save profile</b> button to generate the key."
  - name: info_activity
    type: info
    label: Account Inactivity
    default: "Activity is defined as actually using your account, including the snatch/grab/seeding of torrents. You are also required to sign-in to the web frontend of Anthelion at least once per 3mo (90 days) (Note, using autodl/ARR does not satisfy this)."

login:
  path: api.php
  method: get
  inputs:
    api_key: "{{ .Config.apikey }}"
  error:
    - selector: ":root:contains(\"Unrecognized key\")"
      message:
        text: "The API key was not accepted by {{ .Config.sitelink }}."
    - selector: ":root:contains(\"No API_KEY provided\")"
      message:
        text: "You did not enter an API key."

search:
  paths:
    # docs: https://anthelion.me/forums.php?action=viewthread&threadid=1026
    - path: api.php
      response:
        type: json

  inputs:
    api_key: "{{ .Config.apikey }}"
    o: json
    t: movie
    q: "{{ .Keywords }}"
    tmdb: "{{ .Query.TMDBID }}"
    imdb: "{{ .Query.IMDBIDShort }}"
    # category filtering is disabled since it seems to rely on the AND operator that prevents some releases to show on search.
    # cat: "{{ join .Categories \",\" }}"
    limit: 100
    offset: 0

  rows:
    selector: item
    count:
      selector: response.total

  fields:
    category:
      selector: category
      filters:
        - name: split
          args: [",", -1]
        - name: re_replace
          args: ["1\\d{5}", "2000"]
    year:
      selector: year
      optional: true
    _codec:
      selector: codec
    _container:
      selector: container
      filters:
        - name: toupper
    _media:
      selector: media
      filters:
        - name: replace
          args: ["WEB", "WEB-DL"]
    _resolution:
      selector: resolution
    _audioFormat:
      selector: audioFormat
    _subbing:
      selector: subbing
      optional: true
    _flags:
      selector: flags
      optional: true
      filters:
        - name: replace
          args: [",", " "]
    _language:
      selector: language
      optional: true
    _releaseGroup:
      selector: releaseGroup
      optional: true
      filters:
        - name: trim
    title_optional:
      selector: title
      filters:
        - name: htmldecode
        - name: append
          args: " {{ .Result.year }} {{ .Result._resolution }} {{ .Result._media }} {{ .Result._container }} {{ .Result._codec }} {{ .Result._audioFormat }}{{ if .Result._subbing }} Subs{{ else }}{{ end }}{{ if .Result._flags }} {{ .Result._flags }}{{ else }}{{ end }}{{ if .Result._language }} {{ .Result._language }}{{ else }}{{ end }}{{ if and (.Result._releaseGroup) (ne .Result._releaseGroup \"NULL\") }}-{{ .Result._releaseGroup }}{{ else }}{{ end }}"
        - name: replace
          args: ["M2TS H265", "M2TS HEVC"]
        - name: replace
          args: ["M2TS H264", "M2TS AVC"]
    details:
      selector: guid
    download:
      selector: link
      filters:
        - name: htmldecode
    infohash:
      selector: infohash
    imdbid:
      selector: imdb
    tmdbid:
      selector: tmdb
    genre:
      selector: tags
      filters:
        - name: replace
          args: [".", "_"]
    description:
      text: "{{ .Result.genre }}"
    files:
      selector: fileCount
    seeders:
      selector: seeders
    leechers:
      selector: leechers
    grabs:
      selector: grabs
    date:
      # 2022-08-07T20:56:06+0200
      selector: pubDate
    size:
      selector: size
    downloadvolumefactor:
      text: 1
    uploadvolumefactor:
      text: 1
    minimumratio:
      text: 1.0
    minimumseedtime:
      # 3 day (as seconds = 3 x 24 x 60 x 60)
      text: 259200
    _filename:
      selector: "files[0].name"
      filters:
        - name: htmldecode
      optional: true
    title:
      text: "{{ if and (eq .Result.files \"1\") (.Result._filename) }}{{ .Result._filename }}{{ else }}{{ .Result.title_optional }}{{ end }}"
# json api
