blob: 2990bbfa4335f6c0b56223ca6d3a6538613f05e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
package vtuber;
import com.pina.Holodex;
import com.pina.HolodexException;
import com.pina.datatypes.Channel;
import com.pina.datatypes.SimpleChannel;
import com.pina.datatypes.SimpleVideo;
import com.pina.query.ChannelQueryBuilder;
import com.pina.query.VideoQueryBuilder;
import java.util.ArrayList;
import java.util.List;
public class ScheduleHandler {
Holodex holodex;
public ScheduleHandler(String apikey) {
System.out.println("ScheduleHandler initialized");
holodex = new Holodex(apikey);
}
public List<SimpleVideo> getSchedule(String org, int limit) {
System.out.println("Getting schedule for " + org);
List<SimpleVideo> upcomingAndLiveVideos = new ArrayList<>();
try {
List<SimpleVideo> upcomingVideos = holodex.getLiveAndUpcomingVideos(new VideoQueryBuilder().setOrg(org).setLimit(limit).setStatus("upcoming"));
List<SimpleVideo> liveVideos = holodex.getLiveAndUpcomingVideos(new VideoQueryBuilder().setStatus("live").setOrg(org).setLimit(limit));
upcomingAndLiveVideos.addAll(liveVideos);
upcomingAndLiveVideos.addAll(upcomingVideos);
} catch (HolodexException e) {
System.out.println("Error getting schedule for " + org);
System.out.println(e.getMessage());
}
return upcomingAndLiveVideos;
}
public List<SimpleVideo> getSchedule(String org) {
System.out.println("Getting schedule for " + org);
List<SimpleVideo> upcomingAndLiveVideos = new ArrayList<>();
try {
List<SimpleVideo> upcomingVideos = holodex.getLiveAndUpcomingVideos(new VideoQueryBuilder().setOrg(org).setStatus("upcoming"));
List<SimpleVideo> liveVideos = holodex.getLiveAndUpcomingVideos(new VideoQueryBuilder().setStatus("live").setOrg(org));
upcomingAndLiveVideos.addAll(liveVideos);
upcomingAndLiveVideos.addAll(upcomingVideos);
} catch (HolodexException e) {
System.out.println("Error getting schedule for " + org);
System.out.println(e.getMessage());
}
return upcomingAndLiveVideos;
}
public List<SimpleVideo> getScheduleChannelId(String channelId) {
System.out.println("Getting schedule for " + channelId);
List<SimpleVideo> upcomingAndLiveVideos = new ArrayList<>();
try {
List<SimpleVideo> upcomingVideos = holodex.getLiveAndUpcomingVideos(new VideoQueryBuilder().setChannelId(channelId).setStatus("upcoming"));
List<SimpleVideo> liveVideos = holodex.getLiveAndUpcomingVideos(new VideoQueryBuilder().setStatus("live").setChannelId(channelId));
upcomingAndLiveVideos.addAll(liveVideos);
upcomingAndLiveVideos.addAll(upcomingVideos);
} catch (HolodexException e) {
System.out.println("Error getting schedule for " + channelId);
System.out.println(e.getMessage());
}
return upcomingAndLiveVideos;
}
public boolean organizationExists(String org) {
List<Channel> channels = new ArrayList<>();
try {
channels = holodex.getChannels(new ChannelQueryBuilder().setOrg(org));
} catch (HolodexException e) {
System.out.println("Couldn't find organization with name " + org);
return false;
}
return channels.size() > 0;
}
public boolean channelExists(String channelId) {
Channel channel = new Channel();
try{
channel = holodex.getChannel(channelId);
if (channel.name == null) {
throw new HolodexException("Searching channel successful but no results found");
}
} catch (HolodexException e) {
System.out.println("Couldn't find channel with id " + channelId);
return false;
}
return true;
}
}
|