diff options
author | Andrew Dolgov <[email protected]> | 2015-09-06 16:13:48 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-09-06 16:13:48 +0300 |
commit | 90cc311adb71440ada0b28d4a9e41a16d9deb531 (patch) | |
tree | 160a461d4daf0496fdd125c80d9a4efe7dbbcf9e /org.fox.ttrss/src/main/java | |
parent | 593542e6f418ffe3a2b69e400fae9a899a8fafdc (diff) |
do not crash on video elements w/o source
Diffstat (limited to 'org.fox.ttrss/src/main/java')
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java index fe875c87..19a02bd5 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java @@ -83,28 +83,37 @@ public class Article implements Parcelable { if (flavorImage != null) { - if ("video".equals(flavorImage.tagName().toLowerCase())) { - Element source = flavorImage.select("source").first(); - flavorStreamUri = source.attr("src"); + try { - flavorImageUri = flavorImage.attr("poster"); - } else if ("iframe".equals(flavorImage.tagName().toLowerCase())) { + if ("video".equals(flavorImage.tagName().toLowerCase())) { + Element source = flavorImage.select("source").first(); + flavorStreamUri = source.attr("src"); - String srcEmbed = flavorImage.attr("src"); + flavorImageUri = flavorImage.attr("poster"); + } else if ("iframe".equals(flavorImage.tagName().toLowerCase())) { - if (srcEmbed.length() > 0) { - Pattern pattern = Pattern.compile("/embed/([\\w-]+)"); - Matcher matcher = pattern.matcher(srcEmbed); + String srcEmbed = flavorImage.attr("src"); - if (matcher.find()) { - youtubeVid = matcher.group(1); + if (srcEmbed.length() > 0) { + Pattern pattern = Pattern.compile("/embed/([\\w-]+)"); + Matcher matcher = pattern.matcher(srcEmbed); - flavorImageUri = "https://img.youtube.com/vi/" + youtubeVid + "/mqdefault.jpg"; - flavorStreamUri = "https://youtu.be/" + youtubeVid; + if (matcher.find()) { + youtubeVid = matcher.group(1); + + flavorImageUri = "https://img.youtube.com/vi/" + youtubeVid + "/mqdefault.jpg"; + flavorStreamUri = "https://youtu.be/" + youtubeVid; + } } + } else { + flavorImageUri = flavorImage.attr("src"); + flavorStreamUri = null; } - } else { - flavorImageUri = flavorImage.attr("src"); + } catch (Exception e) { + e.printStackTrace(); + + flavorImage = null; + flavorImageUri = null; flavorStreamUri = null; } } |