Skip to content

Commit

Permalink
Fix/hack for getting youtube video streams/chat urls
Browse files Browse the repository at this point in the history
  • Loading branch information
laurencee committed Sep 15, 2019
1 parent 1c1963c commit c566bd6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 4 additions & 5 deletions ExternalAPIs.Tests/YoutubeClientShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace ExternalAPIs.Tests
{
public class YoutubeClientShould
{
private const string SKY_NEWS_VIDEO_ID = "y60wDzZt8yg";
private const string SKY_NEWS_VIDEO_ID = "siyW0GOBtbo";
private const string SKY_NEWS_CHANNEL_ID = "UCoMdktPbSTixAyNGwb-UYkQ";
private readonly YoutubeReadonlyClient sut = new YoutubeReadonlyClient();

[Fact, Trait("Category", "LocalOnly")]
Expand Down Expand Up @@ -37,7 +38,7 @@ public async Task ThrowNotFoudExceptionForInvalidVideoId()
[Fact, Trait("Category", "LocalOnly")]
public async Task GetChannelIdFromUsername()
{
const string channelName = "LoLChampSeries";
const string channelName = "skynews";
var channelId = await sut.GetChannelIdFromUsername(channelName);

Assert.NotNull(channelId);
Expand All @@ -46,9 +47,7 @@ public async Task GetChannelIdFromUsername()
[Fact, Trait("Category", "LocalOnly")]
public async Task GetLiveVideos()
{
// channelId of the value returned by the test "GetChannelIdFromUsername"
const string channelId = "UCvqRdlKsE5Q8mf8YXbdIJLw";
var onlineVideos = await sut.GetLivestreamVideos(channelId);
var onlineVideos = await sut.GetLivestreamVideos(SKY_NEWS_CHANNEL_ID);

Assert.NotNull(onlineVideos);
Assert.NotNull(onlineVideos.Items);
Expand Down
4 changes: 2 additions & 2 deletions GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.12.5.0")]
[assembly: AssemblyFileVersion("2.12.5.0")]
[assembly: AssemblyVersion("2.12.6.0")]
[assembly: AssemblyFileVersion("2.12.6.0")]
14 changes: 11 additions & 3 deletions Livestream.Monitor/Model/LivestreamModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,17 @@ public string Language
}
}

public Task<string> GetStreamUrl => ApiClient?.GetStreamUrl(ChannelIdentifier.ChannelId);

public Task<string> GetChatUrl => ApiClient?.GetChatUrl(ChannelIdentifier.ChannelId);
public Task<string> GetStreamUrl => ApiClient?.GetStreamUrl(
ApiClient.ApiName == YoutubeApiClient.API_NAME
? Id // hack as youtube can return multiple livestreams for a channel and we store the video id in this field
: ChannelIdentifier.ChannelId
);

public Task<string> GetChatUrl => ApiClient?.GetChatUrl(
ApiClient.ApiName == YoutubeApiClient.API_NAME
? Id // hack as youtube can return multiple livestreams for a channel and we store the video id in this field
: ChannelIdentifier.ChannelId
);

/// <summary> The username this livestream came from via importing (twitch allows importing followed streams) </summary>
public string ImportedBy { get; set; }
Expand Down

0 comments on commit c566bd6

Please sign in to comment.