Skip to content
A dead simple OpenGraph tags parser for Kotlin
Kotlin
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows feat: Add github workflow Nov 2, 2019
.idea feat: Add parser implementation Nov 2, 2019
buildSrc feat: Add parser implementation Nov 2, 2019
gradle/wrapper fix: Switch to maven plugin Nov 2, 2019
parser fix: Remove unused variable in a test Nov 2, 2019
sample feat: Add simple sample app Nov 2, 2019
.gitattributes fix: Add gitattributes file Nov 2, 2019
.gitignore Initialize empty project Nov 1, 2019
LICENSE Add License Nov 2, 2019
README.md
build.gradle.kts fix: Switch to maven plugin Nov 2, 2019
gradlew Initialize empty project Nov 1, 2019
gradlew.bat Initialize empty project Nov 1, 2019
settings.gradle fix: Switch to maven plugin Nov 2, 2019

README.md

OpenGraphKt

Build Status

A dead simple OpenGraph Tags parser for Kotlin, built using Coroutines and Jsoup.

Usage

The API is exposed through suspending extension functions.

// In a coroutine scope, or inside runBlocking

val url = URL("https://ogp.me/")
val tags = url.getOpenGraphTags()

println("""
Title: ${tags.title}
Description: ${tags.description}
Locale: ${tags.getProperty("locale")}
""")

The getOpenGraphTags() method returns a Tags class which only acts as a wrapper around the underlying Map<String, List<String>> object.

Tags is an inline class, and Inline classes are currently experimental, so make sure you're okay with that before using this library.

Limitations

The library currently only supports the og: namespace.

Contribution

Please feel free to open issues or contribute new features through pull requests.

Download

The library is published on Jitpack. Make sure to add it as a repository to your build.gradle file:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

And then add the library dependency:

dependencies {
  implementation "com.github.haroldadmin:opengraphKt:(latest-version)"
}

Latest Version

You can’t perform that action at this time.