Skip to content

Commit 8d989fa

Browse files
committed
2316 - SF
1 parent 48e2bb6 commit 8d989fa

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

server/libs/modules/components/google/youtube/src/main/java/com/bytechef/component/youtube/trigger/YoutubeNewVideoTrigger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ protected static PollOutput poll(
115115
TriggerContext triggerContext) {
116116

117117
String channelId = getChannelId(inputParameters.getRequiredString(IDENTIFIER), triggerContext);
118-
119118
ZoneId zoneId = ZoneId.systemDefault();
120119

121120
LocalDateTime now = LocalDateTime.now(zoneId);
122121

123122
LocalDateTime startDate = closureParameters.getLocalDateTime(LAST_TIME_CHECKED, now.minusHours(3));
123+
124124
ZonedDateTime startZonedDate = startDate.atZone(zoneId);
125125

126126
Map<String, Object> response =

server/libs/modules/components/google/youtube/src/main/java/com/bytechef/component/youtube/util/YoutubeUtils.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@
3939
public class YoutubeUtils {
4040

4141
public static String getChannelId(String identifier, TriggerContext triggerContext) {
42-
43-
Map<String, Object> response =
44-
triggerContext.http(http -> http.get("https://www.googleapis.com/youtube/v3/search"))
45-
.queryParameters(
46-
"part", SNIPPET,
47-
"type", "channel",
48-
"q", identifier)
49-
.configuration(responseType(Http.ResponseType.JSON))
50-
.execute()
51-
.getBody(new TypeReference<>() {});
52-
5342
String channelId = "";
5443

44+
Map<String, Object> response = triggerContext
45+
.http(http -> http.get("https://www.googleapis.com/youtube/v3/search"))
46+
.queryParameters(
47+
"part", SNIPPET,
48+
"type", "channel",
49+
"q", identifier)
50+
.configuration(responseType(Http.ResponseType.JSON))
51+
.execute()
52+
.getBody(new TypeReference<>() {});
53+
5554
if (response.get(ITEMS) instanceof List<?> channels &&
5655
channels.getFirst() instanceof Map<?, ?> channelMap &&
5756
channelMap.get(ID) instanceof Map<?, ?> channelIdMap) {
@@ -66,17 +65,17 @@ public static List<Option<String>> getVideoCategoryIdOptions(
6665
Parameters inputParameters, Parameters connectionParameters, Map<String, String> stringStringMap, String s,
6766
Context context) {
6867

69-
Map<String, Object> response =
70-
context.http(http -> http.get("https://www.googleapis.com/youtube/v3/videoCategories"))
71-
.queryParameters(
72-
"part", SNIPPET,
73-
"regionCode", "US")
74-
.configuration(responseType(Http.ResponseType.JSON))
75-
.execute()
76-
.getBody(new TypeReference<>() {});
77-
7868
List<Option<String>> options = new ArrayList<>();
7969

70+
Map<String, Object> response = context
71+
.http(http -> http.get("https://www.googleapis.com/youtube/v3/videoCategories"))
72+
.queryParameters(
73+
"part", SNIPPET,
74+
"regionCode", "US")
75+
.configuration(responseType(Http.ResponseType.JSON))
76+
.execute()
77+
.getBody(new TypeReference<>() {});
78+
8079
if (response.get(ITEMS) instanceof List<?> items) {
8180
for (Object item : items) {
8281
if (item instanceof Map<?, ?> itemMap && itemMap.get(SNIPPET) instanceof Map<?, ?> snippetMap) {

0 commit comments

Comments
 (0)