---
  site: ilcorsaroblu
  name: Il Corsaro Blu
  description: "Il Corsaro Blu is an ITALIAN Public site for TV / MOVIES / GENERAL"
  language: it-it
  type: public
  encoding: UTF-8
  links:
    - https://www.ilcorsaroblu.org/
  legacylinks:
    - http://ilcorsaroblu.org/
    - https://www.ilcorsaroblu.info/
  certificates:
    - e6dd93ef71f96d04559e2bee8cc8e6fd74957730 # incomplete CA chain

  caps:
    categorymappings:
      # Adult
       - {id: 12, cat: XXX, desc: "Adult"}
      # Applicazioni
       - {id: 5, cat: PC/Phone-Android, desc: "Android"}
      # Books
       - {id: 6, cat: Books, desc: "Books"}
      # Games
       - {id: 3, cat: Other, desc: "Games"}
      # Music
       - {id: 2, cat: Audio, desc: "Music"}
      # Movies
       - {id: 17, cat: Movies/SD, desc: "Movie BDRip"}
       - {id: 21, cat: Movies/Other, desc: "Movies - Films"}
       - {id: 11, cat: Movies/DVD, desc: "DVD-R"}
       - {id: 14, cat: Movies/HD, desc: "Movie 720p"}
       - {id: 13, cat: Movies/HD, desc: "Movie 1080p"}
       - {id: 15, cat: Movies/3D, desc: "Movie 3D"}
       - {id: 24, cat: TV/OTHER, desc: "TV Show Standard"}
       - {id: 19, cat: TV/HD, desc: "Tv Show 1080p"}
       - {id: 20, cat: TV/HD, desc: "Tv Show 720"}
      # Various
       - {id: 4, cat: Other, desc: "Other"}
       - {id: 7, cat: PC, desc: "Windows"}
       - {id: 8, cat: Other, desc: "Linux"}
       - {id: 9, cat: PC/Mac, desc: "Mac"}
       - {id: 23, cat: Other, desc: "Archive"}

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

  settings: []

  search:
    paths:
      - path: /index.php
    keywordsfilters:
      - name: re_replace
        args: ["S[0-9]{2}([^E]|$)", ""] # remove season tag without episode (search doesn't support it)
      - name: diacritics
        args: replace
      # most ITA TV torrents are in XXxYY format, so we search without S/E prefixes and filter later
      - name: re_replace
        args: ["S0?(\\d{1,2})", " $1 "]
      - name: re_replace
        args: ["E(\\d{2,3})", " $1 "]
    inputs:
      search: "{{ .Keywords }}"
      category: "{{range .Categories}}{{.}};{{end}}"
      page: torrents
      active: 0
    rows:
      selector: div.b-content > table > tbody > tr > td > table.lista > tbody > tr:has(a[href^="index.php?page=torrents&category="])
    fields:
      title:
        selector: td:nth-child(2) > a
        # normalize to SXXEYY format
        filters:
          - name: re_replace # replace special characters with " " (space)
            args: ["[^a-zA-Z0-9]|\\.", " "]
          # normalize to SXXEYY format
          - name: re_replace
            args: ["(\\d{2})x(\\d{2})", "S$1E$2"]
          - name: re_replace
            args: ["(\\d{1})x(\\d{2})", "S0$1E$2"]
          - name: re_replace #Stagione X --> S0X
            args: ["Stagione (\\d{0,1}\\s)", "S0$1"]
          - name: re_replace #Stagione XX --> SXX
            args: ["Stagione (\\d{2}\\s)", "S$1"]
          - name: re_replace #/ Episodio [YY-YY --> EYY-YY
            args: ["(\\s\\/\\sEpisodio|\\s\\/\\sEpisodi|\\sEpisodio|\\s\\|\\sEpisodio|\\sEpisodi)\\s\\[", "E"]
          - name: re_replace #/ Completa [episodi  YY-YY --> EYY-YY
            args: ["(\\s\\/\\sCompleta\\s\\[episodi\\s)", "E"]
          - name: re_replace #remove  di YY] | remove /YY]
            args: ["(\\sdi\\s\\d{1,2}|\\/\\d{1,2})\\]", " "]
          - name: re_replace #remove various
            args: ["(Serie completa|Completa|\\[in pausa\\])", ""]
          # fine prova
      download: # handle torrents with normal torrent file download
        optional: true
        selector: a[href^="download.php?id="]
        attribute: href
        filters:
          - name: querystring
            args: id
          - name: toupper
          - name: prepend
            args: http://itorrents.org/torrent/
          - name: append
            args: ".torrent"
      _magnetfilename: # convert title to valid magnet filename
        text: "{{ .Result.title }}"
        filters:
          - name: validfilename
          - name: urlencode
      magnet: # generate magnet link from download link
        optional: true
        selector: a[href^="download.php?id="]
        attribute: href
        filters:
          - name: querystring
            args: id
          - name: prepend
            args: "magnet:?xt=urn:btih:"
          - name: append
            args: "&dn={{ .Result._magnetfilename }}.torrent"
          - name: append # add some well known public trackers
            args: "&tr=udp://tracker.openbittorrent.com:80/announce&tr=udp://tracker.opentrackr.org:1337/announce" 
      magnet: # in case a direct magnet link is provided use it
        optional: true
        selector: a[href^="magnet:?xt="]
        attribute: href
      category:
        selector: a[href^="index.php?page=torrents&category="]
        attribute: href
        filters:
          - name: querystring
            args: category
      details:
        selector: td:nth-child(2) a
        attribute: href
      banner:
        optional: true
        selector: td:nth-child(2) > a
        attribute: onmouseover
        filters:
          - name: regexp
            args: "src=(.+?) "
      size:
        selector: td:nth-child(9)
      date:
        selector: td:nth-child(5)
        filters:
          - name: dateparse
            args: "02/01/2006"
      grabs:
        selector: td:nth-child(8)
        filters:
          - name: replace
            args: ["---", "0"]
      seeders:
        selector: td:nth-child(6)
      leechers:
        selector: td:nth-child(7)
