{
  "apiVersion": 1,
  "identityFields": [],
  "id": "hanjutv",
  "name": "Hanjutv",
  "locales": {
    "zh-CN": {
      "name": "韩剧TV"
    }
  },
  "version": "0.5.1",
  "hosts": ["hxqapi.hiyun.tv", "hxqapi.zmdcq.com"],
  "search": {
    "inputs": ["q"],
    "steps": [
      {
        "type": "http",
        "request": {
          "method": "GET",
          "url": "'https://hxqapi.hiyun.tv/api/common/configs'",
          "headers": "($uid := 'DA000000000000000000'; $uidMd5 := $md5($uid); $signKey := $base64Encode($substring($uidMd5, 0, 16)); $signIv := $base64Encode($substring($uidMd5, 16, 16)); $ts := $now() * 1000; $installTs := $ts - 1209600000; $said := 'fb3597b87601d5a7'; $oa := '0123456789abcdef'; $payload := { 'emu': 0, 'ou': 0, 'it': $installTs, 'iit': $installTs, 'bs': 0, 'uid': $uid, 'pc': 0, 'tm': 81, 'd8m': '0,0,0,0,0,0,0,4', 'md': 'Redmi Note 12', 'maker': 'Xiaomi', 'osv': '14', 'br': 95, 'rpc': 0, 'scc': 2, 'plc': 6, 'toc': 19, 'tsc': 10, 'ts': $ts, 'pa': 1, 'crec': 0, 'nw': 2, 'px': '0', 'isp': '', 'ai': $said, 'oa': $oa, 'dpc': 0, 'dsc': 0, 'qpc': 0, 'apad': 0, 'pk': 'com.babycloud.hanju' }; $uk := $aesCbcEncrypt($uid, 'ZjM0OXdnaGhlNzg0dHF3aA==', 'ZDN3OGhmOTRmaWRrMzhsaw=='); $sign := $aesCbcEncrypt($string($payload), $signKey, $signIv); { 'app': 'hj', 'ch': 'xiaomi', 'said': $said, 'uk': $uk, 'vn': '6.8.2', 'sign': $sign, 'vc': 'a_8280', 'Accept-Encoding': 'gzip', 'Connection': 'Keep-Alive' })",
          "rewriteHeaders": {
            "User-Agent": "'HanjuTV/6.8.2 (Redmi Note 12; Android 14; Scale/2.00)'"
          }
        }
      },
      {
        "type": "http",
        "id": "search",
        "request": {
          "method": "GET",
          "url": "'https://hxqapi.hiyun.tv/api/search/s5'",
          "query": "{ 'k': q, 'srefer': 'search_input', 'type': '0', 'page': '1' }",
          "headers": "($uid := 'DA000000000000000000'; $uidMd5 := $md5($uid); $signKey := $base64Encode($substring($uidMd5, 0, 16)); $signIv := $base64Encode($substring($uidMd5, 16, 16)); $ts := $now() * 1000; $installTs := $ts - 1209600000; $said := 'fb3597b87601d5a7'; $oa := '0123456789abcdef'; $payload := { 'emu': 0, 'ou': 0, 'it': $installTs, 'iit': $installTs, 'bs': 0, 'uid': $uid, 'pc': 0, 'tm': 81, 'd8m': '0,0,0,0,0,0,0,4', 'md': 'Redmi Note 12', 'maker': 'Xiaomi', 'osv': '14', 'br': 95, 'rpc': 0, 'scc': 2, 'plc': 6, 'toc': 19, 'tsc': 10, 'ts': $ts, 'pa': 1, 'crec': 0, 'nw': 2, 'px': '0', 'isp': '', 'ai': $said, 'oa': $oa, 'dpc': 0, 'dsc': 0, 'qpc': 0, 'apad': 0, 'pk': 'com.babycloud.hanju' }; $uk := $aesCbcEncrypt($uid, 'ZjM0OXdnaGhlNzg0dHF3aA==', 'ZDN3OGhmOTRmaWRrMzhsaw=='); $sign := $aesCbcEncrypt($string($payload), $signKey, $signIv); { 'app': 'hj', 'ch': 'xiaomi', 'said': $said, 'uk': $uk, 'vn': '6.8.2', 'sign': $sign, 'vc': 'a_8280', 'Accept-Encoding': 'gzip', 'Connection': 'Keep-Alive' })",
          "rewriteHeaders": {
            "User-Agent": "'HanjuTV/6.8.2 (Redmi Note 12; Android 14; Scale/2.00)'"
          }
        }
      }
    ],
    "output": "($uid := 'DA000000000000000000'; $exists(search.data) and search.data != '' ? ($key := $exists(search.key) and search.key != '' ? search.key : $md5($uid & $string(search.ts)); $mix := $md5($key & '34F9Q53w/HJW8E6Q'); $aesKey := $base64Encode($substring($mix, 0, 16)); $aesIv := $base64Encode($substring($mix, 16, 16)); $raw := $aesCbcDecrypt(search.data, $aesKey, $aesIv, 'none'); $clean := $replace($trim($raw), /[\\u0000-\\u001f\\u007f-\\u009f]/, ''); $decoded := $jsonParse($clean); $list := $exists($decoded.seriesData.seriesList) ? $decoded.seriesData.seriesList : $decoded.seriesList; [$list.{ 'providerIds': { 'sid': $string(sid) }, 'indexedId': $string(sid), 'title': name, 'type': 'tvseries', 'typeDescription': '韩剧', 'imageUrl': $exists(image.thumb) ? image.thumb : '', 'episodeCount': 0, 'year': null }]) : [])"
  },
  "episodes": {
    "inputs": ["sid"],
    "steps": [
      {
        "type": "http",
        "id": "detail",
        "request": {
          "method": "GET",
          "url": "'https://hxqapi.hiyun.tv/api/series/detail'",
          "query": "{ 'sid': $string(sid) }",
          "headers": {
            "vc": "'a_8280'",
            "vn": "'6.8.2'",
            "ch": "'xiaomi'",
            "app": "'hj'",
            "Accept-Encoding": "'gzip'"
          },
          "rewriteHeaders": {
            "User-Agent": "'HanjuTV/6.8.2 (Redmi Note 12; Android 14; Scale/2.00)'"
          }
        }
      }
    ],
    "output": "($sidStr := $string(sid); [detail.playItems[$exists(pid)].{ 'providerIds': { 'sid': $sidStr, 'pid': $string(pid) }, 'indexedId': $string(pid), 'title': $exists(title) and title != '' ? title : ('第' & $string(serialNo) & '集'), 'episodeNumber': serialNo }])"
  },
  "danmaku": {
    "inputs": ["pid"],
    "steps": [
      {
        "type": "forEach",
        "id": "segments",
        "in": "$range(0, 240)",
        "as": "i",
        "throttleMs": 100,
        "request": {
          "method": "GET",
          "url": "'https://hxqapi.hiyun.tv/api/danmu/playItem/list'",
          "query": "{ 'pid': $string(pid), 'prevId': '0', 'fromAxis': $string(i * 60000), 'toAxis': $string((i + 1) * 60000), 'offset': '0' }",
          "headers": {
            "Content-Type": "'application/json'"
          },
          "rewriteHeaders": {
            "User-Agent": "'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'"
          }
        },
        "collect": "danmus",
        "breakOn": "$count($) = 0"
      }
    ],
    "output": "[segments.{ 'cid': $number(did), 'p': $string(t / 1000) & ',' & $string(tp = 2 ? 5 : (tp in [1,4,5,6] ? tp : 1)) & ',' & $string($number(sc)), 'm': con }]"
  }
}
