We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of chapter support (also duration and thumbnail)
string ClipsBodyRequest(string clipId) { ••• s += ' durationSeconds'; ••• s += ' medium: thumbnailURL(width: 480, height: 272)'; ••• } string ChapterSelectButtonVideoBodyRequest(string vodId) { string hash = "8d2793384aac3773beab5e59bd5d6f585aedb923d292800119e03d40cd0f9b41"; string s = ""; s += '{'; s += ' "operationName":"VideoPlayer_ChapterSelectButtonVideo",'; s += ' "variables": {'; s += ' "includePrivate":false,'; s += ' "videoID": "' + vodId + '"'; s += ' },'; s += ' "extensions": {'; s += ' "persistedQuery": {'; s += ' "version": 1,'; s += ' "sha256Hash": "' + hash + '"'; s += ' }'; s += ' }'; s += '}'; return s; } array<dictionary> GetChaptersFromVodId(string vodId) { array<dictionary> chapters; string body = ChapterSelectButtonVideoBodyRequest(vodId); JsonValue momentArray = SendGraphQLRequest(body)["video"]["moments"]["edges"]; int startPrev = -1; if (momentArray.isArray()) { for (int k = 0; k < momentArray.size(); k++) { JsonValue moment = momentArray[k]["node"]; if (!moment.isObject()) continue; string title = moment["description"].asString(); if (title.isEmpty()) continue; int start = moment["positionMilliseconds"].asInt(); int len = moment["durationMilliseconds"].asInt(); if (chapters.empty()) { if (start < 120000) start = 0; } if (len < 120000) { // ignore chapters less than two minutes, most likely they were added by mistake if (startPrev == -1) startPrev = start; continue; } if (startPrev != -1) { start = startPrev; startPrev = -1; } dictionary item; item["title"] = title; item["time"] = formatInt(start); chapters.insertLast(item); } } return chapters; } string ClipsParse(const string &in path, dictionary &MetaData, array<dictionary> &QualityList, const string &in headerClientId) { ••• int duration = clipRoot["durationSeconds"].asInt() * 1000; string thumbnail = clipRoot["medium"].asString(); ••• MetaData["duration"] = duration; MetaData["thumbnail"] = thumbnail; ••• } int parseDuration(const string &in str) { // 48h60m60s if (!str.isEmpty()) return 0; int duration = 0; string hours; string mins; string secs; uint p = 0; for (uint k = 0; k < str.length(); k++) { uint8 char = str[k]; if ((char < "0"[0]) || (char > "9"[0])) { if (char == "h"[0]) { duration += parseInt(str.substr(p, k - p)) * 60 * 60; } else if (char == "m"[0]) { duration += parseInt(str.substr(p, k - p)) * 60; } else if (char == "s"[0]) { duration += parseInt(str.substr(p, k - p)); } p = k + 1; } } return duration; } string PlayitemParse(const string &in path, dictionary &MetaData, array<dictionary> &QualityList) { ••• int duration; string thumbnail; ••• if (stream.isArray()) { ••• duration = parseDuration(item["duration"].asString()) * 1000; thumbnail = item["thumbnail_url"].asString(); thumbnail.replace("%{width}x%{height}", "480x272"); thumbnail.replace("{width}x{height}", "480x272"); ••• } else if (stream.isObject()) { ••• MetaData["duration"] = duration; MetaData["thumbnail"] = thumbnail; MetaData["chapter"] = GetChaptersFromVodId(vodId); ••• }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Implementation of chapter support (also duration and thumbnail)
The text was updated successfully, but these errors were encountered: