Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudogu/spotter
Content-Type and language recognition library
https://github.com/cloudogu/spotter
content-type detection java language maven mime-type recognition tika
Last synced: 4 days ago
JSON representation
Content-Type and language recognition library
- Host: GitHub
- URL: https://github.com/cloudogu/spotter
- Owner: cloudogu
- License: mit
- Created: 2017-11-26T21:41:10.000Z (almost 7 years ago)
- Default Branch: develop
- Last Pushed: 2023-08-24T20:27:27.000Z (about 1 year ago)
- Last Synced: 2024-04-13T22:48:08.952Z (7 months ago)
- Topics: content-type, detection, java, language, maven, mime-type, recognition, tika
- Language: Java
- Homepage:
- Size: 246 KB
- Stars: 4
- Watchers: 11
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spotter
[![Build Status](https://travis-ci.org/sdorra/spotter.svg?branch=master)](https://travis-ci.org/sdorra/spotter)
[![Maven Central](https://img.shields.io/maven-central/v/com.cloudogu.spotter/spotter.svg)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22spotter%22)
[![Quality Gates](https://sonarcloud.io/api/project_badges/measure?project=com.cloudogu.spotter%3Aspotter&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.cloudogu.spotter%3Aspotter)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.cloudogu.spotter%3Aspotter&metric=coverage)](https://sonarcloud.io/dashboard?id=com.cloudogu.spotter%3Aspotter)Spotter is a library which is able to detect the content type of a file.
It is also able to detect the programming language of source files.
Spotter uses [Apache Tika](https://tika.apache.org/) for the content type recognition and uses the [language.yml](https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml) from the [Linguist project](https://github.com/github/linguist).## Usage
Add the latest stable version of to the dependency management tool of your choice.
E.g. for maven:
```xml
com.cloudogu.spotter
spotter-core
x.y.z```
Use the latest version from maven central: [![Maven Central](https://img.shields.io/maven-central/v/com.cloudogu.spotter/spotter.svg)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22spotter%22)
For versions before 4.0.0 use the following coordinates:
```xml
com.github.sdorra
spotter-core
x.y.z```
### Examples
Detect the content type and the programming language of a file:
```java
ContentType contentType = ContentTypes.detect("com/cloudogu/spotter/Language.java");
System.out.println("Content-Type: " + contentType);Optional language = contentType.getLanguage();
if (language.isPresent()) {
System.out.println("Language : " + language.get().getName());
}
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details