SNH48Live / KVM48

The Koudai48 VOD Manager
MIT License
10 stars 0 forks source link

Make perf mode <s>great</s> tolerable again in 600 #13

Open zmwangx opened 5 years ago

zmwangx commented 5 years ago

As I pointed out in the initial assessment, performance VODs lost the subtitle property and it is now impossible to e.g. tell birthday stages from regular stages just looking at the API. To prove my point, for https://live.48.cn/Index/invedio/club/1/id/2772:

$ curl -sS -H 'Content-Type: application/json' 'https://pocketapi.48.cn/live/api/v1/live/getOpenLiveList' --data "{'groupId': 10, 'record': true, 'next': 0}" | jq '.content.liveList[] | if .liveId == "324479006245982208" then . else empty end'
{
  "liveId": "324479006245982208",
  "title": "《重生计划》剧场公演",
  "coverPath": "/mediasource/live/1555670301617L2slw8tD09.jpg",
  "status": 4,
  "stime": "1555825500000",
  "teamList": [
    {
      "teamId": 1001,
      "groupId": 10,
      "teamName": "TEAM SII",
      "teamLogo": "/mediasource/teamLogo2/all/snh48_s2.png",
      "teamColor": "90CCEA"
    }
  ],
  "liveType": 0
}
$ curl -sS -H 'Content-Type: application/json' 'https://pocketapi.48.cn/live/api/v1/live/getOpenLiveOne' --data '{'liveId': 324479006245982208}' | jq .
{
  "status": 200,
  "success": true,
  "message": "OK",
  "content": {
    "liveId": "324479006245982208",
    "title": "《重生计划》剧场公演",
    "coverPath": "/mediasource/live/1555670301617L2slw8tD09.jpg",
    "roomId": "3869841",
    "status": 4,
    "playNum": "1930800",
    "stime": "1555825500000",
    "hasPraise": false,
    "praiseNum": "106",
    "dengPaiGiftId": "266592592682893312",
    "danMuInfo": {
      "giftId": "266592609913094144",
      "money": "10"
    },
    "type": 2,
    "liveJoiners": [],
    "playStreams": [
      {
        "streamName": "标清",
        "streamPath": "http://cychengyuan-vod.48.cn/snh/20190421/9999-gaoqing/324479006245982208.m3u8"
      },
      {
        "streamName": "高清",
        "streamPath": "http://cychengyuan-vod.48.cn/snh/20190421/9999-gaoqing/324479006245982208.m3u8"
      },
      {
        "streamName": "超清",
        "streamPath": "http://cychengyuan-vod.48.cn/snh/20190421/9999-gaoqing/324479006245982208.m3u8"
      }
    ],
    "module": {
      "resourceId": "324479006245982208",
      "resourceType": 1006,
      "resourceMd": ""
    },
    "mute": false,
    "liveType": 0
  }
}

The important differentiator here (莫寒生日公演) is only encoded in https://source.48.cn/mediasource/live/1555670301617L2slw8tD09.jpg. It seems all is lost.

That's not entirely the case though. If one takes a look at https://live.48.cn/Index/main/club/1, apparently VODs as well as future livestreams still carry subtitles. So, they have it, but they're not exposing it in the API or the app. Makes you wonder which idiot(s) thought this is a good idea.

Anyway, there are obviously two ways forward:

  1. Parse live.48.cn client-side;
  2. Parse live.48.cn server-side.

Client-side HTML scraping and parsing is too unwieldy and prone to breakage, especially in this case. Server-side scraping and parsing is technically superior (especially in terms of robustness and client performance), but I do need to introduce a server component (technically easy) and become a middle man. Since I already use my own server for update checks, this doesn't seem too morally problematic; keep in mind though that this does in principle open up a fair bit more data collection opportunities, but since perf mode granularity is limited to one group, hopefully this isn't too creepy. As always an opt out switch will be offered.

In conclusion, I'm going with the server-side solution. I might want to release the rough working version first though.

zmwangx commented 5 years ago

Server component is done. Just need to write the client now.

API is served at https://kvm48.momo0v0.club/api/graphql. Why not kvm48.snh48live.org? See https://github.com/SNH48Live/KVM48/tree/master/server#infrequently-asked-questions.