diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-05-17 01:16:02 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-05-17 01:16:02 +0000 |
commit | 673ba041104bad25c94d11294358f5fc3b2c3817 (patch) | |
tree | 70f340a9fccaaf6c46acd76eac75ae459ff1ad05 /app/src/main/java | |
parent | 6e64f79d21de23a94971a7902bffcc7fd79cd009 (diff) | |
download | infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.tar infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.tar.gz infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.tar.bz2 infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.tar.lz infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.tar.xz infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.tar.zst infinity-for-reddit-673ba041104bad25c94d11294358f5fc3b2c3817.zip |
Version 4.3.0. Fix video post parsing (v.redd.it).
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index 9df78a45..f3b09d5e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -217,16 +217,32 @@ public class ParsePost { } post.setPreviews(previews); } else { - //No preview link post - int postType = Post.NO_PREVIEW_LINK_TYPE; - post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, - authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, - spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); - if (data.isNull(JSONUtils.SELFTEXT_KEY)) { - post.setSelfText(""); + if (isVideo) { + //No preview video post + JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY); + int postType = Post.VIDEO_TYPE; + String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString(); + String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY); + + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, + authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, + nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + archived, locked, saved, isCrosspost); + + post.setVideoUrl(videoUrl); + post.setVideoDownloadUrl(videoDownloadUrl); } else { - post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim())); + //No preview link post + int postType = Post.NO_PREVIEW_LINK_TYPE; + post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, + authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, + postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + if (data.isNull(JSONUtils.SELFTEXT_KEY)) { + post.setSelfText(""); + } else { + post.setSelfText(Utils.modifyMarkdown(data.getString(JSONUtils.SELFTEXT_KEY).trim())); + } } } } |