From 8ac5fa68fb5ee6c2d701dbcafc7b94a2cde9c25a Mon Sep 17 00:00:00 2001 From: Jonas Kalderstam Date: Tue, 4 Jun 2024 23:31:11 +0200 Subject: [PATCH] Fixed parsed width/height of iframes --- .../com/nononsenseapps/feeder/model/html/HtmlLinearizer.kt | 6 ++++-- .../nononsenseapps/feeder/model/html/HtmlLinearizerTest.kt | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nononsenseapps/feeder/model/html/HtmlLinearizer.kt b/app/src/main/java/com/nononsenseapps/feeder/model/html/HtmlLinearizer.kt index d7737df44..d3a31e45c 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/model/html/HtmlLinearizer.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/model/html/HtmlLinearizer.kt @@ -630,6 +630,8 @@ class HtmlLinearizer { } private fun ListBuilderScope.parseIframeVideo(element: Element) { + val width = element.attr("width").toIntOrNull() + val height = element.attr("height").toIntOrNull() getVideo(element.attr("abs:src").ifBlank { null })?.let { video -> add( LinearVideo( @@ -639,8 +641,8 @@ class HtmlLinearizer { uri = video.src, link = video.link, imageThumbnail = video.imageUrl, - widthPx = video.width, - heightPx = video.height, + widthPx = width ?: video.width, + heightPx = height ?: video.height, mimeType = null, ), ), diff --git a/app/src/test/java/com/nononsenseapps/feeder/model/html/HtmlLinearizerTest.kt b/app/src/test/java/com/nononsenseapps/feeder/model/html/HtmlLinearizerTest.kt index 3c9917262..b08153cbe 100644 --- a/app/src/test/java/com/nononsenseapps/feeder/model/html/HtmlLinearizerTest.kt +++ b/app/src/test/java/com/nononsenseapps/feeder/model/html/HtmlLinearizerTest.kt @@ -622,8 +622,8 @@ class HtmlLinearizerTest { "https://www.youtube.com/embed/x_m02bUxfvE?feature=oembed", "https://www.youtube.com/watch?v=x_m02bUxfvE", "http://img.youtube.com/vi/x_m02bUxfvE/hqdefault.jpg", - 480, - 360, + 1170, + 658, null, ), ),