Skip to content

Commit

Permalink
Fix/youtube blockage (#137)
Browse files Browse the repository at this point in the history
* Update player errors to look better

* Update InnerTube

* Add a check for the video ID returned from YouTube
  • Loading branch information
kuylar authored Apr 2, 2024
1 parent c24b2b7 commit 082af42
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
5 changes: 5 additions & 0 deletions LightTube/Controllers/YoutubeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public async Task<IActionResult> Watch(string v, string? list, bool contentCheck
player = await _youtube.GetPlayerAsync(v, contentCheckOk, false, HttpContext.GetLanguage(),
HttpContext.GetRegion());
e = null;
if (player.Details.Id != v)
{
e = new Exception($"YouTube returned a different video than the requested one ({v} != {player.Details.Id})");
player = null;
}
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion LightTube/LightTube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PublishReadyToRunExclude Include="ZstdSharp.dll" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="InnerTube" Version="1.0.28" />
<PackageReference Include="InnerTube" Version="1.0.29" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.8" />
<PackageReference Include="MongoDB.Driver" Version="2.23.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
47 changes: 35 additions & 12 deletions LightTube/Views/Shared/Player.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,36 @@
}
else
{
<div id="player" class="player @(Model.GetClass()) error" style="background-image: url('@Model.Thumbnails.LastOrDefault()?.Url')">
<span>
@Model.Exception.Message
</span>
<div class="player-error-container">
<div class="player-error-icon">
<svg class="icon" fill="currentColor" style="color: white;" width="128" height="128">
<use xlink:href="/svg/bootstrap-icons.svg#exclamation-circle"></use>
</svg>
</div>
<div class="player-error-info">
<div class="title">An error has occurred @(Model.Exception.GetType() == typeof(Exception) ? "" : $"({Model.Exception.GetType().Name})")</div>
<p class="ml-1">@Model.Exception.Message</p>
<p>
This error might not occur in other instances. Find them <a href="https://github.com/lighttube-org/LightTube/blob/master/INSTANCES.md">here</a>
</p>
</div>
</div>
}
}
else
{
<div id="player" class="player @(Model.GetClass()) error" style="background-image: url('@Model.Thumbnails.LastOrDefault()?.Url')">
<span>
Failed to load player
</span>
<div class="player-error-container">
<div class="player-error-icon">
<svg class="icon" fill="currentColor" style="color: white;" width="128" height="128">
<use xlink:href="/svg/bootstrap-icons.svg#exclamation-circle"></use>
</svg>
</div>
<div class="player-error-info">
<div class="title">Failed to load the player</div>
<p>
This might not occur in other instances. Find them <a href="https://github.com/lighttube-org/LightTube/blob/master/INSTANCES.md">here</a>
</p>
</div>
</div>
}
}
Expand Down Expand Up @@ -109,10 +126,16 @@ else if (Model.Player.Formats.Any())
else
{
playable = false;
<div id="player" class="player @(Model.GetClass()) error" style="background-image: url('@Model.Thumbnails.LastOrDefault()?.Url')">
<span>
No muxed formats were returned by YouTube
</span>
<div class="player-error-container">
<div class="player-error-icon">
<svg class="icon" fill="currentColor" style="color: white;" width="128" height="128">
<use xlink:href="/svg/bootstrap-icons.svg#exclamation-circle"></use>
</svg>
</div>
<div class="player-error-info">
<div class="title">An error has occurred</div>
<p>No muxed formats were returned from YouTube</p>
</div>
</div>
}

Expand Down

0 comments on commit 082af42

Please sign in to comment.