2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Show video_timestamp progress line.

This commit is contained in:
John Preston
2025-01-24 20:21:59 +04:00
parent b618d1e56a
commit cb03d5a9d3
5 changed files with 107 additions and 1 deletions

View File

@@ -374,6 +374,28 @@ QString WebPageData::displayedSiteName() const {
: siteName;
}
TimeId WebPageData::extractVideoTimestamp() const {
const auto take = [&](const QStringList &list, int index) {
return (index >= 0 && index < list.size()) ? list[index] : QString();
};
const auto hashed = take(url.split('#'), 0);
const auto params = take(hashed.split('?'), 1);
const auto parts = params.split('&');
for (const auto &part : parts) {
if (part.startsWith(u"t="_q)) {
const auto value = part.mid(2);
const auto kExp = u"^(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?$"_q;
const auto m = QRegularExpression(kExp).match(value);
return m.hasMatch()
? (m.capturedView(1).toInt() * 3600
+ m.capturedView(2).toInt() * 60
+ m.capturedView(3).toInt())
: value.toInt();
}
}
return 0;
}
bool WebPageData::computeDefaultSmallMedia() const {
if (!collage.items.empty()) {
return false;