---
id: hqmusic
name: HQMusic
description: "HQMusic is a Private Torrent Tracker for MUSIC"
language: en-US
type: private
encoding: UTF-8
links:
  - http://hqmusic.info/

caps:
  categorymappings:
    - {id: 1, cat: Audio, desc: "Music"}

  modes:
    search: [q]
    music-search: [q, album, artist, label, track, year, genre]

settings:
  - name: username
    type: text
    label: Username
  - name: password
    type: password
    label: Password
  - name: freeleech
    type: checkbox
    label: Search freeleech only
    default: false
  - name: sort
    type: select
    label: Sort requested from site
    default: time
    options:
      time: created
      seeders: seeders
      size: size
  - name: type
    type: select
    label: Order requested from site
    default: desc
    options:
      desc: desc
      asc: asc

login:
  path: login.php
  method: post
  inputs:
    username: "{{ .Config.username }}"
    password: "{{ .Config.password }}"
    keeplogged: 1
    login: "Log In"
  error:
    - selector: form#loginform > span.warning
  test:
    path: torrents.php

search:
  # http://hqmusic.info/ajax.php?artistname=John&groupname=Born&recordlabel=Sony&year=2012&filelist=Queen&freetorrent=&taglist=rock&tags_type=1&order_by=time&order_way=desc&filter_cat%5B1%5D=1&group_results=1&action=browse
  paths:
    - path: ajax.php
      response:
        type: json

  inputs:
    $raw: "{{ range .Categories }}filter_cat[{{.}}]=1&{{end}}"
    searchstr: "{{ .Keywords }}"
    artistname: "{{ if and (.Query.Artist) (ne .Query.Artist \"VA\") }}{{ .Query.Artist }}{{ else }}{{ end }}"
    groupname: "{{ if .Query.Album }}{{ .Query.Album }}{{ else }}{{ end }}"
    recordlabel: "{{ if .Query.Label }}{{ .Query.Label }}{{ else }}{{ end }}"
    year: "{{ if .Query.Year }}{{ .Query.Year }}{{ else }}{{ end }}"
    filelist: "{{ if .Query.Track }}{{ .Query.Track }}{{ else }}{{ end }}"
    freetorrent: "{{ if .Config.freeleech }}1{{ else }}{{ end }}"
    taglist: "{{ .Query.Genre }}"
    # 0 Any, 1 All
    tags_type: 1
    order_by: "{{ .Config.sort }}"
    order_way: "{{ .Config.type }}"
    group_results: 1
    action: browse

  rows:
    selector: response.results
    attribute: torrents
    multiple: true

  fields:
    _groupid:
      selector: ..groupId
    _torrentid:
      selector: torrentId
    category:
      text: 1
    artist:
      selector: ..artist
      filters:
        - name: htmldecode
    _groupName:
      selector: ..groupName
      filters:
        - name: htmldecode
    _releaseType:
      selector: ..releaseType
    album:
      optional: true
      text: "{{ if eq .Result._releaseType \"Album\" }}{{ .Result._groupName }}{{ else }}{{ end }}"
    track:
      optional: true
      text: "{{ if eq .Result._releaseType \"Single\" }}{{ .Result._groupName }}{{ else }}{{ end }}"
    year:
      optional: true
      selector: ..groupYear
      filters:
        - name: re_replace
          args: ["^0$", ""]
    _format:
      selector: format
    _encoding:
      selector: encoding
    _hasLog:
      selector: hasLog
    _logScore:
      selector: logScore
    _hasCue:
      selector: hasCue
    _media:
      selector: media
    year_remaster:
      selector: remasterYear
    title_remaster:
      optional: true
      selector: remasterTitle
    title:
      # John Mayer - Born And Raised [2012] [Album] FLAC / Lossless / Log (100%) / Cue / CD
      # Duy - I Go [2022] [Single] Other / Lossless / WEB
      text: "{{ .Result.artist }} - {{ .Result._groupName }} {{ if .Result.year }}[{{ .Result.year }}] {{ else }}{{ end }}[{{ .Result._releaseType }}] {{ .Result._format }} / {{ .Result._encoding }} {{ if eq .Result._hasLog \"True\" }}/ Log {{ else }}{{ end }}{{ if ne .Result._logScore \"0\" }}({{ .Result._logScore }}%){{ else }}{{ end }}{{ if eq .Result._hasCue \"True\" }} / Cue{{ else }}{{ end }} / {{ .Result._media }}{{ if ne .Result.year_remaster \"0\" }} / {{ .Result.year_remaster }}{{ else }}{{ end }}{{ if .Result.title_remaster }} {{ .Result.title_remaster }}{{ else }}{{ end }}"
    details:
      text: "torrents.php?id={{ .Result._groupid }}&torrentid={{ .Result._torrentid }}"
    download:
      text: "torrents.php?action=download&id={{ .Result._torrentid }}"
    poster:
      selector: ..cover
    date:
      selector: time
      filters:
        - name: append
          args: " +00:00" # GMT
        - name: dateparse
          args: "yyyy-MM-dd HH:mm:ss zzz"
    size:
      selector: size
    files:
      selector: fileCount
    grabs:
      selector: snatches
    seeders:
      selector: seeders
    leechers:
      selector: leechers
    genre:
      selector: ..tags
      filters:
        - name: replace
          args: [".", "_"]
    description:
      text: "{{ .Result.genre }}"
    _free:
      selector: isFreeleech
    _neutral:
      selector: isNeutralLeech
    _personal:
      selector: isPersonalFreeleech
    downloadvolumefactor_special:
      optional: true
      text: "{{ if eq .Result._neutral \"True\" }}0{{ else }}{{ end }}{{ if eq .Result._free \"True\" }}0{{ else }}{{ end }}{{ if eq .Result._personal \"True\" }}0{{ else }}{{ end }}"
    downloadvolumefactor:
      text: "{{ if .Result.downloadvolumefactor_special }}{{ .Result.downloadvolumefactor_special }}{{ else }}1{{ end }}"
    uploadvolumefactor:
      text: "{{ if eq .Result._neutral \"True\" }}0{{ else }}1{{ end }}"
    minimumratio:
      text: 0.6
    minimumseedtime:
      # 3 days (as seconds = 3 x 24 x 60 x 60)
      text: 259200
# JSON Gazelle
