---
  site: torviet
  name: TorViet
  description: "Tor Viet (HDVNBits) is a VIETNAMESE Private Torrent Tracker for HD MOVIES / TV / GENERAL"
  language: vi-vn
  type: private
  encoding: UTF-8
  links:
    - http://torviet.com

  caps:
    categorymappings:
      - {id: 1, cat: Console, desc: "Game"}
      - {id: 7, cat: PC/Games, desc: "PC"}
      - {id: 133, cat: PC/Phone-Other, desc: "Handheld"}
      - {id: 132, cat: Console, desc: "Console"}

      - {id: 2, cat: Movies, desc: "Movie"}
      - {id: 23, cat: Movies/HD, desc: "mHD"}
      - {id: 24, cat: Movies/SD, desc: "SD"}
      - {id: 124, cat: Movies/HD, desc: "720p"}
      - {id: 125, cat: Movies/HD, desc: "1080p"}
      - {id: 127, cat: Movies/BluRay, desc: "Blu-ray"}

      - {id: 3, cat: TV, desc: "TV"}
      - {id: 128, cat: TV/HD, desc: "HD"}
      - {id: 129, cat: TV/SD, desc: "SD"}

      - {id: 4, cat: PC, desc: "Software"}
      - {id: 76, cat: PC/0day, desc: "Windows"}
      - {id: 77, cat: PC/Mac, desc: "MAC"}
      - {id: 78, cat: PC, desc: "Linux"}
      - {id: 79, cat: PC/Phone-Other, desc: "Handheld"}

      - {id: 5, cat: Audio, desc: "Music"}
      - {id: 92, cat: Audio/Video, desc: "Music Video"}
      - {id: 126, cat: Audio/Lossless, desc: "Lossless"}
      - {id: 130, cat: Audio/MP3, desc: "Lossy"}
      - {id: 131, cat: Audio, desc: "Surround"}

      - {id: 6, cat: Other, desc: "Misc"}
      - {id: 112, cat: Books, desc: "Ebook"}
      - {id: 113, cat: Other, desc: "Training Video"}
      - {id: 117, cat: Audio/Audiobook, desc: "Audio book"}

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

  login:
    path: /takelogin.php
    method: post
    inputs:
      username: "{{ .Config.username }}"
      password: "{{ .Config.password }}"
    error:
      - selector: td.embedded:has(h2:contains("failed"))
    test:
      path: /torrents.php
      
  ratio:
    path: /torrents.php
    selector: table#info_block
    filters:
      - name: regexp
        args: "Ratio:\\s(.*?)\\s\\s"

  search:
    paths:
      - path: /torrents.php
    inputs:
      search: "{{if .Query.IMDBID}}{{ .Query.IMDBID }}{{else}}{{ .Keywords }}{{end}}"
      sltCategory: 0
      sltSubCategory: 0 # can't sepcify multiple categorys so we're useing all always
      sltGenre: 0
      incldead: 0
      spstate: 0
      inclbookmarked: 0
      search_area: "{{ if .Query.IMDBID }}4{{else}}0{{end}}"
      search_mode: 0

    rows:
      selector: div#idtorrent > table.torrents > tbody > tr:has(table.torrentname)
    fields:
      title:
        selector: a[class][title]
        attribute: title
      details:
        selector: a[class][title]
        attribute: href
      description:
        selector: td.embedded:has(a[title])
        remove: a[title]
      category: 
        selector: a[href^="/torrents.php?sltSubCategory="]
        attribute: href
        filters:
          - name: querystring
            args: sltSubCategory
      comments:
        selector: td:nth-child(3) a
        attribute: href
      download:
        selector: a[href^="/download.php?"]
        attribute: href
      size:
        selector: td:nth-child(5)
      seeders:
        selector: td:nth-child(6)
      leechers:
        selector: td:nth-child(7)
      date:
        selector: td:nth-child(4)
        filters:
          - name: append
            args: " ago"
      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"
