Created
December 21, 2017 16:14
-
-
Save iomonad/6fa95105eae121b6b9df38c7c8696ec4 to your computer and use it in GitHub Desktop.
Random rtop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.trosa | |
import net.dean.jraw.http.OkHttpNetworkAdapter | |
import net.dean.jraw.http.UserAgent | |
import net.dean.jraw.models.Sorting | |
import net.dean.jraw.oauth.Credentials | |
import net.dean.jraw.oauth.OAuthHelper | |
import net.dean.jraw.pagination.Paginator | |
object AppEntryPoint { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
val oauthCredentials = Credentials.script( | |
"framboisier", | |
"SmokedSalmon75", | |
"uXpQw0vPZxfPnLjA", | |
"jTf4_Ec23fop_VCS1noFm8OkNzf+eEb0") | |
val userAgent = UserAgent("bot", | |
"you.sucks.boi", | |
"1.0.0", | |
"framboisier") | |
val client = OAuthHelper.automatic(OkHttpNetworkAdapter(userAgent), oauthCredentials) | |
val paginator = client.randomSubreddit().posts() | |
.limit(Paginator.DEFAULT_LIMIT) | |
.sorting(Sorting.HOT) | |
.build() | |
val linux = paginator.next() | |
linux.filter { !it.isNsfw && !it.domain.contains("^self")} | |
.forEach { | |
println(String.format("%s (/r/%s, %s points) - %s", | |
it.title, it.subreddit, it.score, it.url)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment