Skip to content

Commit

Permalink
Merge pull request #13 from lay295/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
superbonaci authored Dec 9, 2023
2 parents 4aa7309 + dd5557d commit 2e1a47d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
3 changes: 2 additions & 1 deletion TwitchDownloaderCore.Tests/TimeSpanHFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public void ThrowsOnImbalancedQuoteMarkEscaping_WhenHoursUnder24()
var exception = Assert.Throws(expectedExceptionType, () => TimeSpanHFormat.ReusableInstance.Format(FORMAT_STRING, timeSpan));

// Ensure the FormatException originated from TimeSpanHFormat and not TimeSpan.ToString()
Assert.IsType<FormatException>(exception);
Assert.Equal(EXPECTED_SOURCE_NAME, exception.Source);
Assert.Equal($"Invalid character escaping in the format string: {FORMAT_STRING}", exception.Message);
}

[Fact]
Expand All @@ -242,6 +242,7 @@ public void ThrowsOnImbalancedQuoteMarkEscaping_When24HoursOrMore()
var exception = Assert.Throws(expectedExceptionType, () => TimeSpanHFormat.ReusableInstance.Format(FORMAT_STRING, timeSpan));

// Ensure the FormatException originated from TimeSpanHFormat and not TimeSpan.ToString()
Assert.IsType<FormatException>(exception);
Assert.Equal(EXPECTED_SOURCE_NAME, exception.Source);
}
}
Expand Down
2 changes: 1 addition & 1 deletion TwitchDownloaderCore/ChatDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private static List<Comment> ConvertComments(CommentVideo video, ChatFormat form
content_offset_seconds = oldComment.contentOffsetSeconds,
commenter = new Commenter
{
display_name = oldComment.commenter.displayName,
display_name = oldComment.commenter.displayName.Trim(),
_id = oldComment.commenter.id,
name = oldComment.commenter.login
}
Expand Down
1 change: 0 additions & 1 deletion TwitchDownloaderCore/Tools/TimeSpanHFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace TwitchDownloaderCore.Tools
{
/// <summary>Adds an 'H' parameter to <see cref="TimeSpan"/> string formatting. The 'H' parameter is equivalent to flooring <see cref="TimeSpan"/>.<see cref="TimeSpan.TotalHours"/>.</summary>
/// <remarks>
/// This formatter only supports escaping 'H's via '\'.
/// For optimal memory performance, resulting strings split about any 'H' parameters should be less than 256.
/// </remarks>
public class TimeSpanHFormat : IFormatProvider, ICustomFormatter
Expand Down
2 changes: 1 addition & 1 deletion TwitchDownloaderCore/VideoDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ private static async Task DownloadVideoPartAsync(HttpClient httpClient, Uri base
}

string[] videoPlaylist = await TwitchHelper.GetVideoPlaylist(downloadOptions.Id, accessToken.data.videoPlaybackAccessToken.value, accessToken.data.videoPlaybackAccessToken.signature);
if (videoPlaylist[0].Contains("vod_manifest_restricted"))
if (videoPlaylist[0].Contains("vod_manifest_restricted") || videoPlaylist[0].Contains("unauthorized_entitlements"))
{
throw new NullReferenceException("Insufficient access to VOD, OAuth may be required.");
}
Expand Down
8 changes: 3 additions & 5 deletions TwitchDownloaderWPF/PageVodDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using TwitchDownloaderCore;
using TwitchDownloaderCore.Extensions;
using TwitchDownloaderCore.Options;
using TwitchDownloaderCore.Tools;
using TwitchDownloaderCore.TwitchObjects.Gql;
Expand Down Expand Up @@ -99,8 +98,6 @@ private async Task GetVideoInfo()
throw new NullReferenceException("Invalid VOD, deleted/expired VOD possibly?");
}

Task<string[]> taskPlaylist = TwitchHelper.GetVideoPlaylist(videoId, taskAccessToken.Result.data.videoPlaybackAccessToken.value, taskAccessToken.Result.data.videoPlaybackAccessToken.signature);

var thumbUrl = taskVideoInfo.Result.data.video.thumbnailURLs.FirstOrDefault();
if (!ThumbnailService.TryGetThumb(thumbUrl, out var image))
{
Expand All @@ -111,8 +108,9 @@ private async Task GetVideoInfo()

comboQuality.Items.Clear();
videoQualities.Clear();
string[] playlist = await taskPlaylist;
if (playlist[0].Contains("vod_manifest_restricted"))

var playlist = await TwitchHelper.GetVideoPlaylist(videoId, taskAccessToken.Result.data.videoPlaybackAccessToken.value, taskAccessToken.Result.data.videoPlaybackAccessToken.signature);
if (playlist[0].Contains("vod_manifest_restricted") || playlist[0].Contains("unauthorized_entitlements"))
{
throw new NullReferenceException(Translations.Strings.InsufficientAccessMayNeedOauth);
}
Expand Down

0 comments on commit 2e1a47d

Please sign in to comment.