{"id":15646794,"url":"https://github.com/michael-simons/java-oembed","last_synced_at":"2025-08-16T15:31:45.497Z","repository":{"id":1256416,"uuid":"1195163","full_name":"michael-simons/java-oembed","owner":"michael-simons","description":"Simple oembed implementation for Java based on Apache HttpClient","archived":false,"fork":false,"pushed_at":"2024-06-13T11:57:44.000Z","size":374,"stargazers_count":47,"open_issues_count":0,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-08T08:51:33.635Z","etag":null,"topics":["java","oembed-components"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michael-simons.png","metadata":{"files":{"readme":"README.textile","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-BSD.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-12-24T08:39:48.000Z","updated_at":"2024-06-13T11:58:14.000Z","dependencies_parsed_at":"2024-10-03T12:16:12.224Z","dependency_job_id":"99ef2867-33bf-4f10-b918-c981198ccc07","html_url":"https://github.com/michael-simons/java-oembed","commit_stats":null,"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-simons%2Fjava-oembed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-simons%2Fjava-oembed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-simons%2Fjava-oembed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-simons%2Fjava-oembed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michael-simons","download_url":"https://codeload.github.com/michael-simons/java-oembed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230043142,"owners_count":18163966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","oembed-components"],"created_at":"2024-10-03T12:14:54.617Z","updated_at":"2024-12-17T00:11:52.903Z","avatar_url":"https://github.com/michael-simons.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"h1. Simple oembed implementation for Java based on Apache HttpClient\n\nThis is a very simple Java client for consuming \"Oembed\":http://www.oembed.com/ enabled sites.\n\nIt uses \"Jackson\":http://jackson.codehaus.org/ for JSON processing and JAXB for XML parsing.\n\nThe core service of this project is the _OembedService_ which takes several endpoints. Those endpoints contains url schemes of urls that should be embedded, the URL of the corresponding Oembed endpoint and optional renderers.\n\njava-oembed can be configured to use an \"ehcache CacheManager instance\":http://ehcache.org/.\n\nThe project is a ready to use configured maven/eclipse project and works nice my \"java-autolinker\":https://github.com/michael-simons/java-autolinker.\n\n*Important*\n\nSince version 0.4.1 this project is Java 8 *only*. Upgrading from 0.3.x will break stuff. I've rewritten nearly everything from scratch, so have a look at the test code or the following small example. The project is now fully tested.\n\nSince version 0.6.1 this project is Java 10 *only*. In addition, it uses Spring Boots dependency management. Upgrading from 0.5.x will break stuff if you're not on JDK10 or higher.\n\nSince version 0.7.1 I have changed the API of _OembedService_ and removed _Optional\u003c\u003e_ as input parameter as suggested by various people (Joshua Bloch, Simon Harrer and others). I also took the freedom to apply some checkstyle rules and thus noticing I had several classes from which could have been extended. Those are now final as they should not have been part of the public API.\n\nSince version 0.8.1 this project is Java 11 *only*.\n\nThe project is not yet on the module path because java-oembed uses JAXB for parsing XML which currently leads to a \"split-package problem\":https://github.com/javaee/jaxb-v2/issues/1168.\n\nh2. Usage\n\nh3. Dependency:\n\njava-oembed is available in the Central Repository (since 0.2.10):\n\n\u003cpre\u003e\u003ccode\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eeu.michael-simons\u003c/groupId\u003e\n    \u003cartifactId\u003ejava-oembed\u003c/artifactId\u003e\n    \u003cversion\u003e0.8.1\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c/code\u003e\u003c/pre\u003e\n\nh3. Standalone\n\n\u003cpre\u003e\u003ccode lang=\"java\"\u003e\npublic static void main(String... a) {\n\tfinal List\u003cOembedEndpoint\u003e endpoints = new ArrayList\u003c\u003e();\n\tOembedEndpoint endpoint;\n\n\tendpoint = new OembedEndpoint();\n\tendpoint.setName(\"youtube\");\n\tendpoint.setFormat(Format.json);\n\tendpoint.setMaxWidth(480);\n\tendpoint.setEndpoint(\"https://www.youtube.com/oembed\");\n\tendpoint.setUrlSchemes(Arrays.asList(\"https?://(www|de)\\\\.youtube\\\\.com/watch\\\\?v=.*\"));\n\t// Optional, specialised renderer, not included here\n\t// endpoint.setResponseRendererClass(YoutubeRenderer.class);\n\tendpoints.add(endpoint);\n\n\tfinal OembedService oembedService = new OembedService(new DefaultHttpClient(), null, endpoints, \"some-app\");\n\tSystem.out.println(oembedService.embedUrls(\"Need some action... \u003ca href=\\\"https://www.youtube.com/watch?v=dgL6ovr3DJM\\\"\u003eThe Hoff!\u003c/a\u003e\", Optional.empty()));\n    }\n\u003c/code\u003e\u003c/pre\u003e\n\nThe builders are gone as you may have noticed. You can add / write them, if you want ;), otherwise i recommend using that stuff in a Spring Boot application like so:\n\nh3. In a Spring Boot application\n\n\u003cpre\u003e\u003ccode lang=\"java\"\u003e\nimport ac.simons.oembed.OembedEndpoint;\nimport ac.simons.oembed.OembedService;\nimport java.util.List;\nimport net.sf.ehcache.CacheManager;\nimport org.apache.http.client.HttpClient;\nimport org.springframework.boot.context.properties.ConfigurationProperties;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\n\n/**\n * @author Michael J. Simons, 2014-12-31\n */\n@Configuration\n@ConfigurationProperties(prefix = \"some-app.oembed\")\npublic class OembedConfig {\n    private List\u003cOembedEndpoint\u003e endpoints;\n\n    private boolean autodiscovery = false;\n\n    private String cacheName;\n\n    private Integer defaultCacheAge;\n\n    public List\u003cOembedEndpoint\u003e getEndpoints() {\n\treturn endpoints;\n    }\n\n    public void setEndpoints(List\u003cOembedEndpoint\u003e endpoints) {\n\tthis.endpoints = endpoints;\n    }\n\n    public boolean isAutodiscovery() {\n\treturn autodiscovery;\n    }\n\n    public void setAutodiscovery(boolean autodiscovery) {\n\tthis.autodiscovery = autodiscovery;\n    }\n\n    public String getCacheName() {\n\treturn cacheName;\n    }\n\n    public void setCacheName(String cacheName) {\n\tthis.cacheName = cacheName;\n    }\n\n    public Integer getDefaultCacheAge() {\n\treturn defaultCacheAge;\n    }\n\n    public void setDefaultCacheAge(Integer defaultCacheAge) {\n\tthis.defaultCacheAge = defaultCacheAge;\n    }\n\n    @Bean\n    public OembedService oembedService(HttpClient httpClient, CacheManager cacheManager) {\n\tfinal OembedService oembedService = new OembedService(httpClient, cacheManager, endpoints, \"some-app\");\n\toembedService.setAutodiscovery(this.autodiscovery);\n\tif(this.cacheName != null) {\n\t    oembedService.setCacheName(cacheName);\n\t}\n\tif(this.defaultCacheAge != null) {\n\t    oembedService.setDefaultCacheAge(defaultCacheAge);\n\t}\n\treturn oembedService;\n    }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\nand achieving the same result as in the stand alone version through the following properties:\n\n\u003cpre\u003e\u003ccode\u003e\n# A flag wether autodiscovery of oembed endpoints should be tried. Defaults to false.\n# some-app.oembed.autodiscovery =\n\n# The name of the cached used by this service. Defaults to \"ac.simons.oembed.OembedService\".\n# some-app.oembed.cacheName\n\n# Time in seconds responses are cached. Used if the response has no cache_age, defaults to 3600 (one hour).\n# some-app.oembed.defaultCacheAge =\n\nsome-app.oembed.endpoints[0].name = youtube\nsome-app.oembed.endpoints[0].endpoint = https://www.youtube.com/oembed\nsome-app.oembed.endpoints[0].maxWidth = 480\nsome-app.oembed.endpoints[0].urlSchemes[0] = https?://(www|de)\\\\.youtube\\\\.com/watch\\\\?v=.*\n# some-app.oembed.endpoints[0].responseRendererClass = de.dailyfratze.text.oembed.YoutubeRenderer\n\u003c/code\u003e\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael-simons%2Fjava-oembed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichael-simons%2Fjava-oembed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael-simons%2Fjava-oembed/lists"}