aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/vtuber/ScheduleHandler.java
blob: 094309b96abc65930a6ada2dde24870d71672a56 (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
package vtuber;

import com.pina.Holodex;
import com.pina.HolodexException;
import com.pina.datatypes.SimpleVideo;
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;

    }
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage