opt in YoutubeAPI

This commit is contained in:
mrbesen 2021-10-18 22:35:44 +02:00
parent a0b0ce6bfb
commit 9d1d73137e
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 8 additions and 5 deletions

View File

@ -101,10 +101,13 @@ public class YoutubeAPI {
private Crawler.Video getVid(JSONObject json) {
String vdid = json.getString("id");
JSONObject snippet = json.getJSONObject("snippet");
String title = snippet.getString("title"); //maxlen: 100
long published = getDate(snippet.getString("publishedAt"));
String channel = snippet.getString("channelTitle");
String tags = snippet.getJSONArray("tags").toList().stream().map(o -> (String) o).collect(Collectors.joining(",")); // max len: ~500
String title = snippet.optString("title", ""); //maxlen: 100
long published = getDate(snippet.optString("publishedAt", ""));
String channel = snippet.optString("channelTitle", "");
String tags = "";
if(snippet.optJSONArray("tags") != null)
tags = snippet.getJSONArray("tags").toList().stream().map(o -> (String) o).collect(Collectors.joining(",")); // max len: ~500
byte category = 0;
try {
@ -112,7 +115,7 @@ public class YoutubeAPI {
} catch(NumberFormatException e) {}
JSONObject contentDetails = json.getJSONObject("contentDetails");
int duration = (int) getDuration(contentDetails.getString("duration"));
int duration = (int) getDuration(contentDetails.optString("duration", ""));
boolean live = !snippet.getString("liveBroadcastContent").equalsIgnoreCase("none");
String langCode = snippet.optString("defaultLanguage", snippet.optString("defaultAudioLanguage", ""));