---
id: afun
name: AFUN
description: "AFUN is a CHINESE Private Torrent Tracker for MOVIES / TV / GENERAL"
language: zh-CN
type: private
encoding: UTF-8
links:
  - https://www.ptlover.cc/

caps:
  categorymappings:
    - {id: 407, cat: TV/Sport, desc: "Sports/赛事"}
    - {id: 414, cat: TV, desc: "TV Shows/综艺"}
    - {id: 408, cat: Audio, desc: "HQ Audio/HQ音频"}
    - {id: 409, cat: Other, desc: "Misc/其他"}
    - {id: 407, cat: TV/Sport, desc: "TV Sport/体育"}
    - {id: 406, cat: Audio/Video, desc: "Music Videos/MV"}
    - {id: 403, cat: TV, desc: "TV Talk Shows/脱口秀"}
    - {id: 402, cat: TV, desc: "TV Series/电视剧"}
    - {id: 405, cat: TV/Anime, desc: "Anime/动画"}
    - {id: 404, cat: TV/Documentary, desc: "Documentaries/纪录片"}
    - {id: 401, cat: Movies, desc: "Movies/电影"}

  modes:
    search: [q]
    tv-search: [q, season, ep, imdbid]
    movie-search: [q, imdbid]
    music-search: [q]

settings:
  - name: cookie
    type: text
    label: Cookie
  - name: info_cookie
    type: info_cookie
  - name: freeleech
    type: checkbox
    label: Search freeleech only
    default: false
  - name: sort
    type: select
    label: Sort requested from site
    default: 4
    options:
      4: created
      7: seeders
      5: size
      1: title
  - name: type
    type: select
    label: Order requested from site
    default: desc
    options:
      desc: desc
      asc: asc
  - name: info_tpp
    type: info
    label: Results Per Page
    default: For best results, change the <b>Torrents per page:</b> setting to <b>100</b> on your account profile.
  - name: info_activity
    type: info
    label: Account Inactivity
    default: "Cherish your user account. Inactive accounts will be deleted based on the following rules:<ol><li>Veteran User or above will never be deleted.</li><li>Elite User or above will never be deleted if parked (at User CP).</li><li>Parked accounts will be deleted if users have not logged in for more than 400 days in a row.</li><li>Unparked accounts will be deleted if users have not logged in for more than 150 days in a row.</li><li>Accounts with both uploaded and downloaded amount being 0 will be deleted if users have not logged in for more than 100 days in a row.</li></ol>"

login:
  # using cookie method because site regularly disables login page for certain events during the year
  method: cookie
  inputs:
    cookie: "{{ .Config.cookie }}"
  test:
    path: index.php
    selector: a[href="logout.php"]

search:
  paths:
    - path: torrents.php
  inputs:
    $raw: "{{ range .Categories }}cat{{.}}=1&{{end}}"
    # searching in description causes HTTP 500 so we will not support doubanid searching
    search: "{{ if .Query.IMDBID }}{{ .Query.IMDBID }}{{ else }}{{ .Keywords }}{{ end }}"
    # 0: include dead, 1: alive, 2: dead
    incldead: 0
    # 0 all, 1 normal, 2 free, 3 2x, 4 2xfree, 5 50%, 6 2x50%, 7 30%
    spstate: "{{ if .Config.freeleech }}2{{ else }}0{{ end }}"
    # 0: title, 1: description, 3: uploader, 4: imdburl
    search_area: "{{ if .Query.IMDBID }}4{{ else }}0{{ end }}"
    # 0: AND, 2: exact
    search_mode: 0
    sort: "{{ .Config.sort }}"
    type: "{{ .Config.type }}"
    # Support in NexusPHP so bots don't pollute trending searches:
    notnewword: 1

  rows:
    selector: table.torrents > tbody > tr:has(a[href^="download.php?id="])

  fields:
    category:
      selector: a[href^="?cat="]
      attribute: href
      filters:
        - name: querystring
          args: cat
    title_default:
      selector: a[href^="details.php?id="]
    title:
      selector: a[title][href^="details.php?id="]
      attribute: title
      optional: true
      default: "{{ .Result.title_default }}"
    details:
      selector: a[href^="details.php?id="]
      attribute: href
    download:
      selector: a[href^="download.php?id="]
      attribute: href
    poster:
      selector: img[data-src]
      attribute: data-src
    imdbid:
      # site currently only has a badge and rating, the id is not present. just in case a future update.
      selector: a[href*="imdb.com/title/tt"]
      attribute: href
    doubanid:
      # site currently only has a badge and rating, the id is not present. just in case a future update.
      selector: a[href*="movie.douban.com/subject/"]
      attribute: href
    date_elapsed:
      # time type: time elapsed (default)
      selector: td:nth-child(4) > span[title]
      attribute: title
      optional: true
      filters:
        - name: append
          args: " +08:00" # CST
        - name: dateparse
          args: "yyyy-MM-dd HH:mm:ss zzz"
    date_added:
      # time added
      selector: td:nth-child(4):not(:has(span))
      optional: true
      filters:
        - name: append
          args: " +08:00" # CST
        - name: dateparse
          args: "yyyy-MM-ddHH:mm:ss zzz"
    date:
      text: "{{ if or .Result.date_elapsed .Result.date_added }}{{ or .Result.date_elapsed .Result.date_added }}{{ else }}now{{ end }}"
    size:
      selector: td:nth-child(5)
    seeders:
      selector: td:nth-child(6)
    leechers:
      selector: td:nth-child(7)
    grabs:
      selector: td:nth-child(8)
    downloadvolumefactor:
      case:
        img.pro_free: 0
        img.pro_free2up: 0
        img.pro_50pctdown: 0.5
        img.pro_50pctdown2up: 0.5
        img.pro_30pctdown: 0.3
        "*": 1
    uploadvolumefactor:
      case:
        img.pro_50pctdown2up: 2
        img.pro_free2up: 2
        img.pro_2up: 2
        "*": 1
    description:
      selector: td:nth-child(2)
      remove: a, b, font, img, span
    minimumratio:
      text: 1.0
    minimumseedtime:
      # 2 days (as seconds = 2 x 24 x 60 x 60)
      text: 172800
# NexusPHP v1.9.0 2025-02-06
