Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.flaflo:YouTubePlus:1.0.2'
}
dependencies {
implementation("com.github.flaflo:YouTubePlus:1.0.2")
}
<dependency>
<groupId>com.github.flaflo</groupId>
<artifactId>YouTubePlus</artifactId>
<version>1.0.2</version>
</dependency>
libraryDependencies += "com.github.flaflo" % "YouTubePlus" % "1.0.2"
:dependencies [[com.github.flaflo/YouTubePlus "1.0.2"]]
A YouTube Library
To parse a YouTubePlaylist you use the YouTubePlaylistParser:
final YouTubePlaylistParser playlistParser = new YouTubePlaylistParser("GOOGLE_API_KEY");
final YouTubePlaylist playlist = playlistParser.parsePlaylist("PLAYLIST_ID");
You can get various informations from a Playlist.
As example you can get all YouTubeVideos contained in a YouTubePlaylist by iterating through it like a java.util.List.
To parse a YouTubeVideo you use the YouTubeVideoParser:
final YouTubeVideoParser videoParser = new YouTubeVideoParser("GOOGLE_API_KEY");
final YouTubeVideo video = videoParser.parseVideo("VIDEO_ID");
A YouTubeVideo has a container to store informations about it, the YouTubeVideoInfo.
To get it use its getter:
final YouTubeVideoInfo videoInfo = video.getInfo();
To get a YouTubeVideoInfo you can either get it through a YouTubeVideo as shown above or through the YouTubeVideoInfoProvider:
final YouTubeVideoInfoProvider infoProvider = new YouTubeVideoInfoProvider("GOOGLE_API_KEY");
final YouTubeVideoInfo info = infoProvider.provideYouTubeVideoInfo("videoId");
The YouTubeVideoInfo contains informations about a YouTubeVideo.
The following is stored by the YouTubeVideoInfo at the moment:
final String title = info.getTitle();
final Date publishedAt = info.getPublishedAt();
final String channelId = info.getChannelId();
final String description = info.getDescription();
final String[] tags = info.getTags();
final String videoId = info.getVideoId();
final String videoFile = info.getVideoFile();
To get a YouTubeThumbnail you use the YouTubeThumbnailParser, this will return a YouTubeThumbnailContainer which contains all thumbnails in their resolutions. You can get them by providing a YouTubeThumbnailFormat:
final YouTubeThumbnailParser thumbnailParser = new YouTubeThumbnailParser("GOOGLE_API_KEY");
final YouTubeThumbnailContainer thumbnailContainer = thumbnailParser.parseThumbnail("videoId");
final YouTubeThumbnail thumbnail = thumbnailContainer.getThumbnail(YouTubeThumbnailFormat.MAXRES);
The YouTubeThumbnail contains the following informations:
final YouTubeThumbnailFormat = thumbnail.getFormat();
final Image image = thumbnail.getImage();
You can also create thumbnail objects by an url or image object you provide in the YouTubeThumbnailParser:
final YouTubeThumbnail createdThumbnail = thumbnailParser.createThumbnail(URL_OR_IMAGE);
A compiled version can be found under the GitHub releases.
Just add this repository and dependency to your pom file:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io/</url>
</repository>
<dependency>
<groupId>com.github.flaflo</groupId>
<artifactId>YouTubePlus</artifactId>
<version>1.0.1</version>
</dependency>