Example #1
0
    private IEnumerator GetChannelVideosByUsername(string usernameToGetChannelVideosFrom)
    {
        // Lets get Lucky's id first
        TwitchLib.Api.Models.Helix.Users.GetUsers.GetUsersResponse getUsersResponse = null;
        yield return(_api.InvokeAsync(_api.Users.helix.GetUsersAsync(logins: new List <string> {
            usernameToGetChannelVideosFrom
        }),
                                      (response) => getUsersResponse = response));

        // We won't reach this point until the api request is completed, and the getUsersResponse is set.

        // We'll assume the request went well and that we made no typo's, meaning we should have 1 user at index 0, which is LuckyNoS7evin
        string luckyId = getUsersResponse.Users[0].Id;

        // Now that we have lucky's id, lets get his videos!
        TwitchLib.Api.Models.v5.Channels.ChannelVideos channelVideos = null;
        yield return(_api.InvokeAsync(_api.Channels.v5.GetChannelVideosAsync(luckyId),
                                      (response) => channelVideos = response));

        // Again, we won't reach this point until the request is completed!

        // Handle user's ChannelVideos
        // Using this way of calling the api, we still have access to usernameToGetChannelVideosFrom!

        var listOfVideoTitles          = GetListOfVideoTitles(channelVideos);
        var printableListOfVideoTitles = string.Join("  |  ", listOfVideoTitles);

        Debug.Log($"Videos from user {usernameToGetChannelVideosFrom}: {printableListOfVideoTitles}");
    }
Example #2
0
    private void GetChannelVideosCallback(TwitchLib.Api.Models.v5.Channels.ChannelVideos e)
    {
        var listOfVideoTitles          = GetListOfVideoTitles(e);
        var printableListOfVideoTitles = string.Join("  |  ", listOfVideoTitles);

        Debug.Log($"Videos from 14900522: {printableListOfVideoTitles}");
    }
Example #3
0
    private List <string> GetListOfVideoTitles(TwitchLib.Api.Models.v5.Channels.ChannelVideos channelVideos)
    {
        List <string> videoTitles = new List <string>();

        foreach (var video in channelVideos.Videos)
        {
            videoTitles.Add(video.Title);
        }

        return(videoTitles);
    }